/* Panel VAG — approved mockup F1.b (light + dark). Tokens first; components read only tokens. */
:root {
  --bg: #f7f6f3; --side: #efede8; --surface: #ffffff; --surface2: #f1eee8; --line: #e2ddd4; --line2: #c9c3b8;
  --text: #1c1b19; --text2: #3b3935; --muted: #67635c; --accent: #1558b0; --accentHover: #0f4488; --accentSoft: #e8eff9; --accentText: #ffffff;
  --bot: #1d7550; --botSoft: #e4f2ea; --wait: #945600; --waitSoft: #fcf0da; --hot: #b42318; --hotSoft: #fde8e6;
  --money: #8a4519; --moneySoft: #f7ebe1; --shadow: 0 12px 32px rgba(0,0,0,.14);
  --font: 'Atkinson Hyperlegible Next', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --serif: 'Newsreader', Georgia, serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #111316; --side: #16191d; --surface: #1b1f24; --surface2: #232830; --line: #2d333b; --line2: #46505b;
  --text: #e8eef2; --text2: #c9d2da; --muted: #9aa7b3; --accent: #6ea8ff; --accentHover: #9cc3ff; --accentSoft: #172538; --accentText: #0b1220;
  --bot: #3ddc97; --botSoft: #132b23; --wait: #e8a317; --waitSoft: #2e2410; --hot: #ff6b5e; --hotSoft: #361816;
  --money: #d99b6c; --moneySoft: #2f2219; --shadow: 0 12px 32px rgba(0,0,0,.5);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111316; --side: #16191d; --surface: #1b1f24; --surface2: #232830; --line: #2d333b; --line2: #46505b;
    --text: #e8eef2; --text2: #c9d2da; --muted: #9aa7b3; --accent: #6ea8ff; --accentHover: #9cc3ff; --accentSoft: #172538; --accentText: #0b1220;
    --bot: #3ddc97; --botSoft: #132b23; --wait: #e8a317; --waitSoft: #2e2410; --hot: #ff6b5e; --hotSoft: #361816;
    --money: #d99b6c; --moneySoft: #2f2219; --shadow: 0 12px 32px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
a { color: var(--accent); } a:hover { color: var(--accentHover); }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ico { flex-shrink: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); } .t-hot { color: var(--hot); } .t-wait { color: var(--wait); } .t-bot { color: var(--bot); } .t-money { color: var(--money); }
.row { display: flex; align-items: center; gap: 8px; } .row.end { justify-content: flex-end; } .grow { flex: 1 1 auto; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.serif { font-family: var(--serif); font-weight: 400; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); font-weight: 600; white-space: nowrap; }
.btn:hover { background: var(--surface2); color: var(--text); }
a.btn { text-decoration: none; }
.btn.primary { background: var(--accent); color: var(--accentText); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn.danger { background: var(--hot); color: #fff; border-color: transparent; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text2); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn[disabled] { opacity: .55; cursor: default; }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; position: relative; }
.icon-btn.plain { border-color: transparent; background: transparent; }
.icon-btn:hover { background: var(--surface2); }
.badge { position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--hot); color: #fff;
  font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.pill { min-width: 22px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--hot); color: #fff; font-size: 12px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; }
.chip { height: 20px; padding: 0 7px; border-radius: 6px; font-size: 11px; font-weight: 700; letter-spacing: .3px; display: inline-flex; align-items: center; white-space: nowrap; }
.chip.bot { background: var(--botSoft); color: var(--bot); } .chip.tu { background: var(--accentSoft); color: var(--accent); }
.chip.espera { background: var(--hotSoft); color: var(--hot); } .chip.gris { background: var(--surface2); color: var(--muted); }
.chip.wait { background: var(--waitSoft); color: var(--wait); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.dot.verde { background: var(--bot); } .dot.amarillo { background: var(--wait); } .dot.rojo { background: var(--hot); } .dot.gris { background: var(--line2); }
.avatar { width: 38px; height: 38px; flex-shrink: 0; border-radius: 50%; background: var(--surface2); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; color: var(--text2); }
.card { border: 1px solid var(--line); background: var(--surface); border-radius: 14px; padding: 16px; }
.input { height: 40px; width: 100%; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); outline: none; }
.input:focus { border-color: var(--accent); }
textarea.input { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.45; }
label.lbl { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text2); }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.skel { background: linear-gradient(90deg, var(--surface2), var(--line), var(--surface2)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 8px; }
@keyframes sk { to { background-position: -200% 0; } }
.spin { width: 16px; height: 16px; border: 2px solid var(--line2); border-top-color: var(--accent); border-radius: 50%; animation: sp .8s linear infinite; display: inline-block; }
@keyframes sp { to { transform: rotate(360deg); } }

/* ── shell ───────────────────────────────────────────────────────────── */
#app { height: 100%; display: flex; overflow: hidden; }
.side { width: 264px; flex-shrink: 0; display: flex; flex-direction: column; gap: 4px; padding: 14px 12px; background: var(--side);
  border-right: 1px solid var(--line); overflow-y: auto; }
/* Colapsada = sólo en COMPUTADORA. En el teléfono la barra es un cajón que se abre completo siempre: la preferencia
   «colapsada» se guarda por navegador y, si venía de antes, dejaba el cajón con puros íconos y sin chats recientes (24-09). */
@media (min-width: 901px) {
  .side.collapsed { width: 64px; padding: 14px 10px; }
  .side.collapsed .lbl-txt, .side.collapsed .side-sec, .side.collapsed .reciente, .side.collapsed .side-foot .who, .side.collapsed .botstate span:not(.dot),
  .side.collapsed .brand-name, .side.collapsed .pill { display: none; }
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 12px; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--accentText); display: flex; align-items: center;
  justify-content: center; font-weight: 700; font-size: 12px; letter-spacing: .5px; flex-shrink: 0; }
.brand-name { flex: 1; font-family: var(--serif); font-size: 21px; font-weight: 500; }
.nav-new { display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 600; margin-bottom: 8px; text-decoration: none; color: var(--text); }
.nav-new:hover { background: var(--surface2); color: var(--text); }
.nav { display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 12px; border: none; border-radius: 10px; background: transparent;
  color: var(--text2); text-decoration: none; font-size: 14px; }
.nav:hover { background: var(--surface2); color: var(--text); }
.nav.on { background: var(--surface2); color: var(--text); font-weight: 700; }
.side-sec { margin: 18px 12px 6px; font-size: 12px; font-weight: 600; color: var(--muted); display: flex; align-items: center; }
.reciente { height: 32px; padding: 0 12px; border-radius: 8px; color: var(--text2); font-size: 13.5px; text-decoration: none; display: flex; align-items: center; }
.reciente:hover, .reciente.on { background: var(--surface2); color: var(--text); }
.reciente span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.botstate { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 10px; background: var(--botSoft); color: var(--bot);
  font-size: 13px; font-weight: 600; margin-top: 12px; }
.botstate.off { background: var(--waitSoft); color: var(--wait); }
.botstate .dot { background: currentColor; }
.side-foot { display: flex; align-items: center; gap: 10px; padding: 8px 6px 0; }
.side-foot .who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.side-foot .who small { font-size: 12px; color: var(--muted); }
.erp-link { display: flex; align-items: center; gap: 4px; height: 32px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line);
  color: var(--text); text-decoration: none; font-size: 13px; font-weight: 600; }
