/* CRM FixNow — estilo iOS minimalista con la paleta del Brand Book FixNow (igual que Administración y Taller). */
:root {
  --bg: #eef3fb;
  --surface: #ffffff;
  --surface-2: #f6f8fc;
  --surface-3: #eef2f8;
  --ink: #141414;
  --ink-2: #3a4356;
  --ink-3: #6b7486;
  --line: #e3e8f2;
  --accent: #0066ff;
  --accent-strong: #2651a7;
  --accent-soft: rgba(0, 102, 255, 0.10);
  --ok: #16a34a; --ok-soft: #e3f3e4;
  --warn: #b45309; --warn-soft: #fff4dc;
  --danger: #d92d20; --danger-soft: #fff1f0;
  --bubble-me: #0066ff; --bubble-me-ink: #fff;
  --bubble-them: #ffffff;
  --note: #fff7d6; --note-ink: #6b4e00;
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(20,20,20,.04), 0 8px 24px rgba(38,81,167,.07);
  --shadow-lg: 0 20px 60px rgba(20,30,60,.18);
  --glass-bg: rgba(255,255,255,.72);
  --glass-border: rgba(255,255,255,.8);
  --blur: blur(20px) saturate(170%);
  --font: 'Montserrat', -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  --rail: 76px;
  --list: 380px;
  --info: 340px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0d12; --surface: #15181f; --surface-2: #1b1f28; --surface-3: #232835;
    --ink: #f2f4f8; --ink-2: #c8cdd8; --ink-3: #8b93a4; --line: #262b36;
    --accent-soft: rgba(73,151,246,.16); --bubble-them: #1f2430;
    --note: #3a3115; --note-ink: #f5d77a;
    --ok-soft: rgba(22,163,74,.18); --warn-soft: rgba(245,158,11,.16); --danger-soft: rgba(217,45,32,.16);
    --glass-bg: rgba(21,24,31,.72); --glass-border: rgba(255,255,255,.06);
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #0b0d12; --surface: #15181f; --surface-2: #1b1f28; --surface-3: #232835;
    --ink: #f2f4f8; --ink-2: #c8cdd8; --ink-3: #8b93a4; --line: #262b36;
    --accent-soft: rgba(73,151,246,.16); --bubble-them: #1f2430;
    --note: #3a3115; --note-ink: #f5d77a;
    --ok-soft: rgba(22,163,74,.18); --warn-soft: rgba(245,158,11,.16); --danger-soft: rgba(217,45,32,.16);
    --glass-bg: rgba(21,24,31,.72); --glass-border: rgba(255,255,255,.06);
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.3);
    color-scheme: dark;
  }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.4; -webkit-font-smoothing: antialiased; overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.hidden { display: none !important; }
