/* ============================================================
   CV Online — App chrome
   Direccion: "mesa de trabajo editorial". Papel cálido, tinta
   azul profunda, acento verde pino y detalle latón. Display
   serif (Fraunces) con restricción, UI en Inter.
   ============================================================ */

:root {
  --paper:      #F4F2EC;
  --paper-2:    #EDEAE1;
  --surface:    #FFFFFF;
  --ink:        #16233F;   /* azul tinta */
  --ink-soft:   #3B4A66;
  --muted:      #7A8399;
  --line:       #DEDACE;
  --line-2:     #E9E6DC;
  --pine:       #2F6F5E;   /* acento */
  --pine-dark:  #235244;
  --brass:      #B58A3C;   /* detalle */
  --danger:     #B23A34;
  --danger-bg:  #FBEDEC;
  --ok:         #2F6F5E;

  --radius:     12px;
  --radius-sm:  8px;
  --shadow:     0 1px 2px rgba(22,35,63,.05), 0 8px 30px rgba(22,35,63,.08);
  --shadow-sm:  0 1px 2px rgba(22,35,63,.06);

  --sans: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --display: "Fraunces", Georgia, serif;

  --sb-track: transparent;
  --sb-thumb: #C9C3B2;
  --sb-thumb-hover: #A9A08A;
}

[data-theme="dark"] {
  --paper:      #151b27;
  --paper-2:    #1c2436;
  --surface:    #212d42;
  --ink:        #e8edf5;
  --ink-soft:   #a8b4cc;
  --muted:      #6a7a96;
  --line:       #2a3650;
  --line-2:     #243048;
  --pine:       #3d9b84;
  --pine-dark:  #2e7a67;
  --brass:      #c9a555;
  --danger:     #e05555;
  --danger-bg:  #2e1e1e;
  --ok:         #3d9b84;
  --shadow:     0 1px 2px rgba(0,0,0,.3), 0 8px 30px rgba(0,0,0,.4);
  --shadow-sm:  0 1px 2px rgba(0,0,0,.2);

  --sb-track: transparent;
  --sb-thumb: #35415C;
  --sb-thumb-hover: #4A587A;
}

/* ============================================================
   SCROLLBARS
   ============================================================ */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--sb-thumb) var(--sb-track);
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--sb-track); }
::-webkit-scrollbar-thumb {
  background: var(--sb-thumb);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
  transition: background .2s;
}
::-webkit-scrollbar-thumb:hover { background: var(--sb-thumb-hover); background-clip: padding-box; }
::-webkit-scrollbar-corner { background: transparent; }