.mas-menu { position: absolute; z-index: 30; width: 230px; padding: 6px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); }
.mas-menu a, .mas-menu button { display: flex; align-items: center; gap: 10px; width: 100%; height: 36px; padding: 0 10px; border: none; border-radius: 8px;
  background: transparent; color: var(--text); text-decoration: none; text-align: left; }
.mas-menu a:hover, .mas-menu button:hover { background: var(--surface2); }

/* min-height:0 no es decorativo: en móvil #app pasa a columna y, sin él, este flex item toma
   min-height:auto (la altura de su contenido), #app{overflow:hidden} lo recorta y los .page/.ficha
   de adentro quedan tan altos como su contenido — no había nada que desplazar. */
.main { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; position: relative; }
.top { height: 56px; flex-shrink: 0; padding: 0 20px; display: flex; align-items: center; gap: 16px; border-bottom: 1px solid var(--line); }
.top h1 { margin: 0; font-size: 15px; font-weight: 700; white-space: nowrap; }
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tab { height: 32px; padding: 0 12px; border-radius: 8px; font-size: 13.5px; border: 1px solid transparent; background: transparent; color: var(--muted);
  text-decoration: none; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.on { border-color: var(--line); background: var(--surface); color: var(--text); font-weight: 700; }
.top-search { display: flex; align-items: center; gap: 8px; width: 260px; height: 36px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--muted); position: relative; }
.top-search input { border: none; outline: none; background: transparent; color: var(--text); width: 100%; font-size: 13.5px; }
.search-res { position: absolute; top: 42px; left: 0; right: 0; z-index: 40; background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); padding: 6px; max-height: 360px; overflow: auto; }
.search-res a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none; }
.search-res a:hover, .search-res a.on { background: var(--surface2); }
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.scroll { overflow-y: auto; }
.mobile-only { display: none !important; }

/* ── avisos ──────────────────────────────────────────────────────────── */
.avisos { position: absolute; top: 60px; right: 16px; width: 390px; max-height: calc(100% - 80px); display: flex; flex-direction: column; gap: 10px;
  padding: 14px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); z-index: 50; }
.avisos-list { overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.aviso { display: flex; gap: 10px; padding: 10px; border-radius: 12px; text-decoration: none; color: var(--text); border: none; background: transparent; text-align: left; width: 100%; }
.aviso:hover { background: var(--surface2); }
.aviso.nuevo.urgente { background: var(--hotSoft); } .aviso.nuevo.atencion { background: var(--waitSoft); } .aviso.nuevo.info { background: var(--accentSoft); }
.aviso .dot { margin-top: 6px; }
.aviso b { font-weight: 700; } .aviso.leido b { font-weight: 400; }
.push-box { display: flex; flex-direction: column; gap: 8px; padding-top: 8px; border-top: 1px solid var(--line); }

/* ── inicio / chat ───────────────────────────────────────────────────── */
.home { flex: 1; overflow-y: auto; display: flex; flex-direction: column; align-items: center; padding: 64px 24px 32px; gap: 28px; }
.home h2 { margin: 0; font-family: var(--serif); font-weight: 400; font-size: 42px; letter-spacing: -.3px; text-align: center; }
.cards3 { width: min(760px, 100%); display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.brief { text-align: left; display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); text-decoration: none; }
.brief:hover { border-color: var(--line2); color: var(--text); }
.brief .et { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; }
.brief .ti { font-size: 15px; font-weight: 600; } .brief .de { font-size: 13px; color: var(--muted); }
.tono-hot .et { color: var(--hot); } .tono-money .et { color: var(--money); } .tono-wait .et { color: var(--wait); } .tono-bot .et { color: var(--bot); }
.composer { width: min(760px, 100%); border-radius: 18px; border: 1px solid var(--line); background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.05);
  display: flex; flex-direction: column; gap: 10px; padding: 14px 14px 10px; }
.composer textarea { border: none; outline: none; resize: none; background: transparent; color: var(--text); font-size: 16px; line-height: 1.5; max-height: 40vh; min-height: 28px; }
.composer .tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.composer { position: relative; }
.seg-mode { margin-left: auto; }
#cmpSeg[data-modo="estricto"] { color: var(--bot); } #cmpSeg[data-modo="equilibrado"] { color: var(--accent); } #cmpSeg[data-modo="fluido"] { color: var(--wait); }
.seg-menu { position: absolute; bottom: calc(100% + 8px); right: 8px; z-index: 40; width: min(320px, calc(100vw - 32px)); padding: 6px;
  border-radius: 14px; border: 1px solid var(--line); background: var(--surface); box-shadow: 0 8px 28px rgba(0,0,0,.18); display: flex; flex-direction: column; gap: 2px; }