.muted { color: var(--ink-3); }
.small { font-size: .82rem; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; gap: 8px; align-items: center; }
.wrap { flex-wrap: wrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- controles ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; background: var(--accent); color: #fff;
  font-weight: 600; font-size: .9rem; border-radius: 12px; padding: 9px 14px; min-height: 38px; cursor: pointer; white-space: nowrap; transition: transform .08s, background .15s, opacity .15s; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.secondary { background: var(--surface-2); color: var(--ink); border-color: var(--line); }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.ok { background: var(--ok); }
.btn.sm { min-height: 30px; padding: 5px 10px; font-size: .8rem; border-radius: 10px; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; border: 0; background: transparent; color: var(--ink-2); cursor: pointer; flex: none; position: relative; }
.icon-btn:hover { background: var(--surface-3); }
.icon-btn.active { color: var(--accent); background: var(--accent-soft); }
input, select, textarea { width: 100%; border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px; padding: 9px 12px; min-height: 40px; outline: none; transition: border .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--surface); }
input[type=checkbox] { width: auto; min-height: 0; accent-color: var(--accent); }
input[type=color] { padding: 3px; width: 46px; flex: none; }
label.f { display: grid; gap: 5px; font-size: .8rem; font-weight: 600; color: var(--ink-3); }
label.f > span { text-transform: uppercase; letter-spacing: .04em; }
.check { display: flex; align-items: center; gap: 8px; font-size: .9rem; color: var(--ink-2); cursor: pointer; }
.seg { display: inline-flex; background: var(--surface-3); border-radius: 12px; padding: 3px; gap: 2px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 9px; font-size: .84rem; font-weight: 600; color: var(--ink-3); cursor: pointer; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; flex: 1; justify-content: center; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.count { background: var(--accent); color: #fff; border-radius: 999px; font-size: .7rem; padding: 0 6px; min-width: 18px; line-height: 18px; text-align: center; font-weight: 700; }
.count.red { background: var(--danger); }
.count:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: .72rem; font-weight: 600; background: var(--surface-3); color: var(--ink-2); white-space: nowrap; max-width: 100%; }
.chip .sw { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.chip.btn-chip { cursor: pointer; border: 1px solid var(--line); background: var(--surface); padding: 5px 10px; font-size: .8rem; }
.chip.btn-chip.on { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff; flex: none; font-size: .95rem; position: relative; letter-spacing: -.02em; }
.avatar.sm { width: 32px; height: 32px; font-size: .78rem; }
.avatar.lg { width: 72px; height: 72px; font-size: 1.5rem; }
.avatar .ch { position: absolute; right: -2px; bottom: -2px; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--surface); }
.avatar .ch svg { width: 10px; height: 10px; stroke: #fff; stroke-width: 2.4; }
.avatar.sm .ch { width: 15px; height: 15px; }
.ch-whatsapp { background: #25d366; } .ch-instagram { background: linear-gradient(45deg,#f9a825,#e91e63,#7b1fa2); } .ch-email { background: #64748b; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.empty-state { margin: auto; text-align: center; color: var(--ink-3); padding: 24px; max-width: 360px; }
.empty-state .big { font-size: 42px; margin-bottom: 6px; }

/* ---------- login ---------- */
.login { height: 100%; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 20% -10%, rgba(0,102,255,.18), transparent), var(--bg); }
.login-card { width: 100%; max-width: 380px; padding: 30px; display: grid; gap: 14px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -.02em; font-size: 1.25rem; }
.brand .logo { width: 38px; height: 38px; border-radius: 11px; background: linear-gradient(135deg, #0066ff, #2651a7); display: grid; place-items: center; color: #fff; }
.error { color: var(--danger); min-height: 1.2em; margin: 0; font-size: .88rem; }

/* ---------- estructura ---------- */
.app { display: grid; grid-template-columns: var(--rail) 1fr; height: 100dvh; }
.rail { background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 0; z-index: 10; }
.rail .logo { width: 40px; height: 40px; border-radius: 12px; background: linear-gradient(135deg, #0066ff, #2651a7); display: grid; place-items: center; color: #fff; margin-bottom: 10px; }
.rail a { width: 60px; padding: 8px 0 6px; border-radius: 14px; display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--ink-3); text-decoration: none; font-size: .64rem; font-weight: 600; position: relative; }
.rail a:hover { background: var(--surface-2); }
.rail a.on { color: var(--accent); background: var(--accent-soft); }
.rail a .count { position: absolute; top: 2px; right: 6px; }
.rail .spacer { flex: 1; }
.view { min-width: 0; min-height: 0; height: 100dvh; overflow: hidden; }

/* chats: lista | chat | ficha */
.chats { display: grid; grid-template-columns: var(--list) 1fr; height: 100%; }
.chats.with-info { grid-template-columns: var(--list) 1fr var(--info); }
.pane-list { background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; position: relative; }
.pane-head { padding: 14px 14px 10px; display: grid; gap: 10px; border-bottom: 1px solid var(--line); }
.pane-head h1 { margin: 0; font-size: 1.5rem; letter-spacing: -.03em; font-weight: 800; }
.search { position: relative; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--ink-3); }
.search input { padding-left: 34px; background: var(--surface-3); border-color: transparent; }
.filters-row { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.filters-row::-webkit-scrollbar { display: none; }
.filters-row select { width: auto; min-height: 30px; padding: 4px 26px 4px 10px; font-size: .8rem; border-radius: 999px; background-color: var(--surface); flex: none; }
.filters-row select.on { border-color: var(--accent); color: var(--accent); background-color: var(--accent-soft); }
.list { overflow-y: auto; flex: 1; padding: 6px 6px 80px; }
.t-item { display: flex; gap: 11px; padding: 10px; border-radius: 16px; cursor: pointer; align-items: center; position: relative; }
.t-item:hover { background: var(--surface-2); }
.t-item.on { background: var(--accent-soft); }
.t-body { flex: 1; min-width: 0; display: grid; gap: 2px; }
.t-top { display: flex; gap: 6px; align-items: baseline; }
.t-name { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: -.01em; }
.t-time { font-size: .74rem; color: var(--ink-3); flex: none; }
.t-time.unread { color: var(--accent); font-weight: 700; }
.t-prev { display: flex; gap: 6px; align-items: center; }
.t-prev span:first-child { flex: 1; min-width: 0; color: var(--ink-3); font-size: .86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-item.unread .t-prev span:first-child { color: var(--ink); font-weight: 500; }
.t-meta { display: flex; gap: 4px; flex-wrap: nowrap; overflow: hidden; margin-top: 2px; }
.fab { position: absolute; right: 16px; bottom: 16px; width: 52px; height: 52px; border-radius: 18px; border: 0; background: var(--accent); color: #fff; display: grid; place-items: center; box-shadow: 0 10px 24px rgba(0,102,255,.35); cursor: pointer; z-index: 5; }
.fab svg { stroke-width: 2.2; }

.pane-chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative;
  background: var(--bg) radial-gradient(circle at 1px 1px, rgba(38,81,167,.07) 1px, transparent 0) 0 0 / 22px 22px; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--glass-bg); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--line); z-index: 3; min-height: 64px; }
.chat-head .who { flex: 1; min-width: 0; cursor: pointer; }
.chat-head .who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: -.01em; }
.chat-head .who small { color: var(--ink-3); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .76rem; }
.head-actions { display: flex; gap: 4px; align-items: center; }
.back { display: none; }
.status-bar { display: flex; gap: 6px; padding: 7px 14px; align-items: center; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; background: var(--glass-bg); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); border-bottom: 1px solid var(--line); }
.status-bar::-webkit-scrollbar { display: none; }
.status-bar select { width: auto; min-height: 30px; padding: 3px 26px 3px 10px; font-size: .8rem; border-radius: 999px; flex: none; }
.status-bar .btn { flex: none; }
.messages { flex: 1; overflow-y: auto; padding: 16px 7%; display: flex; flex-direction: column; gap: 3px; }
.day { align-self: center; background: var(--glass-bg); backdrop-filter: var(--blur); color: var(--ink-3); font-size: .72rem; font-weight: 700; padding: 4px 12px; border-radius: 999px; margin: 10px 0 6px; text-transform: capitalize; position: sticky; top: 4px; z-index: 1; box-shadow: var(--shadow); }
.ev { align-self: center; font-size: .74rem; color: var(--ink-3); padding: 3px 10px; margin: 4px 0; text-align: center; background: var(--glass-bg); border-radius: 999px; }
.msg { max-width: min(78%, 560px); padding: 7px 11px 5px; border-radius: 18px; background: var(--bubble-them); align-self: flex-start; box-shadow: 0 1px 1px rgba(0,0,0,.05); overflow-wrap: anywhere; position: relative; margin-top: 4px; }
.msg.cont { margin-top: 0; }
.msg.me { background: var(--bubble-me); color: var(--bubble-me-ink); align-self: flex-end; }
.msg.me a { color: #fff; }
.msg.note { background: var(--note); color: var(--note-ink); align-self: center; max-width: 86%; border: 1px dashed rgba(180,140,0,.4); }
.msg .sender { font-size: .7rem; font-weight: 700; opacity: .8; margin-bottom: 1px; }
.msg .subject { font-weight: 700; font-size: .82rem; margin-bottom: 3px; opacity: .9; }
.msg .body { white-space: pre-wrap; font-size: .93rem; line-height: 1.38; }
.msg .meta { font-size: .66rem; opacity: .7; text-align: right; margin-top: 2px; display: flex; gap: 3px; justify-content: flex-end; align-items: center; }
.msg .meta .ack { letter-spacing: -3px; margin-left: 2px; font-weight: 700; }
.msg .meta .ack-1, .msg .meta .ack-2, .msg .meta .ack-3 { opacity: .75; }
.msg .meta .ack-4, .msg .meta .ack-5 { color: #7dd3fc; opacity: 1; text-shadow: 0 0 1px #0369a1; }
.msg:not(.me) .meta .ack-4, .msg:not(.me) .meta .ack-5 { color: #0ea5e9; }
.pres { font-weight: 600; }
.pres.on { color: #16a34a; }
.msg img.media, .msg video { max-width: min(300px, 100%); max-height: 340px; border-radius: 13px; display: block; margin: 2px 0 4px; cursor: zoom-in; }
.msg img.sticker { max-width: 140px; }
.msg audio { width: 260px; max-width: 100%; height: 40px; }
.msg .doc { display: flex; gap: 8px; align-items: center; padding: 8px 10px; background: rgba(0,0,0,.06); border-radius: 12px; text-decoration: none; color: inherit; margin: 2px 0 4px; }
.msg.me .doc { background: rgba(255,255,255,.18); }
.more-btn { align-self: center; margin-bottom: 8px; }
.composer-wrap { padding: 8px 12px calc(10px + env(safe-area-inset-bottom)); background: var(--glass-bg); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); border-top: 1px solid var(--line); position: relative; }
.composer-wrap.note-mode { background: var(--note); }
.composer-tools { display: flex; gap: 4px; margin-bottom: 6px; align-items: center; flex-wrap: wrap; }
.composer-tools .seg button { padding: 4px 12px; font-size: .78rem; }
.composer { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { flex: 1; resize: none; max-height: 180px; border-radius: 20px; padding: 10px 16px; background: var(--surface); line-height: 1.35; min-height: 42px; }
.send { width: 42px; height: 42px; border-radius: 50%; padding: 0; flex: none; }
.send svg { stroke-width: 2.2; }
.file-chip { display: inline-flex; gap: 6px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; font-size: .8rem; cursor: pointer; }
.window-warn { font-size: .76rem; color: var(--warn); padding: 0 4px 6px; }
.quick-pop { position: absolute; left: 12px; right: 12px; bottom: calc(100% + 6px); max-height: 320px; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lg); z-index: 6; padding: 6px; }
.quick-item { padding: 8px 10px; border-radius: 10px; cursor: pointer; }
.quick-item.sel, .quick-item:hover { background: var(--accent-soft); }
.quick-item b { color: var(--accent); font-size: .86rem; }
.quick-item div { font-size: .8rem; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.pane-info { background: var(--surface); border-left: 1px solid var(--line); overflow-y: auto; min-height: 0; }
.info-head { padding: 22px 16px 14px; text-align: center; display: grid; justify-items: center; gap: 6px; border-bottom: 1px solid var(--line); position: relative; }
.info-head h2 { margin: 4px 0 0; font-size: 1.15rem; letter-spacing: -.02em; }
.info-head .close { position: absolute; right: 8px; top: 8px; }
.info-sec { padding: 14px 16px; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.info-sec h3 { margin: 0; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); display: flex; justify-content: space-between; align-items: center; }
.kv { display: grid; grid-template-columns: 90px 1fr; gap: 4px 10px; font-size: .86rem; margin: 0; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.tags { display: flex; gap: 5px; flex-wrap: wrap; }

/* ---------- páginas ---------- */
.page { height: 100%; display: flex; flex-direction: column; min-height: 0; }
.page-head { padding: 16px 20px 12px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 1.6rem; letter-spacing: -.03em; font-weight: 800; flex: 1; }
.page-body { flex: 1; overflow: auto; padding: 0 20px 20px; min-height: 0; }
.board { display: flex; gap: 12px; height: 100%; align-items: stretch; padding-bottom: 8px; }
.col { width: 290px; flex: none; background: var(--surface-3); border-radius: var(--radius); display: flex; flex-direction: column; max-height: 100%; }
.col.drop { outline: 2px dashed var(--accent); outline-offset: -4px; }
.col-head { padding: 12px 14px 8px; display: flex; gap: 8px; align-items: center; font-weight: 700; font-size: .9rem; }
.col-head .sw { width: 10px; height: 10px; border-radius: 50%; }
.col-list { padding: 4px 8px 10px; overflow-y: auto; display: grid; gap: 8px; align-content: start; flex: 1; min-height: 60px; }
.kcard { background: var(--surface); border-radius: 16px; padding: 10px 12px; box-shadow: var(--shadow); cursor: grab; display: grid; gap: 6px; border: 1px solid var(--line); }
.kcard:active { cursor: grabbing; }
.kcard.dragging { opacity: .4; }
.kcard .top { display: flex; gap: 8px; align-items: center; }
.kcard .top b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; }
.kcard .prev { font-size: .8rem; color: var(--ink-3); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.kcard select { min-height: 28px; padding: 2px 8px; font-size: .76rem; display: none; }
.grid-cards { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.c-card { padding: 12px 14px; display: flex; gap: 12px; align-items: center; cursor: pointer; }
.c-card:hover { border-color: var(--accent); }
.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); margin-bottom: 14px; }
.stat { padding: 16px; }
.stat .lbl { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 700; }
.stat .val { font-size: 1.9rem; font-weight: 800; letter-spacing: -.03em; margin-top: 4px; }
.stat .sub { font-size: .8rem; color: var(--ink-3); }
.two-col { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.section-card { padding: 16px; }
.section-card h2 { margin: 0 0 12px; font-size: 1rem; letter-spacing: -.01em; }
.bar-row { display: grid; grid-template-columns: 140px 1fr 44px; gap: 10px; align-items: center; font-size: .86rem; padding: 4px 0; }
.bar { height: 10px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 999px; background: var(--accent); }

/* ---------- ajustes ---------- */
.settings { display: grid; grid-template-columns: 220px 1fr; gap: 16px; height: 100%; min-height: 0; }
.settings-nav { display: grid; gap: 2px; align-content: start; }
.settings-nav button { text-align: left; border: 0; background: transparent; padding: 10px 12px; border-radius: 12px; cursor: pointer; font-weight: 600; color: var(--ink-2); display: flex; gap: 10px; align-items: center; }
.settings-nav button.on { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }
.settings-body { overflow-y: auto; min-height: 0; padding-bottom: 30px; }
.list-card { overflow: hidden; }
.list-card + .list-card { margin-top: 14px; }
.lc-head { padding: 14px 16px; display: flex; gap: 10px; align-items: center; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.lc-head h2 { margin: 0; font-size: 1rem; flex: 1; }
.lc-row { padding: 12px 16px; display: flex; gap: 12px; align-items: center; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.lc-row:last-child { border-bottom: 0; }
.lc-row .grow small { display: block; color: var(--ink-3); }
.status-pill { font-size: .72rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--surface-3); color: var(--ink-3); white-space: nowrap; }
.status-pill.conectado { background: var(--ok-soft); color: var(--ok); }
.status-pill.esperando_qr, .status-pill.conectando { background: var(--warn-soft); color: var(--warn); }
.status-pill.error { background: var(--danger-soft); color: var(--danger); }
.qr-box { display: grid; justify-items: center; gap: 8px; padding: 14px; text-align: center; width: 100%; }
.qr-box img { width: 260px; height: 260px; border-radius: 16px; background: #fff; padding: 8px; }
.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.help { font-size: .82rem; color: var(--ink-3); background: var(--surface-2); border-radius: 12px; padding: 10px 12px; line-height: 1.5; }
.help code { background: var(--surface-3); padding: 1px 5px; border-radius: 6px; font-size: .78rem; overflow-wrap: anywhere; }

/* ---------- hojas (modales) ---------- */
.sheet-back { position: fixed; inset: 0; background: rgba(10,15,30,.38); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 50; padding: 16px; animation: fade .15s; }
.sheet { width: 100%; max-width: 560px; max-height: 88dvh; overflow-y: auto; background: var(--surface); border-radius: 24px; box-shadow: var(--shadow-lg); animation: up .2s cubic-bezier(.2,.9,.3,1); }
.sheet.wide { max-width: 760px; }
.sheet-head { position: sticky; top: 0; background: var(--glass-bg); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); padding: 14px 16px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); z-index: 2; }
.sheet-head h2 { margin: 0; font-size: 1.05rem; flex: 1; letter-spacing: -.01em; }
.sheet-body { padding: 16px; display: grid; gap: 14px; }
.sheet-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 0 16px 16px; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.88); z-index: 60; display: grid; place-items: center; cursor: zoom-out; }
.lightbox img { max-width: 94vw; max-height: 92vh; border-radius: 12px; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(24px) scale(.98); opacity: 0; } }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #141414; color: #fff; padding: 11px 18px; border-radius: 14px; z-index: 70; font-size: .9rem; box-shadow: var(--shadow-lg); max-width: 92vw; }
.banner { margin: 8px 8px 0; padding: 9px 12px; border-radius: 12px; background: var(--warn-soft); color: var(--warn); font-size: .82rem; font-weight: 600; cursor: pointer; display: flex; gap: 8px; align-items: center; }

/* ---------- pantallas medianas y celular ---------- */
@media (max-width: 1180px) { .chats.with-info { grid-template-columns: var(--list) 1fr; } .chats.with-info .pane-info { position: fixed; right: 0; top: 0; bottom: 0; width: min(380px, 100vw); z-index: 30; box-shadow: var(--shadow-lg); } }
@media (max-width: 860px) {
  body { font-size: 16px; }
  .app { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .rail { order: 2; flex-direction: row; justify-content: space-around; padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line);
    background: var(--glass-bg); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); gap: 0; }
  .rail .logo, .rail .spacer { display: none; }
  .rail a { width: auto; flex: 1; font-size: .62rem; }
  .rail a.on { background: transparent; }
  .view { height: calc(100dvh - 62px - env(safe-area-inset-bottom)); }
  .app.in-chat .rail { display: none; }
  .app.in-chat .view { height: 100dvh; }
  .chats, .chats.with-info { grid-template-columns: 1fr; }
  .chats .pane-chat { display: none; }
  .chats.open .pane-list { display: none; }
  .chats.open .pane-chat { display: flex; }
  .back { display: inline-grid; }
  .messages { padding: 12px 10px; }
  .msg { max-width: 86%; }
  .head-actions .hide-m { display: none; }
  .pane-info { position: fixed !important; inset: 0 !important; width: 100% !important; z-index: 40; }
  .settings { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .settings-nav { display: flex; overflow-x: auto; gap: 4px; scrollbar-width: none; }
  .settings-nav button { white-space: nowrap; padding: 8px 12px; }
  .page-head { padding: 12px 14px 10px; }
  .page-body { padding: 0 12px 16px; }
  .col { width: 82vw; }
  .kcard select { display: block; }
  .sheet-back { place-items: end center; padding: 0; }
  .sheet { border-radius: 24px 24px 0 0; max-height: 92dvh; padding-bottom: env(safe-area-inset-bottom); }
  .bar-row { grid-template-columns: 100px 1fr 36px; }
}

/* evitar desbordes horizontales (grid/flex con textos largos) */
.app > *, .chats > *, .pane-head > *, .t-body > *, .page > *, .settings > *, .pane-chat > * { min-width: 0; }
.list, .pane-list, .messages { overflow-x: hidden; }
@media (max-width: 860px) { .chat-head .btn.sm { padding: 5px 9px; } .chat-head { gap: 6px; padding: 8px 8px; } }

/* ---------- v0.3 ---------- */
:root[data-size="grande"] body { font-size: 17px; }
:root[data-density="compacta"] .t-item { padding-top: 7px; padding-bottom: 7px; }
:root[data-density="compacta"] .t-meta { display: none; }
.pin { color: var(--accent); font-size: .8rem; }
.snooze-chip { background: var(--warn-soft); color: var(--warn); }
.ai-btn { color: #7c3aed; }
.ai-pop { position: absolute; bottom: calc(100% + 6px); right: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 6px; display: grid; gap: 2px; z-index: 20; min-width: 240px; }
.ai-pop button { border: 0; background: transparent; text-align: left; padding: 10px 12px; border-radius: 11px; cursor: pointer; display: grid; gap: 1px; }
.ai-pop button:hover { background: var(--surface-2); }
.ai-pop button small { color: var(--ink-3); }
.composer-wrap { position: relative; }
.ai-working { font-size: .8rem; color: #7c3aed; padding: 4px 14px; }
.ai-summary { white-space: pre-wrap; line-height: 1.5; font-size: .9rem; }
.team { display: grid; grid-template-columns: 280px 1fr; height: 100%; min-height: 0; }
.team-rooms { border-right: 1px solid var(--line); background: var(--surface); overflow-y: auto; padding: 10px; display: grid; align-content: start; gap: 2px; }
.team-rooms h1 { font-size: 1.5rem; margin: 6px 6px 10px; letter-spacing: -.02em; }
.room { display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: 14px; cursor: pointer; border: 0; background: transparent; text-align: left; width: 100%; }
.room:hover { background: var(--surface-2); }
.room.on { background: var(--accent-soft); }
.room .grow small { display: block; color: var(--ink-3); font-size: .74rem; }
.team-chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.team-chat .messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 2px; }
.team-chat .tm-head { padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--glass-bg); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); display: flex; gap: 10px; align-items: center; }
.msg .ticket-link { display: inline-block; margin-top: 4px; font-size: .78rem; font-weight: 700; text-decoration: underline; cursor: pointer; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatches button { width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; }
.swatches button.on { border-color: var(--ink); }
.kb-body { white-space: pre-wrap; }
.mcp-url { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem; background: var(--surface-3); padding: 10px 12px; border-radius: 12px; overflow-wrap: anywhere; user-select: all; }
@media (max-width: 860px) {
  .team { grid-template-columns: 1fr; }
  .team.open .team-rooms { display: none; }
  .team:not(.open) .team-chat { display: none; }
  .rail a { font-size: .58rem; }
}
#tabSeg button { padding: 6px 8px; font-size: .8rem; }
.composer-tools { flex-wrap: nowrap; }
.composer-tools .icon-btn { flex: none; }
@media (max-width: 860px) {
  .hide-m { display: none; }
  #tabSeg button { padding: 6px 6px; font-size: .76rem; }
  .composer-tools .seg button { padding: 4px 10px; }
}

/* ---------- v0.4 ---------- */
.draft-chip { background: rgba(124,58,237,.12); color: #7c3aed; }
.ai-sec { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); padding: 8px 12px 2px; }
.draft-card { margin: 6px 0 8px; padding: 10px 12px; border-radius: 16px; background: rgba(124,58,237,.08); border: 1px dashed rgba(124,58,237,.4); display: grid; gap: 6px; }
.draft-body { white-space: pre-wrap; font-size: .88rem; max-height: 160px; overflow-y: auto; }
.mail { display: grid; grid-template-columns: 240px 360px 1fr; height: 100%; min-height: 0; }
.mail > * { min-width: 0; min-height: 0; }
.mail-boxes { border-right: 1px solid var(--line); background: var(--surface); padding: 10px; overflow-y: auto; display: grid; align-content: start; }
.mail-boxes h1 { font-size: 1.5rem; margin: 6px 6px 12px; letter-spacing: -.02em; }
.mail-list { border-right: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; }
.mail-list .list { flex: 1; overflow-y: auto; }
.mail-item { padding: 11px 16px; border-bottom: 1px solid var(--line); cursor: pointer; display: grid; gap: 2px; }
.mail-item:hover { background: var(--surface-2); }
.mail-item.on { background: var(--accent-soft); }
.mail-item.unread b, .mail-item.unread .subj { font-weight: 800; }
.mail-item .subj { font-size: .88rem; font-weight: 600; }
.mail-read { display: flex; flex-direction: column; min-height: 0; }
.mail-head { display: flex; gap: 8px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--glass-bg); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); }
.mail-head h2 { margin: 0; font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-thread { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.mail-msg { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; display: grid; gap: 8px; box-shadow: var(--shadow); }
.mail-msg.me { border-color: var(--accent-soft); background: linear-gradient(var(--accent-soft), var(--accent-soft)), var(--surface); }
.mail-body { white-space: pre-wrap; line-height: 1.5; overflow-wrap: anywhere; }
.mail-msg .doc { display: flex; gap: 8px; align-items: center; padding: 8px 10px; background: var(--surface-3); border-radius: 12px; text-decoration: none; color: inherit; }
.mail-reply { border-top: 1px solid var(--line); padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); display: grid; gap: 8px; background: var(--surface); }
.mail-reply textarea { resize: vertical; }
.mail-read .draft-card { margin: 0 16px 8px; }
@media (max-width: 1180px) { .mail { grid-template-columns: 200px 300px 1fr; } }
@media (max-width: 860px) {
  .mail { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .mail-boxes { border-right: 0; border-bottom: 1px solid var(--line); padding: 8px; display: flex; gap: 6px; overflow-x: auto; align-items: center; }
  .mail-boxes h1 { display: none; }
  .mail-boxes #mlBoxes { display: flex !important; margin: 0 !important; gap: 6px; }
  .mail-boxes .room { width: auto; flex: none; padding: 4px 8px; }
  .mail-boxes .room .avatar, .mail-boxes .room small { display: none; }
  .mail-boxes #mlAdd { margin: 0 !important; flex: none; }
  .mail-read { display: none; }
  .mail.open .mail-list, .mail.open .mail-boxes { display: none; }
  .mail.open { grid-template-rows: 1fr; }
  .mail.open .mail-read { display: flex; }
}

/* ---------- v0.5: bandejas y selección ---------- */
.pane-boxes { display: none; background: var(--surface-2); border-right: 1px solid var(--line); overflow-y: auto; padding: 10px 8px; min-height: 0; }
@media (min-width: 1281px) {
  .chats.with-boxes { grid-template-columns: 230px var(--list) 1fr; }
  .chats.with-boxes.with-info { grid-template-columns: 230px var(--list) 1fr var(--info); }
  .chats.with-boxes .pane-boxes { display: block; }
}
@media (min-width: 1281px) and (max-width: 1560px) { .chats.with-boxes.with-info { grid-template-columns: var(--list) 1fr var(--info); } .chats.with-boxes.with-info .pane-boxes { display: none; } }
.boxes-head { display: flex; padding: 6px 8px 10px; font-size: .95rem; }
.box { display: flex; gap: 8px; align-items: center; width: 100%; border: 0; background: transparent; padding: 7px 10px; border-radius: 11px; cursor: pointer; text-align: left; font-size: .86rem; color: var(--ink); }
.box:hover { background: var(--surface-3); }
.box.on { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.box-ic { width: 18px; text-align: center; flex: none; font-size: .85rem; }
.box-n { font-size: .74rem; color: var(--ink-3); font-weight: 600; }
.box-sec { font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); padding: 14px 10px 4px; }
.box-sub { font-size: .7rem; color: var(--ink-3); padding: 8px 10px 2px 24px; }
.boxes-list { display: grid; gap: 2px; }
.t-item { position: relative; }
.t-check { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-size: .8rem; color: #fff; flex: none; align-self: center; }
.t-item.sel { background: var(--accent-soft); }
.t-item.sel .t-check { background: var(--accent); border-color: var(--accent); }
.bulk-bar { position: absolute; left: 8px; right: 8px; bottom: 10px; z-index: 5; display: flex; gap: 6px; align-items: center; padding: 8px 10px; border-radius: 16px; background: var(--glass-bg); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); box-shadow: var(--shadow-lg); border: 1px solid var(--line); }
.pane-list:has(.bulk-bar:not(.hidden)) .fab { display: none; }
#btnSelect.active, #btnBoxes.active { color: var(--accent); background: var(--accent-soft); }
#chatsTitle { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#chatsTitle.long { font-size: 1.25rem; }
.bulk-n { font-size: .9rem; white-space: nowrap; }

/* ---------- v0.6: ayuda ---------- */
.rail a .dot { position: absolute; top: 6px; right: 14px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
.help-wrap { max-width: 820px; display: grid; gap: 12px; }
.ver-card { padding: 14px 16px; display: grid; gap: 8px; }
.ver-card ul, .ver-card ol { margin: 0; padding-left: 20px; line-height: 1.6; }
.ver-tag { font-size: .74rem; font-weight: 800; padding: 3px 9px; border-radius: 999px; background: var(--surface-3); color: var(--ink-2); }
.ver-tag.new { background: var(--accent); color: #fff; }
.faq-cat { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); margin: 14px 4px 6px; }
.faq { padding: 12px 16px; margin-bottom: 8px; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq p { margin: 10px 0 2px; line-height: 1.55; color: var(--ink-2); }
.help-answer { background: var(--surface-2); border-radius: 14px; padding: 12px 14px; }
@media (max-width: 860px) { .rail a[data-view="ayuda"] { display: none; } }

/* ---------- v0.7 ---------- */
.avatar { position: relative; overflow: visible; }
.avatar > img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: inherit; object-fit: cover; }
.wait { font-size: .68rem; font-weight: 800; padding: 1px 6px; border-radius: 999px; margin-right: 6px; flex: none; white-space: nowrap; }
.wait.amber { background: var(--warn-soft); color: var(--warn); }
.wait.red { background: var(--danger-soft); color: var(--danger); }
.quote { border-left: 3px solid currentColor; opacity: .75; padding: 3px 8px; margin: 2px 0 4px; font-size: .82rem; border-radius: 6px; background: rgba(0,0,0,.05); white-space: pre-wrap; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.msg.me .quote { background: rgba(255,255,255,.15); }
.reacts { position: absolute; bottom: -12px; right: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 0 6px; font-size: .8rem; box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.msg:has(.reacts) { margin-bottom: 14px; }
.msg-acts { display: none; position: absolute; top: -16px; right: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 2px 4px; box-shadow: var(--shadow); z-index: 3; gap: 2px; }
.msg.me .msg-acts { right: auto; left: 6px; }
.msg-acts button { border: 0; background: transparent; cursor: pointer; font-size: .95rem; padding: 2px 5px; border-radius: 999px; color: var(--ink); }
.msg-acts button:hover { background: var(--surface-3); }
@media (hover: hover) { .msg[data-id]:hover .msg-acts { display: flex; } }
.msg.act .msg-acts { display: flex; }
.reply-bar { display: flex; gap: 8px; align-items: center; padding: 6px 10px; margin-bottom: 6px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 10px; }
#cMic.recording { color: #fff; background: var(--danger); animation: pulse 1.2s infinite; position: relative; }
#cMic.recording::after { content: attr(data-t); position: absolute; top: -18px; left: 50%; transform: translateX(-50%); font-size: .7rem; color: var(--danger); font-weight: 700; }
@keyframes pulse { 50% { opacity: .65; } }
.hours-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }

/* ---------- v0.8 ---------- */
.appt { display: flex; gap: 12px; align-items: center; padding: 12px 14px; margin-bottom: 8px; flex-wrap: wrap; }
.appt.cancelado { opacity: .55; }
.appt-time { font-weight: 800; font-size: 1.05rem; display: grid; min-width: 62px; }
.appt-time small { font-weight: 500; font-size: .72rem; color: var(--ink-3); }
.appt-acts { display: flex; gap: 6px; flex-wrap: wrap; }
.price-list { display: grid; gap: 6px; margin-top: 10px; max-height: 60vh; overflow-y: auto; }
.price-item { display: flex; gap: 10px; align-items: center; text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 14px; padding: 10px 12px; cursor: pointer; }
.price-item:hover { border-color: var(--accent); }
.price-item small { display: block; color: var(--ink-3); font-size: .74rem; }
.price-val { text-align: right; font-weight: 800; white-space: nowrap; }
.price-val small { color: #ea580c !important; font-weight: 700; }
.banner.info { background: var(--accent-soft); color: var(--accent); }
@media (max-width: 860px) {
  .rail { overflow-x: auto; justify-content: flex-start; scrollbar-width: none; }
  .rail::-webkit-scrollbar { display: none; }
  .rail a { flex: 0 0 auto; min-width: 62px; }
}
.composer-tools { overflow-x: auto; scrollbar-width: none; }
.composer-tools::-webkit-scrollbar { display: none; }

.price-note { color: var(--warn, #b45309); font-weight: 600; }
.price-note.bad { color: var(--danger); }

.chip.blue { background: color-mix(in srgb, #3b82f6 15%, transparent); color: #2563eb; }
.chip.green { background: color-mix(in srgb, #22c55e 15%, transparent); color: #15803d; }
.chip.amber { background: color-mix(in srgb, #f59e0b 18%, transparent); color: #b45309; }
.chip.red { background: color-mix(in srgb, #ef4444 15%, transparent); color: #b91c1c; }
.bubble-prev { white-space: pre-wrap; background: var(--surface-2); border-radius: 14px; padding: 10px 12px; margin: 6px 0; font-size: .9rem; }
#cpTags .on { outline: 2px solid var(--accent); }
.task-row.done b { text-decoration: line-through; color: var(--ink-3); }

.audio-row { display: flex; align-items: center; gap: 6px; }
.audio-row audio { max-width: 240px; height: 40px; }
.speed { border: 0; background: var(--surface-3); color: var(--ink-2); border-radius: 999px; font-size: .78rem; font-weight: 700; padding: 4px 8px; cursor: pointer; }

@media (min-width: 861px) { .gchats { grid-template-columns: minmax(300px, 380px) 1fr; } }
.gmsgs .msg-acts { display: none !important; }
