:root {
  --rojo: #C41413;
  --rojo-osc: #8E0E0E;
  --amarillo: #F8B916;
  --ink: #1A1A1A;
  --ink-2: #3D3D3D;
  --ink-3: #6B7280;
  --line: #E5E7EB;
  --surface: #F5F6F8;
  --blanco: #fff;
  --ok: #16A34A;
  --ok-bg: #DCFCE7;
  --err: #DC2626;
  --err-bg: #FEE2E2;
  --radius: 10px;
  --sombra: 0 1px 3px rgba(0,0,0,.08);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--surface); color: var(--ink); font-size: 15px; line-height: 1.5;
}
a { color: var(--rojo); text-decoration: none; }
h1 { font-size: 1.5rem; margin: 0 0 4px; }
h2 { font-size: 1.1rem; margin: 0 0 12px; }

/* ── Topbar ───────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 0 16px; height: 56px;
  background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 50;
}
.brand { color: #fff; font-size: 1rem; white-space: nowrap; }
.brand strong { color: var(--amarillo); }
.brand-mm {
  display: inline-block; background: var(--rojo); color: #fff; font-weight: 800;
  border-radius: 50%; width: 32px; height: 32px; line-height: 32px; text-align: center;
  margin-right: 6px; font-size: .85rem; vertical-align: middle;
}
.nav { display: flex; gap: 4px; flex: 1; }
.nav a, .nav .nav-grupo > button {
  color: #d1d5db; padding: 6px 14px; border-radius: 8px; font-weight: 500;
  background: none; border: 0; font: inherit; cursor: pointer; white-space: nowrap;
}
.nav a.on, .nav a:hover, .nav .nav-grupo > button.on, .nav .nav-grupo > button:hover { background: rgba(255,255,255,.12); color: #fff; }
.nav-caret { font-size: .7em; opacity: .7; display: inline-block; transition: transform .18s ease; }
.nav-grupo { position: relative; }
/* Desplegable estilo web: panel blanco con sombra, se abre al pasar el ratón */
.nav-sub {
  position: absolute; top: 100%; left: 0; min-width: 210px; z-index: 60;
  background: var(--blanco); border: 1px solid var(--line); border-radius: 12px;
  padding: 8px; box-shadow: 0 12px 32px rgba(0,0,0,.18); margin-top: 8px;
  opacity: 0; visibility: hidden; transform: translateY(6px);
  transition: opacity .18s ease, transform .18s ease, visibility .18s;
}
.nav-sub::before { /* puente invisible para no perder el hover entre botón y panel */
  content: ""; position: absolute; left: 0; right: 0; top: -10px; height: 10px;
}
@media (hover: hover) {
  .nav-grupo:hover .nav-sub, .nav-grupo:focus-within .nav-sub { opacity: 1; visibility: visible; transform: translateY(0); }
  .nav-grupo:hover .nav-caret { transform: rotate(180deg); }
}
.nav-grupo.abierto .nav-sub { opacity: 1; visibility: visible; transform: translateY(0); }
.nav-grupo.abierto .nav-caret { transform: rotate(180deg); }
.nav-sub a {
  display: block; padding: 9px 14px; border-radius: 8px;
  color: var(--ink); font-weight: 500;
}
.nav-sub a:hover { background: var(--surface); color: var(--rojo); }
.nav-sub a.on { background: var(--surface); color: var(--rojo); font-weight: 600; }
.topbar-user { display: flex; align-items: center; gap: 10px; font-size: .85rem; color: #d1d5db; }

/* ── Layout ───────────────────────────── */
.wrap { max-width: 1100px; margin: 0 auto; padding: 20px 16px 90px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.muted { color: var(--ink-3); font-size: .85rem; }
.card { background: var(--blanco); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--sombra); padding: 18px; margin-bottom: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; align-items: start; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; align-items: start; }

/* ── Form ─────────────────────────────── */
label.f { display: block; margin-bottom: 10px; font-size: .82rem; font-weight: 600; color: var(--ink-2); }
label.f input, label.f select, label.f textarea {
  display: block; width: 100%; margin-top: 4px; padding: 9px 11px; font: inherit;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
}
label.f input:focus, label.f select:focus, label.f textarea:focus { outline: 2px solid var(--amarillo); border-color: var(--amarillo); }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: .85rem; margin: 8px 0; font-weight: 400; }
.check input { width: 18px; height: 18px; margin-top: 2px; flex: none; }

