/* CloseOnSite — design system
   Azul confianza + CTA naranja, DM Sans, mobile-first.
   Reglas: touch targets >=44px, contraste AA, transiciones 150-250ms. */

:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #475569;
  --line: #e2e8f0;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff4ff;
  --cta: #f97316;
  --cta-dark: #ea580c;
  --success: #16a34a;
  --success-soft: #ecfdf3;
  --danger: #b91c1c;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-card: 0 1px 2px rgb(15 23 42 / 0.04), 0 4px 16px rgb(15 23 42 / 0.06);
  --shadow-pop: 0 4px 8px rgb(15 23 42 / 0.06), 0 12px 32px rgb(15 23 42 / 0.12);
  --font: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--ink);
}

/* ---------- Header ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: rgb(255 255 255 / 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 0.7rem 1rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: -0.01em;
}
.brand svg { flex: none; }
.topnav { display: flex; gap: 0.25rem; align-items: center; }
.topnav a, .linkbtn {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 0.8rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.topnav a:hover, .linkbtn:hover { background: var(--primary-soft); color: var(--primary); }

main {
  max-width: 660px;
  margin: 0 auto;
  padding: 1rem 1rem 3rem;
  display: grid;
  gap: 1rem;
}

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-card);
}

h1 { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 0.9rem; }
h2 { font-size: 1.08rem; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 0.7rem; }

.eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--primary);
  margin: 0 0 0.35rem;
}

.stack { display: grid; gap: 0.9rem; }
label { display: grid; gap: 0.35rem; font-size: 0.92rem; font-weight: 500; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input:not([type]), select, textarea {
  font: inherit;
  min-height: 46px;
  padding: 0.6rem 0.8rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fbfcfe;
  color: var(--ink);
  transition: border-color 0.2s, box-shadow 0.2s;
}
textarea { min-height: 0; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgb(37 99 235 / 0.15);
}
:is(a, button, input, select, textarea, summary):focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ---------- Buttons ---------- */
button, .btnlink {
  font: inherit;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 48px;
  padding: 0.7rem 1.2rem;
  border: 0;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 1px 2px rgb(15 23 42 / 0.12), inset 0 1px 0 rgb(255 255 255 / 0.12);
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
}
button:hover, .btnlink:hover { background: var(--primary-dark); }
button:active, .btnlink:active { transform: translateY(1px); }
button:disabled { opacity: 0.6; cursor: default; }

button.cta, .btnlink.cta { background: var(--cta); }
button.cta:hover, .btnlink.cta:hover { background: var(--cta-dark); }

