/* 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; }
.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); }

.main { flex: 1; min-width: 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; }
.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: 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: 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); }
.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; }

/* ── 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; }
  #app { flex-direction: column; }
  .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; }
  .side.collapsed { width: 86vw; }
  .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; } }