.seg-menu[hidden] { display: none; }
.seg-menu button { display: flex; gap: 10px; align-items: flex-start; text-align: left; padding: 8px 10px; border: none; border-radius: 10px; background: transparent; color: var(--text); cursor: pointer; font: inherit; }
.seg-menu button:hover, .seg-menu button[aria-checked="true"] { background: var(--surface2); }
.seg-menu button b { display: block; font-size: 14px; } .seg-menu button small { display: block; font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.seg-menu .ic { margin-top: 1px; } .seg-menu .ic[data-modo="estricto"] { color: var(--bot); } .seg-menu .ic[data-modo="equilibrado"] { color: var(--accent); } .seg-menu .ic[data-modo="fluido"] { color: var(--wait); }
.seg-menu .nota { font-size: 12px; color: var(--muted); padding: 6px 10px 4px; border-top: 1px solid var(--line); margin-top: 2px; }
.seg { display: flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--surface2); }
.seg button { display: flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border: none; border-radius: 8px; font-size: 13px; background: transparent; color: var(--muted); }
.seg button[aria-checked="true"] { background: var(--surface); color: var(--text); font-weight: 700; box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.hint { flex: 1; min-width: 140px; font-size: 12.5px; color: var(--muted); }
.send { width: 36px; height: 36px; border-radius: 10px; border: none; background: var(--accent); color: var(--accentText); display: flex; align-items: center; justify-content: center; }
.send[disabled] { opacity: .4; }
.sugs { width: min(760px, 100%); display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.sug { height: 34px; padding: 0 14px; border-radius: 17px; border: 1px solid var(--line); background: transparent; color: var(--text2); font-size: 13.5px; }
.sug:hover { background: var(--surface); }

.chatwrap { flex: 1; min-height: 0; display: flex; }
.chatcol { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.msgs { flex: 1; overflow-y: auto; padding: 24px 24px 12px; }
.msgs-in { max-width: 780px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.m-user { align-self: flex-end; max-width: 85%; padding: 10px 14px; border-radius: 16px 16px 4px 16px; background: var(--surface2); white-space: pre-wrap; word-wrap: break-word; }
.m-asis { align-self: stretch; line-height: 1.6; font-size: 15px; word-wrap: break-word; }
.m-asis p { margin: 0 0 .7em; } .m-asis p:last-child { margin-bottom: 0; }
.m-asis h2, .m-asis h3, .m-asis h4, .m-asis h5 { margin: 1em 0 .4em; font-size: 1.05em; }
.m-asis ul, .m-asis ol { margin: .3em 0 .7em; padding-left: 1.4em; }
.m-asis code { background: var(--surface2); padding: 1px 5px; border-radius: 5px; font-size: .92em; }
.m-asis pre { background: var(--surface2); padding: 12px; border-radius: 10px; overflow-x: auto; }
.m-asis pre code { background: none; padding: 0; }
.m-asis blockquote { margin: .5em 0; padding-left: 12px; border-left: 3px solid var(--line2); color: var(--text2); }
.tbl { overflow-x: auto; margin: .5em 0; } .tbl table { border-collapse: collapse; font-size: 13.5px; min-width: 60%; }
.tbl th, .tbl td { border-bottom: 1px solid var(--line); padding: 6px 10px; } .tbl th { font-weight: 700; background: var(--surface2); }
.m-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 6px; }
.toolchip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 13px; border: 1px solid var(--line); font-size: 12.5px; color: var(--text2); background: var(--surface); }
.toolchip.listo { color: var(--muted); } .toolchip.fallo { color: var(--hot); border-color: var(--hot); }
.toolrow { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.artcard { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); text-align: left; width: 100%; max-width: 420px; color: var(--text); }
.artcard:hover { border-color: var(--accent); }
.artcard .ai { width: 36px; height: 36px; border-radius: 8px; background: var(--accentSoft); color: var(--accent); display: flex; align-items: center; justify-content: center; }
.confcard { border: 1.5px solid var(--wait); background: var(--waitSoft); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; max-width: 560px; }
.confcard.confirmada { border-color: var(--bot); background: var(--botSoft); } .confcard.cancelada, .confcard.fallida { border-color: var(--line2); background: var(--surface2); }
.chat-foot { padding: 8px 24px 18px; }
.chat-foot .composer { margin: 0 auto; max-width: 780px; width: 100%; }
.cursor::after { content: "▍"; animation: blink 1s steps(1) infinite; color: var(--muted); }
@keyframes blink { 50% { opacity: 0; } }
.artpanel { width: min(48%, 720px); flex-shrink: 0; border-left: 1px solid var(--line); display: flex; flex-direction: column; background: var(--surface); }
.artpanel header { height: 52px; display: flex; align-items: center; gap: 8px; padding: 0 12px 0 16px; border-bottom: 1px solid var(--line); }
.artbody { flex: 1; overflow: auto; padding: 20px 24px; }
.artbody iframe { width: 100%; height: 100%; border: none; background: #fff; border-radius: 8px; }
.artbody.frame { padding: 0; }

/* ── conversaciones ──────────────────────────────────────────────────── */
.conv { flex: 1; min-height: 0; display: flex; }
.conv-list { width: var(--w-bandeja, 340px); flex-shrink: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); }
.filtros { display: flex; gap: 6px; padding: 12px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.filtro { height: 30px; padding: 0 10px; border-radius: 15px; font-size: 12.5px; border: 1px solid var(--line); background: transparent; color: var(--text2); display: inline-flex; align-items: center; gap: 6px; }
.filtro.on { border-color: var(--text); background: var(--text); color: var(--bg); font-weight: 700; }
.hilo { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 14px 12px 8px; border: none; border-bottom: 1px solid var(--line);
  text-align: left; background: transparent; color: var(--text); text-decoration: none; }
.hilo:hover { background: var(--surface2); color: var(--text); } .hilo.on { background: var(--surface2); }
.hilo .bar { width: 4px; align-self: stretch; border-radius: 2px; background: transparent; }
.hilo .bar.hot { background: var(--hot); } .hilo .bar.wait { background: var(--wait); }
.hilo .nm { font-weight: 400; } .hilo.unread .nm { font-weight: 700; }
.hilo .pv { font-size: 13px; color: var(--muted); }
.thread { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.thread-top { min-height: 60px; flex-shrink: 0; padding: 8px 20px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); }
.thread-msgs { flex: 1; overflow-y: auto; padding: 20px 28px; display: flex; flex-direction: column; gap: 12px; background: var(--bg); }
.bw { display: flex; flex-direction: column; gap: 4px; }
.bw.c { align-items: flex-start; } .bw.b, .bw.h { align-items: flex-end; } .bw.s { align-items: center; }
.bub { max-width: min(520px, 85%); padding: 10px 14px; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; }
.bw.c .bub { border-radius: 14px 14px 14px 4px; background: var(--surface); border: 1px solid var(--line); }
.bw.b .bub { border-radius: 14px 14px 4px 14px; border: 1.5px dashed var(--bot); }
.bw.h .bub { border-radius: 14px 14px 4px 14px; background: var(--accent); color: var(--accentText); }
.bw.s .bub { font-size: 12.5px; color: var(--muted); background: var(--surface2); border-radius: 10px; }
.bw .meta { font-size: 11.5px; color: var(--muted); }
.bw .who { font-size: 11px; font-weight: 700; letter-spacing: .4px; color: var(--bot); }
.thread-foot { flex-shrink: 0; padding: 12px 20px 16px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.sendbox { display: flex; align-items: flex-end; gap: 8px; padding: 6px 6px 6px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); }
.sendbox textarea { flex: 1; border: none; outline: none; resize: none; background: transparent; color: var(--text); font-size: 14px; padding: 6px 0; max-height: 160px; }
.ficha-mini { width: var(--w-ficha, 300px); flex-shrink: 0; padding: 18px; display: flex; flex-direction: column; gap: 14px; border-left: 1px solid var(--line); overflow-y: auto; }
.kv { display: flex; flex-direction: column; gap: 4px; } .kv small { font-size: 12px; color: var(--muted); }
.money2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.money2 > div, .money3 > div { padding: 10px; border-radius: 10px; background: var(--surface2); }
.money2 .debe, .money3 .debe { background: var(--moneySoft); color: var(--money); }
.money2 b, .money3 b { font-size: 16px; display: block; }
.sincli { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 12px; background: var(--waitSoft); border: 1px solid var(--line); }

/* ── clientes ────────────────────────────────────────────────────────── */
.cli { flex: 1; min-height: 0; display: flex; }
.cli-list { width: 310px; flex-shrink: 0; border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.cli-search { padding: 12px; border-bottom: 1px solid var(--line); }
.cli-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 14px; border: none; border-bottom: 1px solid var(--line); background: transparent; color: var(--text); text-align: left; text-decoration: none; }
.cli-row:hover { background: var(--surface2); color: var(--text); } .cli-row.on { background: var(--surface2); }
.ficha { flex: 1; min-width: 0; overflow-y: auto; padding: 24px 28px; display: flex; flex-direction: column; gap: 16px; }
.ficha h2 { margin: 0; font-family: var(--serif); font-weight: 500; font-size: 30px; }
.resumen { display: flex; flex-direction: column; gap: 10px; padding: 18px 20px; border-radius: 16px; background: var(--accentSoft); border: 1px solid var(--line); }
.resumen .et { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--accent); }
.resumen p { margin: 0; font-size: 15px; line-height: 1.55; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.sec { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); min-width: 0; }
.sec h3 { margin: 0; font-size: 15px; }
.sec .row h3 { flex: 1; }
.money3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.lrow { display: flex; gap: 10px; font-size: 13.5px; padding-top: 6px; border-top: 1px solid var(--line); align-items: baseline; }
.lrow:first-of-type { border-top: none; }
.lrow .f { color: var(--muted); width: 72px; flex-shrink: 0; font-size: 12.5px; }
.kanban-top { display: flex; align-items: center; gap: 14px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 12px; align-items: start; overflow-x: auto; padding-bottom: 8px; }
.kcol { display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: 14px; background: var(--surface2); min-height: 120px; }
.kcol.drop { outline: 2px dashed var(--accent); }
/* Una etapa sin tarjetas no merece una columna entera: se pliega a una tira angosta y sigue
   aceptando que le arrastres una tarjeta encima. */
.kcol.vacia { max-width: 132px; opacity: .72; }
.kcol.vacia:hover, .kcol.vacia.drop { opacity: 1; }
.kcard { text-align: left; display: flex; flex-direction: column; gap: 6px; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.kcard[draggable="true"] { cursor: grab; }
.kcard:hover { border-color: var(--line2); }

/* ── módulos (iframe) ───────────────────────────────────────────────── */
.modframe { flex: 1; border: none; width: 100%; background: var(--bg); }
.modbar { display: flex; align-items: center; gap: 10px; padding: 6px 16px; font-size: 12.5px; color: var(--muted); border-bottom: 1px solid var(--line); }

/* ── páginas (proyectos, artefactos, programados, ajustes) ───────────── */
.page { flex: 1; overflow-y: auto; padding: 28px; }
.page-in { max-width: 900px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.page h2 { margin: 0; font-family: var(--serif); font-weight: 500; font-size: 30px; }
.gridc { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.tile { display: flex; flex-direction: column; gap: 6px; padding: 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); color: var(--text); text-decoration: none; text-align: left; }
.tile:hover { border-color: var(--line2); color: var(--text); }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.switch { width: 40px; height: 24px; border-radius: 12px; background: var(--line2); border: none; position: relative; flex-shrink: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch[aria-checked="true"] { background: var(--bot); } .switch[aria-checked="true"]::after { left: 19px; }
/* FASE Q: interruptor del bot nocturno (checkbox real: accesible con teclado y lector de pantalla) */
label.switch { display: inline-block; cursor: pointer; }
label.switch::after { display: none; }
label.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
label.switch span { position: absolute; inset: 0; border-radius: 12px; background: var(--line2); transition: background .15s; }
label.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: left .15s; }
label.switch input:checked + span { background: var(--bot); }
label.switch input:checked + span::after { left: 19px; }
label.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.noct { padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); margin-bottom: 14px; }
.noct.on { border-color: var(--bot); background: var(--botSoft); }

/* ── login ───────────────────────────────────────────────────────────── */
.login { min-height: 100%; width: 100%; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login-box { width: min(400px, 100%); display: flex; flex-direction: column; gap: 16px; }
.login-box h1 { margin: 0; font-family: var(--serif); font-weight: 400; font-size: 34px; }
.login-err { color: var(--hot); font-size: 13.5px; min-height: 1.2em; }
.login-ok { color: var(--bot); font-size: 13.5px; }

/* dialogs & toasts */
dialog.dlg { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--text); padding: 20px; width: min(460px, calc(100% - 32px)); box-shadow: var(--shadow); }
dialog.dlg::backdrop { background: rgba(0,0,0,.35); }
dialog.dlg.wide { width: min(720px, calc(100% - 32px)); }
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 13.5px; box-shadow: var(--shadow); transition: opacity .4s; max-width: 90vw; }
.toast.error { background: var(--hot); color: #fff; } .toast.ok { background: var(--bot); color: #fff; }
.toast.out { opacity: 0; }

/* ── responsive ─────────────────────────────────────────────────────── */
@media (max-width: 1180px) {
  .ficha-mini { display: none; }
  .artpanel { position: absolute; inset: 0; width: auto; z-index: 20; }
}
@media (max-width: 900px) {
  body { font-size: 15px; }
  .mobile-only { display: flex !important; }
  .desk-only { display: none !important; }
  /* 100dvh sigue a la barra del navegador del teléfono; 100% se queda con la altura grande y deja
     la última franja debajo del borde. overscroll-behavior evita el rebote que arrastra la página. */
  #app { flex-direction: column; height: 100dvh; overscroll-behavior: none; }
  .page, .home, .ficha, .msgs, .thread-msgs, .scroll { -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
  .side { position: fixed; inset: 0 auto 0 0; z-index: 60; width: 86vw; max-width: 320px; transform: translateX(-105%); transition: transform .2s; box-shadow: var(--shadow); }
  .side.open { transform: none; }
  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 55; }
  .top { padding: 0 8px 0 12px; gap: 6px; }
  .top h1 { font-size: 17px; flex: 1; }
  .top .icon-btn { width: 44px; height: 44px; border: none; background: transparent; }
  .tabs-m { display: flex; gap: 4px; padding: 8px 12px; border-bottom: 1px solid var(--line); overflow-x: auto; }
  .bottom { height: 64px; flex-shrink: 0; display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); background: var(--side); padding-bottom: env(safe-area-inset-bottom); }
  .bottom a, .bottom button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: none; background: transparent;
    font-size: 11.5px; color: var(--muted); text-decoration: none; position: relative; }
  .bottom .on { color: var(--accent); font-weight: 700; }
  .bottom .pill { position: absolute; top: 6px; left: calc(50% + 6px); }
  .home { padding: 24px 16px; gap: 16px; align-items: stretch; }
  .home h2 { font-size: 30px; text-align: left; }
  .composer textarea { font-size: 16px; }
  .composer .tools { flex-wrap: nowrap; gap: 6px; }
  .seg { flex: 1; min-width: 0; } .seg button { flex: 1; justify-content: center; height: 36px; padding: 0 4px; font-size: 12.5px; gap: 4px; }
  .composer .icon-btn.plain { width: 36px; min-height: 36px; }
  .conv-list, .cli-list { width: 100%; border-right: none; }
  .conv.sel .conv-list, .cli.sel .cli-list { display: none; }
  .conv:not(.sel) .thread, .cli:not(.sel) .ficha { display: none; }
  .thread-msgs { padding: 16px; }
  .ficha { padding: 18px 16px; } .ficha h2 { font-size: 26px; }
  .grid2 { grid-template-columns: 1fr; }
  .avisos { position: fixed; inset: 56px 8px auto 8px; width: auto; max-height: calc(100% - 140px); }
  .msgs { padding: 16px 14px 8px; } .chat-foot { padding: 6px 10px 10px; }
  .page { padding: 18px 16px; }
  .kanban { grid-auto-columns: 82vw; scroll-snap-type: x mandatory; } .kcol { scroll-snap-align: start; }
  .btn, .icon-btn { min-height: 40px; }
}
@media (min-width: 901px) { .bottom, .tabs-m, .scrim { display: none !important; } }

/* Tarjeta de MENSAJES a clientes (20-09-2026). El texto se enseña completo y con sus saltos de
   línea: es literal lo que va a leer el cliente, así que recortarlo sería esconder lo que se
   aprueba. Cada renglón es un <label> para que el toque en cualquier parte marque la casilla. */
.msgprev { display: flex; flex-direction: column; gap: 8px; margin: 6px 0 2px; }
.msgrow { display: flex; gap: 10px; align-items: flex-start; padding: 9px 11px; border-radius: 9px;
  background: var(--bg-2, rgba(127, 127, 127, .07)); border: 1px solid var(--line); cursor: pointer; }
.msgrow:has(input:checked) { border-color: var(--accent); }
.msgrow.cerrada { opacity: .72; border-style: dashed; }
.msgrow input { margin-top: 3px; width: 17px; height: 17px; flex: 0 0 auto; accent-color: var(--accent); }
.msgrow input:disabled { cursor: default; }


/* Archivos del cliente: desplegable sobre el redactor (2026-09-21). En rejilla empujaban el hilo
   hacia abajo; aquí están a un clic y cada uno dice lo que VIO el cerebro de visión. */
.adjmenu { position: relative; }
.adjmenu .adjn { font-weight: 700; }
.adjpop {
  position: absolute; bottom: calc(100% + 6px); left: 0; z-index: 40;
  width: min(380px, 78vw); max-height: 46vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .16); padding: 6px;
}
.adjit { display: flex; gap: 10px; align-items: center; padding: 7px; border-radius: 9px;
  text-decoration: none; color: var(--text); }