/* ── Botones ──────────────────────────── */
.btn {
  display: inline-block; border: 0; cursor: pointer; font: inherit; font-weight: 600;
  background: var(--rojo); color: #fff; padding: 9px 18px; border-radius: 8px; text-align: center;
}
.btn:hover { background: var(--rojo-osc); }
.btn-sec { background: var(--ink); }
.btn-sec:hover { background: #000; }
.btn-amarillo { background: var(--amarillo); color: var(--ink); }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: inherit; font-weight: 500; }
.btn-ghost:hover { background: rgba(0,0,0,.05); }
.topbar .btn-ghost { border-color: rgba(255,255,255,.3); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: .82rem; }
.btn-peligro { background: var(--err); }
.acciones { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Tablas ───────────────────────────── */
.tabla { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tabla th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-3); padding: 8px 10px; border-bottom: 2px solid var(--line); }
.tabla td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tabla tr:hover td { background: #FAFBFC; }
.tabla a.fila { color: inherit; display: block; }
.t-num { text-align: right; }

/* ── Badges / flash ───────────────────── */
.badge { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: .75rem; font-weight: 600; white-space: nowrap; }
.b-gris { background: #E5E7EB; color: #374151; }
.b-ambar { background: #FEF3C7; color: #92400E; }
.b-azul { background: #DBEAFE; color: #1E40AF; }
.b-verde { background: var(--ok-bg); color: #166534; }
.b-verde-osc { background: #166534; color: #fff; }
.b-rojo { background: var(--err-bg); color: #991B1B; }
.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-weight: 500; }
.flash-ok { background: var(--ok-bg); color: #166534; }
.flash-error { background: var(--err-bg); color: #991B1B; }
.flash-info { background: #EFF6FF; color: #1E40AF; }

/* ── Login ────────────────────────────── */
.login-page { min-height: 100vh; display: grid; place-items: center; background: var(--ink); padding: 20px; }
.login-card { background: #fff; border-radius: 14px; padding: 32px; width: 100%; max-width: 380px; }
.login-logo { text-align: center; margin-bottom: 20px; }
.login-logo .brand-mm { width: 56px; height: 56px; line-height: 56px; font-size: 1.4rem; margin: 0 0 8px; }

/* ── Dashboard ────────────────────────── */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi b { display: block; font-size: 1.6rem; color: var(--rojo); }
.kpi span { font-size: .8rem; color: var(--ink-3); }

/* ── Ficha cliente: tabs (por data-tab, no posicionales) ── */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { border: 0; background: none; font: inherit; font-weight: 600; padding: 8px 14px; cursor: pointer; color: var(--ink-3); border-bottom: 3px solid transparent; margin-bottom: -2px; }
.tabs button.on { color: var(--rojo); border-bottom-color: var(--rojo); }

/* ── Checklist ────────────────────────── */
.chk-seccion { margin-bottom: 14px; }
.chk-seccion h3 { font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; color: var(--rojo); margin: 0 0 8px; }
.chk-fila { display: grid; grid-template-columns: 150px auto 1fr; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.chk-fila .chk-item { font-weight: 600; font-size: .85rem; }
.chk-opts { display: flex; gap: 4px; }
.chk-opts label { display: flex; align-items: center; gap: 4px; font-size: .8rem; padding: 4px 10px; border: 1px solid var(--line); border-radius: 99px; cursor: pointer; user-select: none; }
.chk-opts input { margin: 0; }
.chk-opts label:has(input:checked) { background: var(--ink); color: #fff; border-color: var(--ink); }
.chk-fila input.obs { padding: 5px 9px; font-size: .82rem; border: 1px solid var(--line); border-radius: 6px; width: 100%; }

/* ── Fotos ────────────────────────────── */
.fotos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.foto-thumb { position: relative; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); aspect-ratio: 1; }
.foto-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.foto-thumb .foto-x { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,.6); color: #fff; border: 0; border-radius: 50%; width: 24px; height: 24px; cursor: pointer; line-height: 1; }
.foto-thumb .foto-fase { position: absolute; left: 0; bottom: 0; right: 0; background: rgba(0,0,0,.55); color: #fff; font-size: .65rem; padding: 2px 6px; }
.subir-foto { border: 2px dashed var(--line); border-radius: 8px; display: grid; place-items: center; aspect-ratio: 1; cursor: pointer; color: var(--ink-3); font-size: .8rem; text-align: center; padding: 6px; }
.subir-foto:hover { border-color: var(--amarillo); color: var(--ink); }

/* ── Firma ────────────────────────────── */
.firma-box { border: 2px dashed var(--ink-3); border-radius: 10px; background: #fff; touch-action: none; width: 100%; height: 220px; display: block; }
.firma-hecha img { max-width: 260px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.legal-scroll { max-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; font-size: .78rem; color: var(--ink-2); white-space: pre-wrap; background: #FAFBFC; }

/* ── Buscador clientes (orden nueva) ──── */
.buscador { position: relative; }
.buscador-res { position: absolute; top: 100%; left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: 0 0 10px 10px; box-shadow: var(--sombra); z-index: 20; max-height: 280px; overflow-y: auto; }
.buscador-res button { display: block; width: 100%; text-align: left; padding: 10px 14px; background: none; border: 0; border-bottom: 1px solid var(--line); cursor: pointer; font: inherit; }
.buscador-res button:hover { background: var(--surface); }
.cliente-sel { background: var(--ok-bg); border: 1px solid #86EFAC; border-radius: 8px; padding: 10px 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }

/* ── Móvil ────────────────────────────── */
@media (max-width: 760px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .hide-m { display: none; }
  .topbar { padding: 0 10px; gap: 8px; }
  .nav {
    position: fixed; bottom: 0; left: 0; right: 0; background: var(--ink);
    justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 50;
    overflow-x: auto; scrollbar-width: none;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav a, .nav .nav-grupo > button { font-size: .76rem; padding: 8px 7px; white-space: nowrap; }
  /* en móvil (sin hover) el panel abre al tocar, FIXED sobre la barra para escapar del overflow */
  .nav-sub {
    position: fixed; top: auto; left: 12px; right: 12px; bottom: calc(64px + env(safe-area-inset-bottom));
    margin: 0; transform: translateY(6px);
  }
  .nav-grupo.abierto .nav-sub { transform: translateY(0); }
  .nav-sub::before { display: none; }
  .chk-fila { grid-template-columns: 1fr; gap: 4px; }
  .wrap { padding-bottom: 110px; }
  .tabla { font-size: .82rem; }
  .tabla .hide-m { display: none; }
}

/* ── Editor visual (wysiwyg propio) ───── */
.wys { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-top: 4px; background: #fff; }
.wys-toolbar { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px; background: var(--surface); border-bottom: 1px solid var(--line); }
.wys-toolbar button {
  border: 1px solid transparent; background: none; font: inherit; font-size: .8rem; font-weight: 600;
  padding: 4px 9px; border-radius: 6px; cursor: pointer; color: var(--ink-2);
}
.wys-toolbar button:hover { background: #fff; border-color: var(--line); }
.wys-toolbar button.on { background: var(--ink); color: #fff; }
.wys-area { min-height: 220px; max-height: 480px; overflow-y: auto; padding: 12px 14px; outline: none; font-size: .92rem; }
.wys-area h2 { font-size: 1.15rem; margin: .8em 0 .3em; }
.wys-area h3 { font-size: 1rem; margin: .7em 0 .3em; }
.wys-area blockquote { border-left: 3px solid var(--amarillo); margin: .6em 0; padding: .2em .9em; color: var(--ink-2); }
.wys-area a { color: var(--rojo); text-decoration: underline; }
.wys textarea.wys-html { width: 100%; min-height: 220px; border: 0; padding: 12px 14px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .8rem; }

/* ── Formularios de contacto (leads) ──── */
.lead-filtros { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 99px;
  background: var(--blanco); border: 1px solid var(--line); color: var(--ink-2);
  font-size: .82rem; font-weight: 600; cursor: pointer; font-family: inherit;
}
.chip b { background: var(--surface); border-radius: 99px; padding: 0 8px; font-size: .75rem; }
.chip:hover { border-color: var(--ink-3); }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip.on b { background: rgba(255,255,255,.2); }
.chip-rojo.on { background: var(--rojo); border-color: var(--rojo); }
.chip-ambar.on { background: #B45309; border-color: #B45309; }
.chip-mini { padding: 3px 10px; font-size: .72rem; }
.lead-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
.lead-card {
  background: var(--blanco); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--sombra); padding: 16px; border-left: 4px solid var(--line);
  display: flex; flex-direction: column;
}
.lead-card.lead-nuevo { border-left-color: var(--rojo); }
.lead-card.lead-en_proceso { border-left-color: var(--amarillo); }
.lead-card.lead-cerrado { opacity: .75; }
.lead-card header { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.lead-avatar {
  width: 38px; height: 38px; border-radius: 50%; background: var(--ink); color: #fff;
  display: grid; place-items: center; font-weight: 700; flex: none;
}
.lead-msg { font-size: .88rem; margin: 4px 0 8px; }
.lead-cliente { font-size: .84rem; margin: 0 0 6px; }
.lead-extra summary { cursor: pointer; font-size: .8rem; color: var(--ink-3); }
.lead-card footer { display: flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 8px; border-top: 1px dashed var(--line); flex-wrap: wrap; }
.lead-estados { display: flex; gap: 4px; }

/* ── Gráficas (contenedor altura fija, evita overflow de canvas) ── */
.chart-box { position: relative; height: 260px; min-width: 0; }
.chart-box canvas { position: absolute; inset: 0; }

/* ── Facturación: alta tipo StelOrder ── */
.fact-grid { display: grid; grid-template-columns: 1.05fr .95fr; gap: 18px; align-items: start; }
.fact-cliente .cliente-sel { margin-bottom: 8px; }
.fact-estado { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.fact-doc { gap: 12px; }
.fact-lineas-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.fact-lineas th, .fact-lineas td { white-space: nowrap; }
.fact-lineas td:first-child, .fact-lineas th:first-child { white-space: normal; min-width: 200px; }
.fact-lineas input, .fact-lineas select { padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; font: inherit; background: #fff; }
.fact-lineas input:focus, .fact-lineas select:focus { outline: 2px solid var(--amarillo); border-color: var(--amarillo); }
.fact-lineas .linea-total { font-weight: 700; min-width: 90px; }
.fact-del .btn { color: var(--ink-3); font-size: 1.1rem; line-height: 1; padding: 4px 10px; }
.fact-del .btn:hover { color: var(--err); }

/* resultados del buscador de productos con miniatura */
.buscador-res .res-prod { display: flex; align-items: center; gap: 10px; }
.res-img { width: 38px; height: 38px; flex: none; border-radius: 6px; background: var(--surface); display: grid; place-items: center; overflow: hidden; font-size: 1.1rem; }
.res-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.res-txt { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.res-nombre { font-weight: 600; }
.res-stock { font-size: .78rem; color: var(--ink-3); }
.res-stock-alerta { color: var(--err); font-weight: 600; }

/* alta rápida de cliente desde el alta de factura */
.cliente-nuevo { border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin: 8px 0; background: #FAFBFC; }

/* edición rápida en el Almacén (PVP y stock desde el listado) */
.qe-input { width: 84px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; font: inherit; text-align: right; }
.qe-input:focus { outline: 2px solid var(--amarillo); border-color: var(--amarillo); }
.qe-wrap td[data-qe-cell] .qe-input { display: none; }
.qe-wrap.qe-on td[data-qe-cell] .qe-view { display: none; }
.qe-wrap.qe-on td[data-qe-cell] .qe-input { display: inline-block; }
.qe-wrap.qe-on tr:hover td { background: #FFFDF5; }
.qe-input.qe-dirty { border-color: var(--amarillo); background: #FFFBEB; }
.qe-wrap.qe-on tr.qe-row-dirty td { background: #FFF7DB; }
.qe-saveall[disabled] { opacity: .45; cursor: default; }
.qe-saveall:not([disabled]) { background: var(--ok); }
.qe-saveall:not([disabled]):hover { background: #15803D; }

.barra-totales {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; align-items: center; gap: 22px;
  background: var(--ink); color: #fff;
  padding: 9px 18px calc(9px + env(safe-area-inset-bottom));
  box-shadow: 0 -2px 14px rgba(0,0,0,.2);
}
.barra-totales .bt-item { display: flex; flex-direction: column; line-height: 1.15; }
.barra-totales .bt-item span { font-size: .68rem; color: #9ca3af; text-transform: uppercase; letter-spacing: .04em; }
.barra-totales .bt-item strong { font-size: 1rem; }
.barra-totales .bt-total strong { font-size: 1.3rem; color: var(--amarillo); }
.barra-totales .bt-acc { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.barra-totales .btn-ghost { border-color: rgba(255,255,255,.3); color: #fff; }
.barra-totales .btn-ghost:hover { background: rgba(255,255,255,.12); }

@media (max-width: 760px) {
  .fact-grid { grid-template-columns: 1fr; gap: 12px; }
  /* en móvil la barra deja de ser fija (la nav inferior ocupa el bottom): fluye al final del form */
  .barra-totales {
    position: static; border-radius: var(--radius); margin: 4px 0 8px;
    flex-wrap: wrap; gap: 14px; padding: 12px 14px;
  }
  .barra-totales .bt-acc { width: 100%; margin-left: 0; }
  .barra-totales .bt-acc .btn { flex: 1; }
}

/* ── Print (resguardo) ────────────────── */
@media print {
  .topbar, .nav, .no-print, .flash { display: none !important; }
  body { background: #fff; font-size: 11px; }
  .wrap { max-width: none; padding: 0; }
  .card { border: 0; box-shadow: none; padding: 0; margin-bottom: 10px; }
  .legal-scroll { max-height: none; overflow: visible; border: 0; padding: 0; font-size: 8.5px; }
  a { color: inherit; }
}

/* ── Tablas anchas: scroll horizontal en móvil ── */
.tabla-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.qe-wrap    { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 760px) {
  .tabla-wrap .tabla { min-width: 480px; }
  .qe-wrap    .tabla { min-width: 600px; }
}

/* === P7.4 estudios (luz + telefonía) — portado del mockup energia-estudios-v2 === */
.flujo { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.flujo .sep { color: var(--ink-3); font-size: .8rem; }

.tipo-sel { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.tipo-sel button { border: 2px solid var(--line); background: #fff; border-radius: var(--radius); padding: 16px; font: inherit; cursor: pointer; text-align: left; transition: border-color .2s, box-shadow .2s, transform .25s cubic-bezier(.34,1.56,.64,1); }
.tipo-sel button:hover { transform: translateY(-2px); box-shadow: var(--sombra); }
.tipo-sel button.on { border-color: var(--rojo); box-shadow: 0 0 0 3px rgba(196,20,19,.12); }
.tipo-sel .t-ico { font-size: 1.5rem; display: block; margin-bottom: 4px; }
.tipo-sel b { display: block; }
.tipo-sel small { color: var(--ink-3); }

/* los bloques luz/telefonía del editor son fieldsets (disabled = no viajan en el POST) */
fieldset[data-bloque-estudio] { border: 0; padding: 0; margin: 0; min-width: 0; }

.dropzone { display: block; border: 2px dashed var(--ink-3); border-radius: var(--radius); background: #fff; padding: 34px 20px; text-align: center; color: var(--ink-3); cursor: pointer; transition: border-color .2s, background .2s; }
.dropzone:hover, .dropzone.dz-hover, .dropzone:focus-visible { border-color: var(--amarillo); background: #FFFDF5; }
.dropzone.dz-lleno { border-color: var(--ok); background: #F0FDF4; }
.dropzone .dz-ico { font-size: 2rem; display: block; margin-bottom: 6px; }
.dropzone b { color: var(--ink); }
.dropzone .dz-nombre { display: block; margin-top: 6px; }

.nota-ia { display: flex; gap: 10px; align-items: flex-start; background: #EFF6FF; border: 1px solid #BFDBFE; border-radius: 8px; padding: 10px 14px; font-size: .82rem; color: #1E40AF; margin-top: 12px; }
.nota-ia .ico { font-size: 1.1rem; }

.tarifa-input { width: 84px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; font: inherit; font-size: .85rem; text-align: right; background: #fff; }
.tarifa-input:focus { outline: 2px solid var(--amarillo); border-color: var(--amarillo); }

/* selector de formato de propuesta (corazón del módulo) */
.formato-sel { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 4px 0 18px; }
.formato-card { position: relative; border: 2px solid var(--line); border-radius: var(--radius); background: #fff; padding: 18px; cursor: pointer; text-align: left; font: inherit; color: inherit; transition: border-color .22s, box-shadow .22s, transform .3s cubic-bezier(.34,1.56,.64,1); }
.formato-card:hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(0,0,0,.08); }
.formato-card.on { border-color: var(--rojo); box-shadow: 0 0 0 3px rgba(196,20,19,.12), 0 6px 20px rgba(0,0,0,.06); }
.formato-card.on::after { content: '✓ ELEGIDO'; position: absolute; top: -11px; right: 14px; background: var(--rojo); color: #fff; font-size: .68rem; font-weight: 700; letter-spacing: .06em; padding: 3px 10px; border-radius: 99px; animation: fmt-pop .4s cubic-bezier(.34,1.56,.64,1) both; }
@keyframes fmt-pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.formato-card .fc-ico { font-size: 1.6rem; }
.formato-card h3 { margin: 6px 0 4px; font-size: 1rem; }
.formato-card p { margin: 0 0 10px; font-size: .84rem; color: var(--ink-2); }
.formato-card ul { margin: 0; padding-left: 18px; font-size: .8rem; color: var(--ink-3); }
.formato-card li { margin: 2px 0; }
.fc-cuando { display: inline-block; margin-top: 10px; font-size: .74rem; font-weight: 700; padding: 4px 10px; border-radius: 99px; }
.fc-valor .fc-cuando { background: #DBEAFE; color: #1E40AF; }
.fc-ahorro .fc-cuando { background: var(--ok-bg); color: #166534; }

/* previsualizaciones A4 (los estilos internos del A4 los emite crm_estudio_estilos_a4) */
.a4-zona { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.a4-label { text-align: center; font-weight: 700; font-size: .85rem; margin-bottom: 10px; }
.a4-label .badge { margin-left: 6px; }
.prev-a4 { transition: opacity .35s ease; }
.prev-a4.prev-off { opacity: .45; }

/* manual de contratación */
.manual-plataforma { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; overflow: hidden; background: #fff; }
.manual-plataforma summary { cursor: pointer; padding: 13px 16px; font-weight: 700; background: #FAFBFC; display: flex; align-items: center; gap: 10px; list-style: none; }
.manual-plataforma summary::-webkit-details-marker { display: none; }
.manual-plataforma summary .caret { margin-left: auto; transition: transform .25s ease; font-size: .8rem; color: var(--ink-3); }
.manual-plataforma[open] summary .caret { transform: rotate(180deg); }
.manual-pasos { padding: 6px 16px 14px; }
.paso { display: flex; gap: 12px; align-items: flex-start; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.paso:last-child { border-bottom: 0; }
.paso input { width: 19px; height: 19px; margin-top: 2px; flex: none; accent-color: var(--ok); cursor: pointer; }
.paso .p-num { flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--ink); color: #fff; font-size: .74rem; font-weight: 700; display: grid; place-items: center; margin-top: 1px; }
.paso label { cursor: pointer; font-size: .88rem; }
.paso label small { display: block; color: var(--ink-3); }
.paso:has(input:checked) label { text-decoration: line-through; color: var(--ink-3); }
.manual-progreso { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 4px 16px 12px; }
.manual-progreso div { height: 100%; width: 0; background: var(--ok); border-radius: 99px; transition: width .45s ease; }
.placeholder-nota { border: 1.5px dashed var(--ink-3); border-radius: 8px; background: #FAFBFC; padding: 10px 14px; font-size: .82rem; color: var(--ink-2); margin-bottom: 14px; }

@media (max-width: 760px) {
  .tipo-sel, .formato-sel, .a4-zona { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .tipo-sel button, .formato-card, .formato-card.on::after, .prev-a4, .manual-progreso div { animation: none !important; transition: none !important; }
}

/* chatbot (P9.3): transcripción en burbujas + KB */
.chat-log { display: flex; flex-direction: column; gap: 10px; max-height: 68vh; overflow-y: auto; padding: 4px 6px; }
.chat-msg { max-width: 74%; padding: 10px 14px; border-radius: 14px; font-size: .9rem; overflow-wrap: break-word; }
.chat-user { align-self: flex-end; background: var(--ink); color: #fff; border-bottom-right-radius: 4px; }
.chat-user .chat-meta { color: rgba(255,255,255,.65); }
.chat-bot { align-self: flex-start; background: #F1F3F5; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.chat-bot.chat-mal { background: #FEF2F2; border-color: #FCA5A5; }
.chat-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 6px; font-size: .72rem; color: var(--ink-3); }
.chat-nota { margin-top: 6px; }
.chat-nota summary { cursor: pointer; list-style: none; font-size: .75rem; font-weight: 600; color: var(--rojo); }
.chat-nota summary::-webkit-details-marker { display: none; }
.chat-nota[open] summary { margin-bottom: 6px; }
.chat-nota textarea { width: 100%; font: inherit; font-size: .85rem; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; }
.kb-detalle { margin-top: 4px; }
.kb-detalle summary { cursor: pointer; list-style: none; font-size: .78rem; color: var(--ink-3); font-weight: 600; }
.kb-detalle summary::-webkit-details-marker { display: none; }
.kb-detalle[open] { border: 1px dashed var(--line); border-radius: 8px; padding: 10px; margin-top: 6px; background: #FAFBFC; }
.kb-detalle .f { display: block; margin-bottom: 8px; }
.kb-detalle textarea, .kb-detalle input[type="text"] { width: 100%; font: inherit; font-size: .85rem; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
@media (max-width: 760px) {
  .chat-msg { max-width: 92%; }
}

/* === P11.3 etiquetas + escáner === */
.etq-res { border: 1px solid var(--line); border-radius: 10px; max-height: 300px; overflow-y: auto; margin-top: 4px; }
.etq-op { display: block; width: 100%; text-align: left; padding: 10px 14px; background: none; border: 0; border-bottom: 1px solid var(--line); cursor: pointer; font: inherit; font-size: .9rem; }
.etq-op:last-child { border-bottom: 0; }
.etq-op:hover { background: var(--surface); }
.seg { display: inline-flex; gap: 2px; background: #F1F3F5; border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg label { display: inline-flex; align-items: center; gap: 5px; padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: .88rem; font-weight: 600; color: var(--ink-3); }
.seg label:has(input:checked) { background: #fff; color: var(--ink); box-shadow: var(--sombra); }
.seg input { accent-color: var(--rojo); }

/* ── P11.4 · TPV de mostrador ── */
.tpv-grid { display: grid; grid-template-columns: 1fr 340px; gap: 16px; align-items: start; }
.tpv-lineas-wrap { overflow-x: auto; }
.tpv-lineas { width: 100%; }
.tpv-lineas td, .tpv-lineas th { padding: 6px 8px; }
.tpv-total-box { display: flex; flex-direction: column; gap: 2px; text-align: center; padding: 6px 0 2px; }
.tpv-total-box strong { font-size: 2.1rem; color: var(--rojo); line-height: 1.1; font-variant-numeric: tabular-nums; }
.tpv-cambio { margin-top: 8px; font-size: 1rem; }
.tpv-cambio strong { font-size: 1.2rem; color: var(--ok); }
.tpv-caja-kpis { display: flex; gap: 16px; margin-bottom: 8px; }
.tpv-caja-kpis > div { display: flex; flex-direction: column; line-height: 1.2; }
.tpv-caja-kpis span { font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; }
.tpv-caja-kpis strong { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.tpv-cierre summary { display: inline-block; list-style: none; }
.tpv-cierre summary::-webkit-details-marker { display: none; }
@media (max-width: 860px) {
  .tpv-grid { grid-template-columns: 1fr; }
}

/* ── P11.5 Agenda del taller ─────────────────────────── */
.agenda-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.nav-fecha { display: inline-flex; align-items: center; gap: 4px; }
.nav-fecha a, .nav-fecha button { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font-size: 1rem; cursor: pointer; color: var(--ink-2); display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.nav-fecha a:hover, .nav-fecha button:hover { background: var(--surface); }
.nav-fecha .hoy { width: auto; padding: 0 14px; font-weight: 600; font-size: .85rem; }
.agenda-rango { font-weight: 700; font-size: 1.05rem; text-transform: capitalize; }
.agenda-leyenda { display: flex; gap: 14px; flex-wrap: wrap; font-size: .78rem; color: var(--ink-3); margin-bottom: 10px; }
.agenda-leyenda span { display: inline-flex; align-items: center; gap: 5px; }
.agenda-leyenda i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.agenda-layout { display: grid; grid-template-columns: 1fr 320px; gap: 16px; align-items: start; }
.grid-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--sombra); }
.semana { display: grid; grid-template-columns: 56px repeat(var(--dias, 5), minmax(140px, 1fr)); min-width: 640px; position: relative; }
.dh { position: sticky; top: 56px; z-index: 6; background: #fff; border-bottom: 2px solid var(--line); padding: 8px 6px; text-align: center; }
.dh .dia { font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.dh .num { font-size: 1.35rem; font-weight: 800; line-height: 1; margin-top: 2px; }
.dh.hoy .num, .dh.hoy .dia { color: var(--rojo); }
.dh .carga { font-size: .68rem; color: var(--ink-3); margin-top: 3px; }
.dh.festivo { background: repeating-linear-gradient(45deg, #FEF2F2, #FEF2F2 6px, #fff 6px, #fff 12px); }
.hcol { border-right: 1px solid var(--line); }
.hlabel { font-size: .7rem; color: var(--ink-3); text-align: right; padding: 2px 6px 0 0; position: relative; }
.dcol { border-right: 1px solid var(--line); position: relative; }
.dcol:last-child { border-right: 0; }
.aslot { border-bottom: 1px solid #F1F3F5; position: relative; }
.aslot.libre { cursor: pointer; }
.aslot.libre:hover { background: #F0FDF4; }
.aslot.libre:hover::after { content: "+ Cita"; position: absolute; inset: 0; display: grid; place-items: center; font-size: .72rem; font-weight: 700; color: var(--ok); }
.aslot.cerrado { background: repeating-linear-gradient(45deg, #FAFBFC, #FAFBFC 5px, #F1F3F5 5px, #F1F3F5 10px); }
.cita { position: absolute; left: 3px; right: 3px; border-radius: 7px; padding: 5px 7px; font-size: .74rem; overflow: hidden; color: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.18); border-left: 3px solid rgba(0,0,0,.25); text-decoration: none; display: block; }
.cita:hover { box-shadow: 0 4px 12px rgba(0,0,0,.25); z-index: 4; }
.cita.sel { outline: 3px solid var(--amarillo); outline-offset: 1px; z-index: 5; }
.cita .c-hora { font-weight: 700; opacity: .95; color: #fff; }
.cita .c-cli { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cita .c-svc { opacity: .92; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cita .c-tag { position: absolute; top: 4px; right: 5px; font-size: .62rem; background: rgba(255,255,255,.28); padding: 0 5px; border-radius: 99px; }
.cita.est-confirmada { background: #2563EB; }
.cita.est-en_taller { background: #7C3AED; }
.cita.est-hecha { background: #0891B2; }
.cita.est-provisional { background: #B45309; background-image: repeating-linear-gradient(45deg, rgba(255,255,255,.14), rgba(255,255,255,.14) 6px, transparent 6px, transparent 12px); border-left-color: var(--amarillo); }
.cita.est-cancelada, .cita.est-no_show { background: #9CA3AF; text-decoration: line-through; opacity: .7; }
.agenda-panel { position: sticky; top: 72px; }
.agenda-dl { display: grid; grid-template-columns: 92px 1fr; gap: 6px 10px; font-size: .86rem; margin: 12px 0; }
.agenda-dl dt { color: var(--ink-3); }
.agenda-dl dd { margin: 0; font-weight: 600; }
.hint { display: flex; gap: 8px; align-items: flex-start; background: #EFF6FF; border: 1px solid #BFDBFE; border-radius: 8px; padding: 10px 12px; font-size: .8rem; color: #1E40AF; }
@media (max-width: 1080px) { .agenda-layout { grid-template-columns: 1fr; } }