button.secondary, .btnlink.secondary {
  background: #fff;
  color: var(--ink);
  border: 1.5px solid var(--line);
  box-shadow: none;
}
button.secondary:hover, .btnlink.secondary:hover { background: var(--bg); border-color: #cbd5e1; }

.btnlink.small { min-height: 40px; font-size: 0.85rem; padding: 0.4rem 0.7rem; margin-top: 0.35rem; width: 100%; }

.btn-block { width: 100%; }

/* ---------- Chips / presets ---------- */
fieldset {
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0.8rem;
  margin: 0;
}
legend { font-size: 0.82rem; font-weight: 600; color: var(--muted); padding: 0 0.35rem; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 44px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 0.45rem 0.95rem;
  font-size: 0.9rem;
  font-weight: 500;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}
.chip:hover { border-color: var(--primary); }
.chip:has(input:checked) {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgb(37 99 235 / 0.35);
}
.chip input { accent-color: currentColor; margin: 0; }

/* ---------- Upload ---------- */
.filebtn {
  display: grid;
  gap: 0.4rem;
  justify-items: center;
  border: 2px dashed #b6c3da;
  border-radius: var(--radius);
  padding: 1.5rem 1.2rem;
  text-align: center;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-soft);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.filebtn:hover { border-color: var(--primary); background: #e6eeff; }
.filebtn .hint { font-size: 0.8rem; font-weight: 400; color: var(--muted); }
.filebtn input { width: 100%; font-size: 0.85rem; }

/* ---------- Listas ---------- */
.projects { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.projects a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  min-height: 52px;
  padding: 0.7rem 0.9rem;
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--ink);
  font-weight: 600;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.projects a:hover { border-color: var(--primary); box-shadow: var(--shadow-card); background: #fff; }
.projects .meta { display: flex; align-items: center; gap: 0.5rem; }
.projects svg.chev { flex: none; color: #94a3b8; }

.tag {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
  white-space: nowrap;
}
.tag.ok { background: var(--success-soft); color: var(--success); }
.tag.warn { background: #fff7ed; color: var(--cta-dark); }

/* ---------- Stats ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  text-align: center;
  padding: 1rem 0.75rem;
}
.stats > div { display: grid; gap: 0.1rem; padding: 0.3rem 0.2rem; border-radius: var(--radius-sm); }
.stats strong { font-size: 1.45rem; font-weight: 800; letter-spacing: -0.02em; color: var(--ink); }
.stats > div:first-child strong { color: var(--primary); }
.stats > div:nth-child(2) strong { color: var(--success); }
.stats > div:nth-child(3) strong { color: var(--cta); }
.stats span { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }

/* ---------- Variantes / imágenes ---------- */
.variants {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.7rem;
  margin: 0.7rem 0;
}
.variants figure { margin: 0; }
.variants img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  display: block;
  transition: transform 0.2s, box-shadow 0.2s;
}
.variants a:hover img { box-shadow: var(--shadow-pop); }
figcaption { font-size: 0.78rem; font-weight: 600; color: var(--muted); text-align: center; margin-top: 0.3rem; }

/* ---------- Comparador antes/después ---------- */
.ba {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-card);
  user-select: none;
}
.ba img { width: 100%; display: block; aspect-ratio: 4 / 3; object-fit: cover; }
.ba .after { position: absolute; inset: 0; clip-path: inset(0 0 0 var(--cut, 50%)); }
.ba .after img { position: absolute; inset: 0; height: 100%; }
.ba .handle {
  position: absolute;
  top: 0; bottom: 0;
  left: var(--cut, 50%);
  width: 3px;
  background: #fff;
  box-shadow: 0 0 8px rgb(15 23 42 / 0.45);
  pointer-events: none;
}
.ba .handle::after {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  width: 40px; height: 40px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #fff url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%232563eb' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><path d='m9 6-6 6 6 6'/><path d='m15 6 6 6-6 6'/></svg>") center / 20px no-repeat;
  box-shadow: 0 2px 10px rgb(15 23 42 / 0.35);
}
.ba input[type="range"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: ew-resize;
  touch-action: none;
}
.ba .balabel {
  position: absolute;
  top: 0.6rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #fff;
  background: rgb(15 23 42 / 0.62);
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  pointer-events: none;
}
.ba .balabel.before { left: 0.6rem; }
.ba .balabel.afterl { right: 0.6rem; }

/* ---------- Precio / propuesta ---------- */
.pricebig {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ink);
  margin: 0.5rem 0 0.2rem;
}
.pricebox {
  background: var(--primary-soft);
  border: 1px solid #d6e2ff;
  border-radius: var(--radius-sm);
  padding: 0.9rem 1.1rem;
  margin: 0.8rem 0;
}
.pricebox .pricelabel { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--primary); }

.scope { margin: 0.4rem 0 0; padding: 0; list-style: none; display: grid; gap: 0.45rem; }
.scope li { display: flex; gap: 0.55rem; align-items: start; }
.scope svg { flex: none; margin-top: 0.18rem; color: var(--success); }

.muted { color: var(--muted); font-size: 0.88rem; }
.error {
  color: var(--danger);
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
  font-size: 0.9rem;
}

.pricerow { display: flex; gap: 0.5rem; align-items: end; flex-wrap: wrap; margin: 0.4rem 0; }
.pricerow .pricename { flex: 1 1 100%; font-size: 0.9rem; font-weight: 600; }
.pricerow input[type="number"] { width: 7rem; }
.pricerow button { min-height: 46px; padding: 0.5rem 0.8rem; }

/* ---------- Firma ---------- */
.sigwrap {
  border: 2px dashed #b6c3da;
  border-radius: var(--radius-sm);
  background: #fbfcfe;
  position: relative;
}
#sig { width: 100%; height: 190px; display: block; touch-action: none; border-radius: var(--radius-sm); }
.sigwrap .sighint {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  color: #94a3b8;
  font-size: 0.9rem;
  pointer-events: none;
}

/* ---------- Tablas / admin ---------- */
.admintable { border-collapse: collapse; width: 100%; font-size: 0.85rem; }
.admintable th, .admintable td { border-bottom: 1px solid var(--line); padding: 0.45rem 0.55rem; text-align: left; }
.admintable th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }

/* ---------- Spinner ---------- */
.spinner {
  display: inline-block;
  width: 1em;
  height: 1em;
  border: 2.5px solid var(--line);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: -0.15em;
}
@keyframes spin { to { transform: rotate(360deg); } }

.renderwait {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.4rem 0;
}

details summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; }

/* ---------- Auth (login/register) ---------- */
.authwrap { display: grid; gap: 1rem; margin-top: 4vh; }
.authhero { text-align: center; display: grid; gap: 0.3rem; justify-items: center; }
.authhero .logo { margin-bottom: 0.4rem; }
.authhero h1 { margin: 0; font-size: 1.5rem; }
.authhero p { margin: 0; color: var(--muted); font-size: 0.95rem; max-width: 34ch; }

@media (max-width: 420px) {
  .stats { grid-template-columns: repeat(2, 1fr); row-gap: 0.9rem; }
  .variants { grid-template-columns: repeat(2, 1fr); }
}

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