.adjit:hover { background: var(--surface2); }
.adjit img { width: 46px; height: 46px; object-fit: cover; border-radius: 7px; flex-shrink: 0; }
.adjit .adjico { width: 46px; height: 46px; display: flex; align-items: center; justify-content: center;
  font-size: 24px; background: var(--surface2); border-radius: 7px; flex-shrink: 0; }
.adjtx { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: 12.5px; line-height: 1.3; }
.adjtx b { font-size: 12.5px; }
.adjtx .muted { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Copiloto: se queda con el sitio que ocupaban el resumen y las acciones rápidas. */
.copiloto { display: flex; flex-direction: column; gap: 8px; flex: 1; min-height: 0; }
.copiloto { border-top: 1px solid var(--line); padding-top: 12px; }
.cop-top { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.cop-top b { display: inline-flex; align-items: center; gap: 6px; }
.cop-nuevos { font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 10px; background: var(--waitSoft); color: var(--wait); }
.cop-hilo { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; max-height: 46vh; min-height: 60px; }
.cop-vacio { font-size: 12.5px; line-height: 1.5; }
.cop-yo { align-self: flex-end; max-width: 90%; padding: 6px 10px; border-radius: 10px; background: var(--accentSoft); font-size: 13px; }
.cop-ia { font-size: 13.5px; line-height: 1.5; }
.cop-ia .toolrow { display: flex; flex-wrap: wrap; gap: 4px; }
.cop-ia .toolrow:empty { display: none; }
.cop-ia .toolchip { height: 22px; font-size: 11.5px; padding: 0 8px; }
.cop-nota { font-size: 12px; color: var(--muted); border-left: 2px solid var(--line2); padding-left: 8px; }
.cop-sug { display: flex; flex-direction: column; gap: 6px; padding: 10px; border-radius: 12px; border: 1px solid var(--bot); background: var(--botSoft); }
.cop-sug.incierta { border-color: var(--hot); background: var(--hotSoft); }
.cop-sug small { font-size: 12px; font-weight: 700; color: var(--text2); }
.cop-porque { font-size: 12px; }
.cop-sug textarea { width: 100%; resize: vertical; border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: var(--surface); font-size: 13.5px; line-height: 1.45; }
.cop-intake { display: flex; flex-direction: column; gap: 6px; padding: 10px; border-radius: 12px; border: 1px solid var(--accent); background: var(--accentSoft); }
.cop-intake small { font-size: 12px; font-weight: 700; color: var(--text2); }
.cop-intake dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 0; font-size: 12.5px; }
.cop-intake dt { color: var(--muted); text-transform: capitalize; } .cop-intake dd { margin: 0; overflow-wrap: anywhere; }
.cop-pago { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; background: var(--moneySoft); color: var(--money); font-size: 12.5px; font-weight: 600; }
.cop-acciones { display: flex; gap: 6px; }
.cop-acciones .btn { flex: 1; justify-content: center; }
.cop-preg { display: flex; gap: 6px; align-items: center; }
.cop-preg .input { height: 34px; flex: 1; min-width: 0; }
.cop-preg .send { width: 34px; height: 34px; flex-shrink: 0; }

/* Columnas ajustables (2026-09-21). El tirador es el borde: se arrastra y el ancho se recuerda
   en este navegador. Sin JS de librería, sin depender de que el layout sea grid. */
.tirador { width: 6px; flex-shrink: 0; cursor: col-resize; background: transparent;
  border-right: 1px solid var(--line); transition: background .12s; }
.tirador:hover, .tirador.arrastrando { background: var(--text); opacity: .18; }
.conv-list { border-right: none; }
.ficha-mini { border-left: none; }
@media (max-width: 900px) { .tirador { display: none; } .conv-list { width: 100%; } }
/* M1 — botones de artefacto (fuera del iframe: el sandbox sigue sin red) */
.artacc { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--line); background: var(--surface); }
/* M7 — tablas del tablero de uso */
.tabla-scroll { overflow-x: auto; max-width: 100%; }
.tmin { border-collapse: collapse; font-size: 12.5px; width: 100%; margin-top: 4px; }
.tmin th, .tmin td { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tmin th { color: var(--muted); font-weight: 600; }
/* M5 — Mostrador (tableta de pie): objetivos táctiles de 56 px o más, texto grande, sin hover. */
.most { padding: 16px; display: flex; flex-direction: column; gap: 14px; max-width: 1400px; margin: 0 auto; width: 100%; }
.most-top { display: flex; gap: 12px; flex-wrap: wrap; }
.most-buscar { flex: 1 1 320px; display: flex; align-items: center; gap: 10px; height: 60px; padding: 0 16px; border-radius: 14px; border: 1px solid var(--line2); background: var(--surface); }
.most-buscar input { flex: 1; border: none; background: none; font-size: 18px; outline: none; min-width: 0; }
.most-grande { min-height: 60px; font-size: 17px; padding: 0 22px; border-radius: 14px; }
.most-res { display: flex; flex-direction: column; gap: 8px; }
.most-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.most-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 10px; min-height: 220px; }
.most-card h3 { margin: 0; font-size: 18px; }
.most-list { display: flex; flex-direction: column; gap: 8px; }
.most-item { display: flex; flex-direction: column; gap: 2px; min-height: 58px; justify-content: center; padding: 10px 14px; border-radius: 12px; background: var(--surface2); color: var(--text); text-decoration: none; border-left: 5px solid var(--line2); }
.most-item b { font-size: 16px; } .most-item span { font-size: 14px; color: var(--text2); }
.most-item.hot { border-left-color: var(--hot); } .most-item.wait { border-left-color: var(--wait); }
.most-item:active { transform: scale(.99); }
.most-vacio { color: var(--muted); font-size: 15px; padding: 10px 2px; }
.most-in { height: 52px; font-size: 18px; }
.most-pie { text-align: center; font-size: 13px; margin: 0; }
/* ── Pantallas NATIVAS (Inventario / Calculadora / Presupuestos, 2026-09-21) ─────────────────── */
.nat { padding: 18px 22px; display: flex; flex-direction: column; gap: 12px; min-height: 0; height: 100%; max-width: 1500px; margin: 0 auto; width: 100%; }
.nat-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.nat-h { margin: 0; font-family: var(--serif); font-weight: 500; font-size: 26px; }
.nat-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.nat-bar .input { flex: 1 1 260px; height: 38px; }
.nat-split { display: flex; gap: 14px; flex: 1; min-height: 0; }
.nat-tabla { flex: 1; min-width: 0; overflow: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.nat-panel { width: 380px; flex-shrink: 0; overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.nat-sec { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--line); padding-top: 10px; }
.ntab { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.ntab th { position: sticky; top: 0; background: var(--surface2); text-align: left; font-weight: 600; color: var(--text2); padding: 8px 10px; border-bottom: 1px solid var(--line); z-index: 1; }
.ntab td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.ntab td b { display: block; font-weight: 600; } .ntab td .muted { font-size: 12px; }
.ntab tbody tr { cursor: pointer; } .ntab tbody tr:hover, .ntab tbody tr.on { background: var(--accentSoft); }
.ntab .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.chip-s { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 1px 8px; border-radius: 10px; background: var(--surface2); color: var(--text2); border: 1px solid var(--line); cursor: default; }
button.chip-s { cursor: pointer; }
.chip-s.wait { background: var(--waitSoft); color: var(--wait); border-color: transparent; }
.chip-s.bot { background: var(--botSoft); color: var(--bot); border-color: transparent; }
.ubic { font-size: 13px; }
.nat-chat { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); }
.nat-chat .input { flex: 1; border: none; height: 34px; background: transparent; }
.nat-ej { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.tj { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 12px; border: 1px solid var(--accent); background: var(--accentSoft); font-size: 13.5px; }
.tj.confirmada { border-color: var(--bot); background: var(--botSoft); } .tj.fallida, .tj.incierta { border-color: var(--hot); background: var(--hotSoft); }
.tj.cancelada { border-color: var(--line); background: var(--surface2); }
.tj-est { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--text2); }
.tj-cambio { display: flex; gap: 10px; align-items: baseline; font-size: 16px; font-variant-numeric: tabular-nums; }
.tj-dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0; font-size: 13px; }
.tj-dl dt { color: var(--muted); } .tj-dl dd { margin: 0; overflow-wrap: anywhere; }
.tj-lista { margin: 0; padding-left: 18px; } .tj-res { font-size: 13px; color: var(--text2); white-space: pre-wrap; }
@media (max-width: 1000px) { .nat-split { flex-direction: column; } .nat-panel { width: 100%; } .nat { padding: 12px; } }
/* 22-09 (Fernando: «en teléfono no puedo bajar» en Presupuestos y Calculadora). .nat medía el 100 % del alto y .view recorta
   (overflow:hidden): lo que pasaba del alto quedaba cortado sin forma de bajar (Calculadora 611 px visibles de 978). Ahora .nat
   desplaza siempre; y en pantallas angostas la tabla y el panel toman su alto natural y se baja con TODA la página, en vez de
   dos cajitas con scroll propio (la lista de Presupuestos quedaba en 252 px y el detalle, debajo, inalcanzable). */