/* Scrollbar sobre el panel oscuro del login */
.auth-aside { scrollbar-color: rgba(255,255,255,.18) transparent; }
.auth-aside::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); }
.auth-aside::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.3); }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  transition: background .2s, color .2s;
}
a { color: var(--pine); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }
h1,h2,h3 { margin: 0; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: .62em 1.05em; font-size: .93rem; font-weight: 600;
  transition: transform .04s ease, background .15s ease, border-color .15s ease, color .15s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #101c34; }
.btn-accent { background: var(--pine); color: #fff; }
.btn-accent:hover { background: var(--pine-dark); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--paper-2); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border-color: #EED2CF; }
.btn-danger:hover { background: #F6DEDC; }
.btn-sm { padding: .42em .7em; font-size: .82rem; }
.btn-block { width: 100%; }

/* ---------- Inputs ---------- */
.field { display: flex; flex-direction: column; gap: .32rem; margin-bottom: .8rem; }
.field label { font-size: .8rem; font-weight: 600; color: var(--ink-soft); }
.field .hint { font-size: .74rem; color: var(--muted); font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=tel],
input[type=url], input[type=date], input[type=month], textarea, select {
  width: 100%; font-family: inherit; font-size: .92rem; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: .58em .7em; transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--pine);
  box-shadow: 0 0 0 3px rgba(47,111,94,.14);
}
textarea { resize: vertical; min-height: 74px; line-height: 1.45; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .8rem; }
@media (max-width: 560px){ .row-2,.row-3 { grid-template-columns: 1fr; } }

/* Campo de fecha: texto libre + botón calendario */
.date-combo { position: relative; display: flex; align-items: stretch; }
.date-combo input[type=text] { flex: 1; padding-right: 2.4em; }
.date-hidden {
  position: absolute; right: .3em; top: 50%; transform: translateY(-50%);
  width: 1px; height: 1px; opacity: 0; pointer-events: none; padding: 0; border: 0;
}
.date-cal-btn {
  position: absolute; right: .28em; top: 50%; transform: translateY(-50%);
  width: 1.9em; height: 1.9em; display: grid; place-items: center;
  background: transparent; border: 0; cursor: pointer; font-size: 1rem; line-height: 1;
  border-radius: 6px; opacity: .75;
}
.date-cal-btn:hover { opacity: 1; background: var(--paper-2, rgba(0,0,0,.05)); }
.date-current-note {
  display: inline-flex; align-items: center; gap: .4em; font-size: .9rem;
  color: var(--pine); font-weight: 600; padding: .58em .1em;
}
.check-inline {
  display: flex !important; flex-direction: row !important; align-items: center; gap: .5rem;
  font-size: .82rem; font-weight: 500; color: var(--ink-soft); cursor: pointer; margin-bottom: .2rem;
}
.check-inline input[type=checkbox] { width: auto; margin: 0; accent-color: var(--pine); }

.checkbox { flex-direction: row; align-items: center; gap: .5rem; }
.checkbox input { width: auto; }
.checkbox label { font-weight: 500; color: var(--ink); }

/* ============================================================
   AUTH
   ============================================================ */
.auth-wrap {
  min-height: 100vh; display: grid; grid-template-columns: 1.1fr .9fr;
}
@media (max-width: 900px){
  .auth-wrap { grid-template-columns: 1fr; min-height: auto; }
}

.auth-aside {
  background:
    radial-gradient(900px 620px at 15% 115%, rgba(47,111,94,.30), transparent 62%),
    radial-gradient(620px 420px at 95% -12%, rgba(228,192,120,.14), transparent 58%),
    linear-gradient(160deg, #16233F 0%, #1D2F52 58%, #21395F 100%);
  color: #EDEFF5; padding: 3rem 3rem; position: relative; overflow: hidden;
  display: flex; flex-direction: column;
}
@media (max-width: 900px){ .auth-aside { padding: 2.2rem 1.5rem 2.5rem; } }

.mobile-cta { display: none; }

.aside-content { position: relative; z-index: 2; display: flex; flex-direction: column;
  gap: 1.6rem; height: 100%; }

.auth-brand { display: flex; align-items: center; gap: .7rem; font-family: var(--display);
  font-weight: 600; font-size: 1.22rem; letter-spacing: .2px; }
.auth-mark { width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center;
  background: var(--brass); color: #16233F; font-weight: 700; font-family: var(--display); }

/* ---- Hero ---- */
.auth-hero { margin-top: .4rem; }
.hero-kicker {
  display: inline-block; font-size: .68rem; font-weight: 600; letter-spacing: 1.4px;
  text-transform: uppercase; color: #9BB0A8; background: rgba(47,111,94,.22);
  border: 1px solid rgba(120,190,160,.22); padding: .35em .8em; border-radius: 999px;
  margin-bottom: .9rem;
}
.auth-hero h1 { font-family: var(--display); font-weight: 600; font-size: 2.9rem; line-height: 1.02;
  letter-spacing: -1px; margin: 0; }
.auth-hero h1 em { font-style: italic; color: #E7C889; position: relative; }
.auth-hero h1 em::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: .08em; height: 7px;
  background: rgba(231,200,137,.18); border-radius: 3px; z-index: -1;
}

/* ---- Steps ---- */
.auth-steps { display: flex; flex-direction: column; gap: .85rem; flex: 1; justify-content: center;
  max-width: 30ch; }
.auth-step { display: flex; gap: .8rem; align-items: baseline; }
.step-n {
  flex-shrink: 0; width: 22px; height: 22px; border-radius: 6px;
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.12);
  display: grid; place-items: center; font-size: .7rem; font-weight: 700;
  color: #E7C889; font-variant-numeric: tabular-nums; align-self: flex-start; margin-top: .1rem;
}
.step-txt { display: flex; flex-direction: column; gap: .1rem; }
.step-txt strong { font-size: .89rem; font-weight: 600; color: #E8EBF3; }
.step-txt span   { font-size: .78rem; color: #8093B0; line-height: 1.4; }

/* ---- Badge de precio ---- */
.price-badge {
  display: flex; flex-direction: column; gap: .35rem;
  align-self: flex-start; max-width: max-content;
  background: linear-gradient(135deg, rgba(255,255,255,.10), rgba(255,255,255,.045));
  border: 1px solid rgba(255,255,255,.15); border-radius: 14px;
  padding: .9rem 1.25rem; backdrop-filter: blur(10px);
  box-shadow: 0 8px 30px rgba(0,0,0,.28);
}
.price-label { font-size: .66rem; letter-spacing: 1.1px; text-transform: uppercase;
  color: #8CA0BE; font-weight: 600; }

.price-row { display: flex; align-items: center; gap: 1.1rem; }

.price-amount {
  display: flex; align-items: baseline; gap: .12rem;
  font-family: var(--sans); font-weight: 700; line-height: 1;
  font-variant-numeric: tabular-nums; font-feature-settings: 'tnum' 1;
}
.price-cur { font-size: 1.1rem; font-weight: 600; color: #E7C889; align-self: flex-start;
  margin-top: .18rem; }
.price-num { font-size: 2rem; color: #fff; letter-spacing: -1.2px; }
.price-ars { font-size: .72rem; font-weight: 600; color: #8CA0BE; letter-spacing: .6px;
  margin-left: .28rem; }

.price-mp { display: flex; align-items: center; gap: .5rem;
  padding-left: 1.1rem; border-left: 1px solid rgba(255,255,255,.12); }

.price-sub { font-size: .68rem; color: #6B7D9A; letter-spacing: .2px; }

.mp-logo {
  width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0;
  background: linear-gradient(135deg, #00B1EA, #0078C8);
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: .75rem;
  letter-spacing: -.3px; box-shadow: 0 3px 12px rgba(0,177,234,.4);
}
.mp-txt { font-size: .68rem; color: #8CA0BE; line-height: 1.3; white-space: nowrap; }
.mp-txt strong { color: #DCE4F0; font-weight: 600; font-size: .74rem; }

.auth-foot { font-size: .75rem; color: #5E6D87; display: flex; gap: 1.3rem; flex-wrap: wrap;
  border-top: 1px solid rgba(255,255,255,.06); padding-top: .95rem; }
.auth-foot span::before { content: '·'; margin-right: .55rem; color: rgba(255,255,255,.18); }
.auth-foot span:first-child::before { display: none; }

/* ---- Slider de plantillas ---- */
.auth-slider {
  position: absolute; right: -75px; top: 50%; transform: translateY(-50%);
  width: 390px; z-index: 1; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; gap: 1rem;
}
.slider-stack {
  position: relative; width: 390px; aspect-ratio: 1 / 1.414; /* proporción A4 */
  border-radius: 8px; overflow: hidden;
  box-shadow: 0 30px 80px rgba(0,0,0,.55), 0 0 0 1px rgba(255,255,255,.07);
  transform: rotate(4deg);
  animation: sliderFloat 10s ease-in-out infinite;
}
@keyframes sliderFloat {
  0%, 100% { transform: rotate(4deg) translateY(0); }
  50%      { transform: rotate(2.5deg) translateY(-10px); }
}
.slider-stack .slide {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; object-position: top center;
  opacity: 0; transition: opacity .9s ease;
}
.slider-stack .slide.active { opacity: 1; }

/* Velo para que no compita con el texto */
.slider-stack::after {
  content: ''; position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background: linear-gradient(105deg, rgba(22,35,63,.92) 0%, rgba(22,35,63,.45) 35%, rgba(22,35,63,.12) 70%);
}

.slider-dots { display: flex; gap: .4rem; opacity: .5; }
.slider-dots .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: rgba(255,255,255,.25); transition: background .4s, width .4s;
}
.slider-dots .dot.active { background: var(--brass); width: 18px; border-radius: 3px; }

@media (max-width: 1250px){ .auth-slider { opacity: .3; right: -150px; } }

.auth-main { display: grid; place-items: center; padding: 2rem; background: var(--paper); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .card-title { font-family: var(--display); font-size: 1.65rem; font-weight: 600; margin-bottom: .3rem; }
.auth-card .card-sub { color: var(--muted); font-size: .92rem; margin-bottom: 1.6rem; }
.auth-tabs { display: inline-flex; background: var(--paper-2); border-radius: 10px; padding: 4px; margin-bottom: 1.4rem; }
.auth-tabs button { border: none; background: transparent; color: var(--ink-soft); font-weight: 600;
  font-size: .88rem; padding: .5em 1em; border-radius: 7px; }
.auth-tabs button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.auth-alt { text-align: center; font-size: .86rem; color: var(--muted); margin-top: 1.1rem; }
.auth-title { font-family: var(--display); font-size: 1.4rem; font-weight: 600; margin-bottom: .3rem; }
.auth-sub { font-size: .88rem; color: var(--muted); margin-bottom: 1.1rem; }
.code-input input { text-align: center; letter-spacing: .6em; font-size: 1.5rem; font-weight: 600;
  font-variant-numeric: tabular-nums; }

/* ============================================================
   APP SHELL
   ============================================================ */
.topbar {
  position: sticky; top: 0; z-index: 30; height: 60px; display: flex; align-items: center;
  justify-content: space-between; padding: 0 1.4rem; background: rgba(244,242,236,.85);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.topbar .brand { display: flex; align-items: center; gap: .6rem; font-family: var(--display);
  font-weight: 600; font-size: 1.12rem; }
.topbar .brand .auth-mark { width: 26px; height: 26px; font-size: .9rem; }
.topbar .nav { display: flex; align-items: center; gap: .5rem; }
.topbar .who { font-size: .82rem; color: var(--muted); margin-right: .3rem; max-width: 22ch;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-admin { font-size: .68rem; font-weight: 700; color: var(--brass); border: 1px solid #E4CF9E;
  background: #FBF3DF; padding: .12em .5em; border-radius: 999px; text-transform: uppercase; letter-spacing: .5px; }
.btn-theme { background: transparent; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: .38em .55em; font-size: 1rem; line-height: 1; cursor: pointer; color: var(--ink-soft);
  transition: background .15s, color .15s; display: flex; align-items: center; }
.btn-theme:hover { background: var(--paper-2); color: var(--ink); }

/* ============================================================
   EDITOR
   ============================================================ */
.editor {
  display: grid; grid-template-columns: 480px 1fr; gap: 0;
  align-items: start; height: calc(100vh - 60px);
}
@media (max-width: 1100px){ .editor { grid-template-columns: 1fr; height: auto; } }

.form-pane {
  padding: 0 1.4rem 3rem;
  border-right: 1px solid var(--line);
  position: sticky; top: 60px;
  height: calc(100vh - 60px);
  overflow-y: auto;
  overflow-x: hidden;
}
.preview-pane {
  padding: 1.4rem;
  position: sticky; top: 60px;
  display: flex; flex-direction: column;
  height: calc(100vh - 60px);
  min-width: 0; overflow-x: hidden;
}

/* Controles de hoja y plantilla en el panel izquierdo */
.form-controls { padding: 1.2rem 0 1rem; border-bottom: 1px solid var(--line); margin-bottom: 1.4rem; }
.form-controls-row { display: flex; flex-wrap: wrap; align-items: center; gap: .7rem; margin-bottom: .9rem; }
.form-pane h2 { font-family: var(--display); font-size: 1.4rem; font-weight: 600; margin-bottom: .2rem; margin-top: 0; }
.form-pane .lead { color: var(--muted); font-size: .9rem; margin-bottom: 1.3rem; }

.section-block { background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius);
  padding: 1rem 1.05rem; margin-bottom: 1rem; box-shadow: var(--shadow-sm); }
.section-block > h3 { font-size: .78rem; font-weight: 700; letter-spacing: .8px; text-transform: uppercase;
  color: var(--pine); margin-bottom: 0; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: .9rem; }
.section-hint { font-size: .75rem; color: var(--ink-soft); margin: -.4rem 0 .75rem; font-style: italic; }

.repeat-item { border: 1px dashed var(--line); border-radius: var(--radius-sm); padding: .85rem;
  margin-bottom: .75rem; background: #FCFBF8; position: relative; }
.repeat-item .item-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem; }
.repeat-item .item-head strong { font-size: .82rem; color: var(--ink-soft); }
.item-head-actions { display: flex; align-items: center; gap: .25rem; }
.reorder-btn { background: none; border: 1px solid var(--border); border-radius: 4px; padding: 0 .3rem; font-size: .7rem; line-height: 1.6; cursor: pointer; color: var(--ink-soft); transition: background .15s, color .15s; }
.reorder-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.link-remove { background: none; border: none; color: var(--danger); font-size: .78rem; font-weight: 600; padding: .2em .3em; }
.link-remove:hover { text-decoration: underline; }
.bullets-list { display: flex; flex-direction: column; gap: .4rem; }
.bullet-row { display: flex; gap: .4rem; align-items: flex-start; }
.bullet-row textarea { min-height: 40px; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .4rem; }
.chip { display: inline-flex; align-items: center; gap: .4rem; background: var(--paper-2);
  border: 1px solid var(--line); border-radius: 999px; padding: .28em .7em; font-size: .82rem; }
.chip button { border: none; background: none; color: var(--muted); font-size: 1rem; line-height: 1; padding: 0; }
.chip button:hover { color: var(--danger); }

.photo-row { display: flex; align-items: center; gap: 1rem; margin-bottom: .8rem; }
.photo-prev { width: 66px; height: 66px; border-radius: 50%; object-fit: cover; border: 2px solid var(--line);
  background: var(--paper-2); flex: none; }

/* ---- Preview pane ---- */
.preview-toolbar { display: flex; flex-wrap: wrap; gap: .7rem; align-items: center; margin-bottom: 1rem; } /* legacy */
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { border: none; background: transparent; padding: .4em .7em; border-radius: 7px; font-size: .82rem;
  font-weight: 600; color: var(--ink-soft); }
.seg button.active { background: var(--ink); color: #fff; }
.seg .label { font-size: .7rem; color: var(--muted); font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; align-self: center; padding: 0 .5em 0 .3em; }

.template-picker { display: flex; flex-wrap: wrap; gap: .5rem; padding-bottom: .2rem; margin-bottom: 0; }
.tpl-card { flex: none; width: 92px; cursor: pointer; text-align: center; }
.tpl-thumb { width: 92px; height: 122px; border-radius: 8px; border: 2px solid var(--line);
  background: #fff; overflow: hidden; box-shadow: var(--shadow-sm); transition: border-color .15s, transform .1s; }
.tpl-card.active .tpl-thumb { border-color: var(--pine); }
.tpl-card:hover .tpl-thumb { transform: translateY(-2px); }
.tpl-card span { display: block; font-size: .74rem; margin-top: .35rem; color: var(--ink-soft); font-weight: 600; }
.tpl-thumb svg { width: 100%; height: 100%; display: block; }

.fit-badge { display: inline-flex; align-items: center; gap: .45em; font-size: .82rem; font-weight: 600;
  padding: .4em .75em; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); }
.fit-badge.ok { color: var(--ok); border-color: #BBD8CE; background: #EDF6F2; }
.fit-badge.warn { color: var(--brass); border-color: #E7D2A2; background: #FBF4E2; }
.fit-badge.tight { color: var(--danger); border-color: #EED2CF; background: var(--danger-bg); }
.fit-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

.preview-stage { background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; display: grid; place-items: start center;
  overflow-x: hidden; overflow-y: visible; flex: 1; min-height: 0; }

/* Contenedor de la hoja del CV (tamaño fijo por formato) */
.cv-page {
  background: #fff; box-shadow: 0 10px 40px rgba(22,35,63,.16); position: relative;
  overflow: hidden; transform-origin: top center;
}
.cv-page.fmt-a4     { width: 794px;  height: 1123px; }
.cv-page.fmt-carta  { width: 816px;  height: 1056px; }
.cv-page.fmt-oficio { width: 816px;  height: 1344px; }

.download-row { display: flex; flex-wrap: wrap; gap: .6rem; padding-top: .9rem; border-top: 1px solid var(--line); margin-top: 0; flex-shrink: 0; }

/* ============================================================
   ADMIN
   ============================================================ */
.admin { max-width: 1100px; margin: 0 auto; padding: 2rem 1.4rem 4rem; }
.admin h2 { font-family: var(--display); font-size: 1.7rem; font-weight: 600; margin-bottom: .2rem; }
.admin .lead { color: var(--muted); margin-bottom: 1.6rem; }
.stats { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.6rem; }
.stat { background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius);
  padding: .9rem 1.2rem; box-shadow: var(--shadow-sm); min-width: 130px; }
.stat .n { font-family: var(--display); font-size: 1.7rem; font-weight: 600; }
.stat .l { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }

.table-wrap { background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow-sm); }
table.users { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.users th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .6px;
  color: var(--muted); padding: .8rem 1rem; border-bottom: 1px solid var(--line); background: #FBFAF6; }
table.users td { padding: .75rem 1rem; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.users tr:last-child td { border-bottom: none; }
table.users tr:hover td { background: #FCFBF7; }
.badge { font-size: .72rem; font-weight: 700; padding: .18em .55em; border-radius: 999px; }
.badge.on { color: var(--ok); background: #EAF4EF; }
.badge.off { color: var(--danger); background: var(--danger-bg); }
.badge.pend { color: var(--brass); background: #FBF4E2; }
.actions-cell { display: flex; gap: .4rem; justify-content: flex-end; }
@media (max-width: 720px){ table.users .hide-sm { display: none; } }

/* ============================================================
   TOAST + utils
   ============================================================ */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: .7em 1.1em; border-radius: 10px; font-size: .88rem;
  font-weight: 500; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 100; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--danger); }
.toast.ok { background: var(--pine-dark); }

.err-text { color: var(--danger); font-size: .82rem; margin-top: .3rem; min-height: 1em; }
.ok-text { color: var(--ok); font-size: .82rem; margin-top: .3rem; min-height: 1em; }
.spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff;
  border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.center-load { display: grid; place-items: center; min-height: 60vh; color: var(--muted); }
.muted { color: var(--muted); }
.mt-1 { margin-top: .6rem; } .mt-2 { margin-top: 1.2rem; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.divider { height: 1px; background: var(--line); margin: 1.2rem 0; border: none; }

/* ============================================================
   CV MODAL (admin)
   ============================================================ */
.cv-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.cv-modal { background: var(--paper); border-radius: var(--radius); box-shadow: 0 20px 60px rgba(0,0,0,.3);
  width: min(860px, 100%); max-height: 90vh; display: flex; flex-direction: column; overflow: hidden; }
.cv-modal-header { display: flex; justify-content: space-between; align-items: center;
  padding: .9rem 1.2rem; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.cv-modal-close { background: none; border: none; font-size: 1.1rem; color: var(--muted);
  cursor: pointer; padding: .2em .4em; border-radius: 4px; }
.cv-modal-close:hover { background: var(--surface); color: var(--ink); }
.cv-modal-stage { background: var(--paper-2); padding: 24px; overflow-y: auto; overflow-x: hidden;
  flex: 1; min-height: 0; display: grid; place-items: start center; }

/* ============================================================
   TOPBAR BANNER
   ============================================================ */
.topbar-banner {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0 1rem;
  min-width: 0;
}
.topbar-banner[style*="display: none"] { display: none !important; }

.topbar-banner-text {
  font-size: .84rem;
  color: var(--ink-soft);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  transition: opacity .3s ease;
}
.topbar-banner-text strong { color: var(--ink); }
.topbar-banner-text a { color: var(--pine); font-weight: 600; }

.banner-fade-out { opacity: 0; }
.banner-fade-in  { animation: bannerFadeIn .4s ease; }
@keyframes bannerFadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Dark mode: topbar usa variable para que el backdrop sea correcto */
[data-theme="dark"] .topbar { background: rgba(21,27,39,.88); }
[data-theme="dark"] .auth-aside { background: #1c2436; }
[data-theme="dark"] .auth-card { background: var(--surface); }
[data-theme="dark"] input, [data-theme="dark"] textarea, [data-theme="dark"] select { background: var(--paper-2); color: var(--ink); border-color: var(--line); }
[data-theme="dark"] .tag-admin { background: #2e2510; border-color: #5a4010; }
[data-theme="dark"] .section-block { background: var(--surface); }
[data-theme="dark"] .repeat-item { background: var(--paper-2); }
[data-theme="dark"] .tpl-card .tpl-thumb { background: var(--surface); }
[data-theme="dark"] .preview-stage { background: var(--paper-2); }
[data-theme="dark"] .stat { background: var(--surface); }
[data-theme="dark"] .users td, [data-theme="dark"] .users th { border-color: var(--line); }
/* ============================================================
   MOBILE
   ============================================================ */

/* Evitar scroll horizontal en toda la app */
html, body { max-width: 100%; overflow-x: hidden; }

@media (max-width: 900px) {

  /* ---- Login: presentación primero, formulario tras el CTA ---- */
  .auth-wrap { display: flex; flex-direction: column; }
  .auth-aside { min-height: 100vh; justify-content: center; }

  /* Botón "Comenzar" arriba a la derecha */
  .mobile-cta {
    display: inline-flex; align-items: center; gap: .3rem;
    position: absolute; top: 1.4rem; right: 1.5rem; z-index: 5;
    background: var(--brass); color: #16233F;
    border: none; border-radius: 999px;
    padding: .62em 1.25em; font-size: .86rem; font-weight: 700;
    font-family: var(--sans); letter-spacing: .1px; cursor: pointer;
    box-shadow: 0 4px 16px rgba(181,138,60,.35);
    transition: transform .15s, box-shadow .15s;
  }
  .mobile-cta:active { transform: scale(.96); box-shadow: 0 2px 8px rgba(181,138,60,.3); }

  /* El formulario aparece recién al tocar "Comenzar" */
  .auth-main { display: none; padding: 2.2rem 1.5rem 3rem; }
  .auth-wrap.show-form .auth-main { display: grid; }

  .aside-content { gap: 1.2rem; height: auto; padding-top: 3.2rem; }
  .auth-hero h1 { font-size: 2.1rem; }
  .hero-kicker { font-size: .64rem; margin-bottom: .7rem; }

  .auth-steps { max-width: none; gap: .7rem; }
  .step-txt span { font-size: .76rem; }

  /* Slider: de fondo decorativo a bloque visible centrado */
  .auth-slider {
    position: static; transform: none; width: 100%;
    margin: .4rem 0 .2rem; opacity: 1; order: 99;
  }
  .slider-stack {
    width: min(230px, 62vw); margin: 0 auto;
    transform: rotate(2deg); animation: none;
  }
  .slider-stack::after {
    background: linear-gradient(180deg, rgba(22,35,63,.15) 0%, rgba(22,35,63,.05) 60%, transparent 100%);
  }

  .price-badge { align-self: stretch; max-width: none; }
  .price-row { flex-wrap: wrap; gap: .8rem; }

  .auth-card { max-width: 100%; }
}

@media (max-width: 1100px) {

  /* ---- Editor: formulario arriba, previsualización debajo ---- */
  .editor { display: flex; flex-direction: column; height: auto;
    min-width: 0; max-width: 100%; overflow-x: hidden; }

  .form-pane {
    position: static; height: auto; overflow: visible;
    border-right: none; border-bottom: 1px solid var(--line);
    padding: 0 1.1rem 2rem;
    min-width: 0; max-width: 100%;
  }

  .preview-pane {
    position: static; height: auto;
    padding: 1.5rem 0 3rem;
    min-width: 0; max-width: 100%; width: 100%;
  }
  /* Encabezado y botones sí respetan el margen lateral */
  .preview-pane > *:not(.preview-stage) { padding-left: 1.1rem; padding-right: 1.1rem; }

  /* La hoja usa todo el ancho de pantalla */
  .preview-stage {
    padding: 0; border-radius: 0;
    border-left: none; border-right: none;
    overflow: hidden;
    display: block;          /* no flex: el transform no achica la caja de layout */
    width: 100%; max-width: 100%; min-width: 0;
    flex: none;              /* que la altura la fije el JS, no el flex */
  }
  .cv-page { transform-origin: top left; }

  .download-row { justify-content: center; }
}

@media (max-width: 560px) {
  .form-pane  { padding: 0 .9rem 1.5rem; }
  .preview-pane { padding: 1.2rem 0 2.5rem; }
  .preview-pane > *:not(.preview-stage) { padding-left: .9rem; padding-right: .9rem; }
  .preview-stage { padding: 0; }

  /* Topbar en 3 filas: logo / banner / botones */
  .topbar {
    height: auto; flex-direction: column; align-items: stretch;
    gap: .55rem; padding: .7rem .9rem;
  }
  .topbar .brand { justify-content: center; }

  .topbar-banner {
    padding: 0; width: 100%;
    border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
    padding-top: .5rem; padding-bottom: .5rem;
  }
  .topbar-banner-text { font-size: .78rem; white-space: normal; text-align: center; }

  .topbar .nav {
    width: 100%; justify-content: center; flex-wrap: wrap; gap: .4rem;
  }
  .topbar .who { max-width: 100%; font-size: .76rem; text-align: center;
    flex-basis: 100%; margin-right: 0; }

  /* El editor arranca debajo del topbar variable */
  .form-pane, .preview-pane { top: auto; }

  .admin { padding: 1.5rem .9rem 3rem; }
  .form-controls-row { gap: .5rem; }
}