.nat { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
/* Los hijos de .nat no se encogen (el tablero de Trabajos quedaba en 268 px y cortaba las columnas); sólo .nat-split se ajusta
   al alto en escritorio para que su tabla y su panel desplacen por dentro. */
.nat > :not(.nat-split) { flex-shrink: 0; }
@media (max-width: 1000px) {
  .nat-split { flex: none; }
  .nat-tabla { flex: none; overflow-y: visible; overflow-x: auto; }
  .nat-panel { flex: none; overflow: visible; }
  .ntab th { position: static; }
}
.nat-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.cpart { border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 8px; background: var(--bg); }
.cgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.cfield { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.cfield .input { height: 34px; color: var(--text); }
.cfield.wide { grid-column: span 2; } .cfield.chk { flex-direction: row; align-items: center; gap: 6px; color: var(--text); }
.nat-panel.ancho { width: 560px; }
.money3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.money3 > div { background: var(--surface2); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; }
.money3 small { font-size: 11.5px; color: var(--muted); } .money3 b { font-size: 16px; font-variant-numeric: tabular-nums; }
.money3 .debe { background: var(--moneySoft); color: var(--money); }
.ntab.edit td { padding: 4px 6px; } .ntab.edit .input { height: 32px; width: 100%; } .ntab.edit .input.n { width: 96px; text-align: right; }
.ntab.edit tbody tr { cursor: default; } .ntab.edit tr.nueva { background: var(--botSoft); }
@media (max-width: 1000px) { .nat-panel.ancho { width: 100%; } }
.nat-bar .seg { max-width: 100%; overflow-x: auto; flex-wrap: nowrap; }
.nat-bar .seg button { flex-shrink: 0; }
.nat-panel .tmin td, .nat-panel .tmin th { white-space: normal; }
.nat-panel .tmin td.num, .nat-panel .tmin th.num { white-space: nowrap; text-align: right; }
.nat, .nat-split, .nat-tabla { min-width: 0; }

/* U1 (21-09): tarjetas del copiloto — las pendientes con tope de alto; las resueltas en «Acciones confirmadas». */
/* 21-09 (2ª): sin scroll propio — en la columna flexible del panel se encogía hasta no leerse. */
#copTarjetas { flex-shrink: 0; }
.copiloto > * { flex-shrink: 0; }
.copiloto > .cop-hilo { flex-shrink: 1; }
.cop-tj { border-color: var(--accent); background: var(--accentSoft); }
.cop-tj-t { font-size: 13.5px; line-height: 1.35; }
.cop-tj .tmin, .cop-tj .tj-lista, .cop-tj .tj-dl { font-size: 12.5px; }
.cop-tj .tmin { width: 100%; table-layout: fixed; }
.cop-tj .tmin th, .cop-tj .tmin td { white-space: normal; overflow-wrap: anywhere; padding: 4px 4px; }
.cop-tj .tmin th:nth-child(2), .cop-tj .tmin td:nth-child(2) { width: 46px; text-align: center; }
.cop-tj .tmin th:nth-child(3), .cop-tj .tmin td:nth-child(3) { width: 78px; text-align: right; }
.cop-tj .tj-res { font-size: 12.5px; }
#copTarjetas:empty { display: none; }
.cop-hechas .cop-hechas-pop { top: calc(100% + 6px); bottom: auto; }
.cop-hecha { align-items: flex-start; cursor: default; }
.cop-hecha.confirmada svg { color: var(--bot); } .cop-hecha.cancelada svg { color: var(--muted); }
.cop-hecha.fallida svg, .cop-hecha.incierta svg { color: var(--hot); }

/* U2 (21-09): Agenda nativa */
.ag-lista { padding: 4px 14px 14px; }
.ag-grupo h3 { font-size: 13px; text-transform: capitalize; color: var(--text2); margin: 14px 0 4px; }
.ag-grupo.venc h3 { color: var(--hot); }
.ag-fila { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-top: 1px solid var(--line); }
.ag-grupo .ag-fila:first-of-type { border-top: none; }
.ag-fila.venc .ag-t { color: var(--hot); }
.ag-ico { width: 22px; text-align: center; flex-shrink: 0; }
.ag-cuerpo { font-size: 12.5px; color: var(--text2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ag-acc { flex-shrink: 0; gap: 6px; }
@media (max-width: 640px) { .ag-fila { display: grid; grid-template-columns: 22px minmax(0, 1fr); } .ag-acc { grid-column: 2; justify-content: flex-end; } }

/* Acciones confirmadas del chat (21-09): bajo la caja de escribir, desplegable hacia arriba */
.ch-hechas { max-width: 780px; margin: 4px auto 0; width: 100%; }
.ch-hechas .adjpop { max-height: 50vh; }

/* U2: parámetros de la calculadora nativa */
.calc-par { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.calc-par summary { cursor: pointer; font-size: 13px; font-weight: 600; }
.calc-par-in { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; margin: 8px 0 4px; }

/* U2 Trabajos nativo */
.avance { flex: 1; height: 6px; border-radius: 4px; background: var(--surface2); overflow: hidden; }
.avance i { display: block; height: 100%; background: var(--bot); }
/* Publicar desde el chat (21-09): la imagen tal como saldría en Facebook, dentro de la tarjeta. */
.pub-prev { display: block; max-width: min(100%, 360px); max-height: 360px; object-fit: contain; border-radius: 8px; border: 1px solid var(--line); background: var(--bg2, #0000); }
/* Su panel de cliente (eje extra, 21-09): réplica del portal del cliente (/opt/cliente-pwa) con SU paleta, para que se vea como él lo ve. */
.cpv-wrap { display: grid; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .cpv-wrap { grid-template-columns: 1fr; } }
.cpv { --pbg: #eef2f7; --psf: #fff; --pink: #0f172a; --psoft: #475569; --pline: #d3dce6; --pacc: #0f4c81; --pok: #15803d; --ptrack: #e2e8f0;
  background: var(--pbg); color: var(--pink); border: 8px solid #1f2937; border-radius: 26px; padding: 14px; display: flex; flex-direction: column; gap: 10px;
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; max-height: 640px; overflow: auto; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .cpv { --pbg: #0b1220; --psf: #16202f; --pink: #e8eef7; --psoft: #9fb0c6; --pline: #2b3a4f; --pacc: #4c9be8; --pok: #34d17d; --ptrack: #22303f; } }
:root[data-theme="dark"] .cpv { --pbg: #0b1220; --psf: #16202f; --pink: #e8eef7; --psoft: #9fb0c6; --pline: #2b3a4f; --pacc: #4c9be8; --pok: #34d17d; --ptrack: #22303f; }
.cpv-brand { display: flex; gap: 10px; align-items: center; }
.cpv-brand small, .cpv-sub { color: var(--psoft); font-size: 12.5px; display: block; }
.cpv-logo { width: 34px; height: 34px; border-radius: 10px; background: var(--pacc); color: #fff; display: grid; place-items: center; font-weight: 800; flex: none; }
.cpv-card { background: var(--psf); border: 1px solid var(--pline); border-radius: 14px; padding: 14px; overflow-wrap: anywhere; }
.cpv-card h4 { margin: 0 0 6px; font-size: 14.5px; line-height: 1.3; }
.cpv-pct { font-size: 1.6rem; font-weight: 800; line-height: 1; }
.cpv-bar { height: 10px; background: var(--ptrack); border-radius: 999px; overflow: hidden; margin: 8px 0; }
.cpv-bar > i { display: block; height: 100%; background: var(--pacc); border-radius: 999px; }
.cpv-steps { display: flex; gap: 5px; }
.cpv-steps > div { flex: 1; text-align: center; font-size: 10.5px; color: var(--psoft); min-width: 0; }
.cpv-steps > div > i { display: block; height: 6px; border-radius: 999px; background: var(--ptrack); margin-bottom: 4px; }
.cpv-steps > div.done { color: var(--pink); font-weight: 600; }
.cpv-steps > div.done > i { background: var(--pacc); }
.cpv-linea { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--pline); font-size: 13px; }
.cpv-imp { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cpv-ok { color: var(--pok); }
.cpv-total { display: flex; justify-content: space-between; margin-top: 8px; padding-top: 8px; border-top: 2px solid var(--pline); }
.cpv-total b { font-size: 1.15rem; }
.cpv-map { display: inline-block; margin-top: 10px; color: var(--pacc); font-weight: 600; font-size: 13px; }
.cpv-btn { display: block; text-align: center; border: 1px solid var(--pline); border-radius: 10px; padding: 10px; color: var(--pacc); font-weight: 700; }
.cpv-edit { gap: 10px; min-width: 0; }
.cpv-proy { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; min-width: 0; }
.cpv-aviso { font-size: 13px; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--accentSoft); }

/* FASE W (24-09): Cortes de vidrio (prefijo vd-, verificado libre) */
.vd-lista { max-height: 260px; overflow: auto; }
.vd-lista tr.sel td { background: var(--accentSoft); }
.vd-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.vd-piezas td { padding: 2px 4px; }
.vd-piezas .input { height: 30px; min-width: 64px; width: 100%; }
.vd-piezas .vd-cant { min-width: 48px; }
.vd-kpi { display: flex; gap: 18px; flex-wrap: wrap; }
.vd-kpi div { display: flex; flex-direction: column; } .vd-kpi b { font-size: 20px; } .vd-kpi span { font-size: 12px; color: var(--muted); }
.vd-svg { width: 100%; height: auto; background: var(--surface2); border-radius: 8px; }
.vd-hoja { fill: var(--surface); stroke: var(--text); stroke-width: 1.2; }
.vd-pz { fill: var(--accentSoft); stroke: var(--text); stroke-width: .7; }
.vd-sob { fill: var(--surface2); stroke: var(--line2); stroke-width: .5; stroke-dasharray: 3 2; }
.vd-cut { stroke: var(--hot); stroke-width: .9; stroke-dasharray: 5 3; }
.vd-t { fill: var(--text); text-anchor: middle; dominant-baseline: middle; font-weight: 700; }
.vd-pasos { margin: 6px 0 0; padding-left: 22px; font-size: 12.5px; display: flex; flex-direction: column; gap: 3px; }
.chip-s.vd-ok { background: var(--moneySoft); color: var(--money); border-color: transparent; }
@media (max-width: 700px) { .vd-piezas th:nth-child(4), .vd-piezas td:nth-child(4) { display: none; } }
/* O4 (2026-09-27): design preview in the chat */
.diseno-prev { margin: 8px 0; max-width: min(100%, 420px); }
.diseno-prev img { display: block; width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--line); box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.diseno-prev figcaption { display: flex; gap: 8px; margin-top: 8px; }
@media (max-width: 860px) { .dis-grid { grid-template-columns: minmax(0, 1fr) !important; } }

/* Z4 (2026-10-05): images attached in the chat composer */
.cmp-adj { display: flex; flex-wrap: wrap; gap: 8px; }
.cmp-adj[hidden] { display: none; }
.cmp-chip { display: inline-flex; align-items: center; gap: 8px; padding: 4px 6px 4px 4px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface2); color: var(--text2); font-size: 13px; max-width: 100%; }
.cmp-chip img { width: 40px; height: 40px; object-fit: contain; border-radius: 8px;
  background: repeating-conic-gradient(var(--line) 0 25%, transparent 0 50%) 0 0 / 10px 10px; }
.cmp-chip.err { border-color: var(--hot); color: var(--hot); }
.cmp-chip button.cmp-fondo { font-size: 13px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; color: inherit; }
.cmp-chip.revisar { flex-wrap: wrap; }
.cmp-chip.revisar img { width: 160px; height: 160px; background: repeating-conic-gradient(#d9d9d9 0 25%, #fff 0 50%) 0 0 / 16px 16px; }
.cmp-chip button { border: none; background: transparent; color: var(--muted); font-size: 18px; line-height: 1; cursor: pointer; padding: 0 4px; }
#cmpImgBtn { cursor: pointer; }
.m-user .m-img { display: inline-flex; flex-direction: column; gap: 2px; margin: 6px 6px 0 0; color: inherit; text-decoration: none; font-size: 12px; }
.m-user .m-img img { max-width: 160px; max-height: 160px; border-radius: 10px; object-fit: contain;
  background: repeating-conic-gradient(rgba(0,0,0,.08) 0 25%, transparent 0 50%) 0 0 / 12px 12px; }

/* 07-10 (conv 220) · pending cards: a bar above the composer + clearer card (type chip, title, label/value rows, warning) */
.tjv-bar { max-width: 780px; margin: 0 auto 8px; width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border: 1.5px solid var(--wait); background: var(--waitSoft); color: var(--text); border-radius: 12px; font-size: 13.5px; }
.tjv-bar[hidden] { display: none; }
.tjv-bar > svg { color: var(--wait); flex: none; }
.tjv-head { font-size: 12px; font-weight: 700; gap: 6px; align-items: center; }
.tjv-tipo { white-space: nowrap; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line2); color: var(--text2); }
.tjv-num { font-size: 11px; font-weight: 600; }
.tjv-tit { font-size: 14.5px; line-height: 1.35; }
.tjv-dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 0; font-size: 13.5px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.tjv-dl dt { color: var(--muted); font-weight: 600; }
.tjv-dl dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
.tjv-aviso { display: flex; gap: 6px; align-items: flex-start; font-size: 13px; font-weight: 600; color: var(--hot);
  background: var(--hotSoft); border-radius: 8px; padding: 7px 9px; }
.tjv-aviso > svg { flex: none; margin-top: 2px; }
.confcard.tjv-flash { box-shadow: 0 0 0 3px var(--wait); transition: box-shadow .2s; }
@media (max-width: 520px) { .tjv-dl { grid-template-columns: 1fr; gap: 0 0; } .tjv-dl dd { margin-bottom: 6px; } }
.tjv-sinresp { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; margin: -4px 0 4px auto; justify-content: flex-end; }
.tjv-sinresp svg { vertical-align: -2px; }
/* 07-10 Sitios module */
.sitios-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.sitio { min-height: 170px; }

/* Generador 3D (Impresión 3D, 2026-10-09): shape/mounting pickers with pictures + the generation's review pictures */
.g3-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-top: 6px; }
.g3-tile { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--surface); color: var(--text); font-size: 12.5px; cursor: pointer; }
.g3-tile img { width: 100%; aspect-ratio: 3 / 2; object-fit: contain; border-radius: 6px; background: #eeeae2; }
.g3-tile[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accentSoft); font-weight: 700; }
.g3-vistas { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; margin-top: 8px; }
.g3-vistas img { width: 100%; border-radius: 10px; background: #eeeae2; }
