/* Inbox — modo claro, mobile-first.
   Estilo app de mensajería moderna: superficies blancas sobre gris frío, canales con su color,
   avatares de color, rojo de marca para lo urgente/no leído y violeta para todo lo que hace la IA. */

:root {
  --canvas: #F3F4F7;
  --surface: #FFFFFF;
  --surface-2: #F1F2F5;
  --surface-3: #E6E8ED;
  --ink: #111318;
  --ink-2: #3B404B;
  --muted: #6A7080;
  --faint: #A2A7B3;
  --line: #E9EBF0;
  --line-2: #DCDFE6;
  --accent: #E8144B;
  --accent-soft: #FDECF1;
  --ai: #6B4EFF;
  --ai-ink: #4A31CC;
  --ai-soft: #F1EEFF;
  --warn: #A85A00;
  --warn-soft: #FEF3E2;
  --ok: #0E7A55;
  --ok-soft: #E6F6EF;
  --info: #2459D6;
  --info-soft: #EAF0FE;
  --note: #FFF7E0;
  --note-ink: #6B4E00;
  --bubble-out: #1B1E25;
  --chat-bg: #EEF0F4;
  --wa: #25D366;
  --ig: linear-gradient(45deg, #F9A33A 0%, #E1306C 50%, #833AB4 100%);
  --fb: #0866FF;
  --tt: #111318;
  --em: #5B6475;
  --shadow-1: 0 1px 2px rgba(17, 19, 24, .05);
  --shadow-2: 0 2px 4px rgba(17, 19, 24, .04), 0 12px 32px rgba(17, 19, 24, .08);
  --r: 16px;
  --r-s: 12px;
  --tab-h: 66px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-brand: 'Montserrat', var(--font);
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.45;
  letter-spacing: -.006em;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss01';
  overscroll-behavior-y: none;
}
body.no-scroll { overflow: hidden; }
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; letter-spacing: inherit; }
input, textarea, select { font-size: 16px; } /* evita el zoom de iOS */
h1, h2, h3 { margin: 0; }
p { margin: 0; }
[hidden] { display: none !important; }
::selection { background: var(--ai-soft); color: var(--ai-ink); }

.ic { width: 20px; height: 20px; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mt { margin-top: 14px; }
.row { display: flex; align-items: center; }
.row.gap { gap: 10px; } .row.gap-s { gap: 2px; }
.row.end { justify-content: flex-end; } .row.between { justify-content: space-between; }
.stack { display: grid; gap: 14px; }
.stack > *, .card > *, .cards > * { min-width: 0; }
.wordmark { font-family: var(--font-brand); font-weight: 700; letter-spacing: .3em; font-size: 11px; text-transform: uppercase; }
img.logo { display: block; height: 18px; width: auto; }
img.logo.side-only { display: none; }
.boot img.logo, .login-card img.logo { height: 30px; }
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

/* ─── Botones ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 20px; border-radius: 12px; border: 1px solid var(--line-2);
  background: var(--surface); color: var(--ink); font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none;
  transition: transform .08s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease;
  box-shadow: var(--shadow-1);
}
.btn:hover { border-color: var(--faint); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary, .btn.dark { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary:hover, .btn.dark:hover { background: #2A2E37; }
.btn.danger { background: var(--accent-soft); color: var(--accent); border-color: transparent; box-shadow: none; }
.btn.ghost { background: transparent; border-color: var(--line-2); box-shadow: none; }
.btn.sm { min-height: 36px; padding: 0 13px; font-size: 13px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn .ic { width: 18px; height: 18px; }
.icon-btn {
  width: 42px; height: 42px; display: inline-grid; place-items: center; border-radius: 12px;
  border: 0; background: transparent; cursor: pointer; position: relative; flex: none; color: var(--ink-2);
  transition: background .15s;
}
.icon-btn:hover, .icon-btn:active { background: var(--surface-2); }
.icon-btn .ic { width: 21px; height: 21px; stroke-width: 1.7; }
.icon-btn .dot { position: absolute; top: 9px; right: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); }
.spinner {
  width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite; display: inline-block; opacity: .6;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Formularios ─────────────────────────────────────────────────── */
.field { display: grid; gap: 7px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field input, .field textarea, .field select, .input {
  width: 100%; min-height: 46px; padding: 11px 14px; border-radius: var(--r-s); border: 1px solid var(--line-2);
  background: var(--surface); outline: none; resize: vertical; transition: border-color .15s, box-shadow .15s;
}
.field textarea { min-height: 84px; }
.field input:focus, .field textarea:focus, .field select:focus, .input:focus { border-color: var(--ai); box-shadow: 0 0 0 3px var(--ai-soft); }
.field small { color: var(--muted); font-size: 12px; }
.switch { display: flex; gap: 12px; align-items: center; min-height: 44px; cursor: pointer; }
.switch input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; width: 44px; min-height: 0; height: 26px; padding: 0; border: 0;
  border-radius: 999px; background: var(--surface-3); position: relative; flex: none; margin: 0; cursor: pointer; transition: background .15s;
}
.switch input[type="checkbox"]::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.18); transition: transform .15s; }
.switch input[type="checkbox"]:checked { background: var(--ok); }
.switch input[type="checkbox"]:checked::after { transform: translateX(18px); }
.form-error { color: var(--accent); font-size: 14px; }

/* ─── Shell ───────────────────────────────────────────────────────── */
#app { min-height: 100%; }
.boot { min-height: 100vh; display: grid; place-content: center; gap: 20px; justify-items: center; }
.loading { display: grid; place-items: center; padding: 48px; color: var(--muted); }
#view { padding-bottom: calc(var(--tab-h) + var(--safe-b)); min-height: 100vh; overflow-x: clip; }
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(var(--tabs, 5), 1fr);
  height: calc(var(--tab-h) + var(--safe-b)); padding: 6px 4px var(--safe-b);
  background: rgba(255, 255, 255, .92); backdrop-filter: saturate(1.6) blur(18px); -webkit-backdrop-filter: saturate(1.6) blur(18px);
  border-top: 1px solid var(--line);
}
#tabs a {
  display: grid; justify-items: center; align-content: start; gap: 3px; text-decoration: none; padding-top: 2px;
  color: var(--muted); font-size: 11px; font-weight: 500; position: relative;
}
#tabs a .tab-ic { display: grid; place-items: center; width: 54px; height: 30px; border-radius: 999px; transition: background .15s; }
#tabs a .ic { width: 22px; height: 22px; stroke-width: 1.6; }
#tabs a.active { color: var(--ink); font-weight: 600; }
#tabs a.active .tab-ic { background: var(--ai-soft); color: var(--ai-ink); }
#tabs a.active .ic { stroke-width: 2; }
#tabs .tab-badge {
  position: absolute; top: 0; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: var(--accent); color: #fff; font-size: 10.5px; font-weight: 700; display: grid; place-items: center;
  border: 2px solid #fff; box-sizing: content-box;
}
.side-only { display: none; }
body.in-chat #tabs { display: none; }
body.in-chat #view { padding-bottom: 0; }
.demo-ribbon {
  position: fixed; top: var(--safe-t); left: 50%; transform: translateX(-50%); z-index: 30; background: var(--ai); color: #fff;
  font-size: 9px; font-weight: 700; letter-spacing: .18em; padding: 2px 10px; border-radius: 0 0 8px 8px; pointer-events: none;
}

.topbar {
  display: grid; gap: 2px; padding: calc(12px + var(--safe-t)) 16px 8px; position: sticky; top: 0; z-index: 5;
  background: rgba(243, 244, 247, .9); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.topbar .top-row { display: flex; align-items: center; justify-content: space-between; min-height: 34px; }
.topbar .wordmark { color: var(--ink); }
.topbar h1 { font-size: 26px; font-weight: 700; letter-spacing: -.03em; line-height: 1.15; }
.topbar .sub { font-size: 13px; color: var(--muted); }
.topbar .sub b { color: var(--accent); font-weight: 700; }
.page { padding: 6px 16px 32px; max-width: 760px; }

/* ─── Filtros (chips) ─────────────────────────────────────────────── */
.seg-scroll, .tabs-inline {
  display: flex; gap: 8px; overflow-x: auto; padding: 2px 16px 10px; scrollbar-width: none;
}
.seg-scroll::-webkit-scrollbar, .tabs-inline::-webkit-scrollbar { display: none; }
.seg {
  flex: none; display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); font-weight: 600; font-size: 13.5px;
  cursor: pointer; text-decoration: none; transition: background .15s, color .15s, border-color .15s;
}
.seg.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.seg b { font-size: 11.5px; font-weight: 600; color: var(--muted); }
.seg.on b { color: rgba(255, 255, 255, .7); }
.seg b.hot { min-width: 19px; height: 19px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 11px; }

/* ─── Bandeja ─────────────────────────────────────────────────────── */
.inbox { display: block; }
.list-pane { min-height: 100vh; }
.search {
  margin: 4px 16px 10px; display: flex; align-items: center; gap: 10px; background: var(--surface-3);
  border-radius: 12px; padding: 0 13px; border: 1px solid transparent; transition: background .15s, border-color .15s;
}
.search:focus-within { background: var(--surface); border-color: var(--line-2); }
.search .ic { color: var(--muted); width: 18px; height: 18px; }
.search input { flex: 1; border: 0; background: transparent; min-height: 42px; outline: none; }
.search input::placeholder { color: var(--muted); }

.conv-list { margin: 0; background: var(--surface); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.conv-list:has(.empty) { background: transparent; border: 0; }
.conv { display: flex; gap: 12px; padding: 12px 16px; text-decoration: none; position: relative; transition: background .12s; }
.conv + .conv::before { content: ''; position: absolute; top: 0; left: 76px; right: 0; border-top: 1px solid var(--line); }
.conv:hover { background: #FAFAFC; }
.conv:active, .conv.active { background: var(--surface-2); }
.conv.active::after { content: ''; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--ai); }
.conv-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.conv-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.conv-top .name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-top time { font-size: 12px; color: var(--faint); flex: none; font-weight: 500; }
.conv-mid { display: flex; gap: 10px; align-items: flex-start; }
.preview { color: var(--muted); font-size: 14px; line-height: 1.4; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; flex: 1; }
.conv.unread .name { font-weight: 700; }
.conv.unread .preview { color: var(--ink-2); }
.conv.unread time { color: var(--accent); font-weight: 600; }
.count { flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; margin-top: 1px; }
.conv-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-top: 5px; }
.conv-meta:empty { display: none; }
.conv-meta span {
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; background: var(--surface-2); color: var(--ink-2);
}
.conv-meta .ic { width: 12px; height: 12px; stroke-width: 2; }
.conv-meta .m-urgent { background: var(--accent-soft); color: var(--accent); }
.conv-meta .m-urgent::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.conv-meta .m-draft, .conv-meta .m-ai { background: var(--ai-soft); color: var(--ai-ink); }
.conv-meta .m-cat { background: var(--surface-2); color: var(--ink-2); }
.conv-meta .m-user { background: var(--info-soft); color: var(--info); }
.conv-meta .m-window { background: var(--warn-soft); color: var(--warn); }

/* Píldoras (resto de las pantallas) */
.pill {
  display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; background: var(--surface-2); color: var(--ink-2); white-space: nowrap;
}
.pill .ic { width: 12px; height: 12px; }
.pill.soft { background: transparent; border: 1px solid var(--line-2); color: var(--muted); }
.pill.hot { background: var(--accent); color: #fff; }
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.ai { background: var(--ai-soft); color: var(--ai-ink); }
.conv-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.conv-tags:empty { display: none; }

.avatar {
  position: relative; width: 48px; height: 48px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--av-bg, var(--surface-3)); color: var(--av-ink, var(--ink-2)); font-weight: 650; font-size: 15px; letter-spacing: .01em;
}
.avatar.sm { width: 38px; height: 38px; font-size: 13px; }
.avatar.lg { width: 64px; height: 64px; font-size: 21px; }
.ch-badge {
  position: absolute; right: -3px; bottom: -3px; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center;
  background: var(--em); color: #fff; border: 2px solid var(--surface);
}
.avatar.sm .ch-badge { width: 17px; height: 17px; right: -4px; bottom: -4px; }
.avatar.lg .ch-badge { width: 24px; height: 24px; }
.ch-badge .ic { width: 11px; height: 11px; stroke-width: 2.2; }
.ch-whatsapp { background: var(--wa); }
.ch-instagram { background: var(--ig); }
.ch-messenger { background: var(--fb); }
.ch-tiktok { background: var(--tt); }
.ch-email { background: var(--em); }
.ch-web { background: #0EA5E9; }
.ch-mercadolibre { background: #FFE600; color: #2D3277; }

.empty { padding: 64px 32px; text-align: center; display: grid; gap: 8px; color: var(--muted); justify-items: center; }
.empty strong { color: var(--ink); font-size: 17px; font-weight: 700; }
.empty p { max-width: 300px; font-size: 14px; }

/* ─── Chat ────────────────────────────────────────────────────────── */
.chat-pane { display: none; }
body.in-chat .list-pane { display: none; }
body.in-chat .chat-pane { display: block; }
.chat { display: flex; flex-direction: column; height: var(--vvh, 100dvh); background: var(--chat-bg); }
.chat-head {
  display: flex; align-items: center; gap: 2px; padding: calc(6px + var(--safe-t)) 6px 6px;
  border-bottom: 1px solid var(--line); background: var(--surface); flex: none;
}
.chat-who { flex: 1; min-width: 0; display: flex; align-items: center; gap: 11px; border: 0; background: none; text-align: left; padding: 4px; cursor: pointer; border-radius: 12px; }
.chat-who:hover { background: var(--surface-2); }
.who-text { display: grid; min-width: 0; gap: 1px; }
.who-text strong { font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.01em; }
.who-text small { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 14px; margin: 10px 12px 0;
  font-size: 13px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-s); flex: none; box-shadow: var(--shadow-1);
}
.chat-banner span { display: flex; align-items: center; gap: 7px; color: var(--ink-2); }
.chat-banner .ic { width: 16px; height: 16px; color: var(--ai); }
.chat-banner strong { display: block; font-weight: 700; }
.chat-banner p { color: var(--muted); margin-top: 2px; }
.chat-banner.hot { background: var(--accent-soft); border-color: transparent; }
.chat-banner.hot strong, .chat-banner.hot .ic { color: var(--accent); }
.chat-banner.warn { background: var(--warn-soft); border-color: transparent; }
.chat-banner.warn .ic { color: var(--warn); }
.msgs { flex: 1; overflow-y: auto; padding: 12px 12px 18px; display: flex; flex-direction: column; gap: 6px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.day { text-align: center; margin: 12px 0 6px; }
.day span { display: inline-block; font-size: 11.5px; font-weight: 600; color: var(--muted); background: rgba(255, 255, 255, .85); padding: 4px 10px; border-radius: 999px; box-shadow: var(--shadow-1); }
.older { align-self: center; margin-bottom: 8px; }

.b {
  max-width: min(82%, 540px); padding: 8px 12px 6px; border-radius: 18px; position: relative; display: grid; gap: 3px;
  word-wrap: break-word; overflow-wrap: anywhere; font-size: 15px; line-height: 1.42;
}
.b.in { align-self: flex-start; background: var(--surface); border-bottom-left-radius: 6px; box-shadow: var(--shadow-1); }
.b.out { align-self: flex-end; background: var(--bubble-out); color: #fff; border-bottom-right-radius: 6px; cursor: pointer; }
.b.out.s-ai { background: var(--ai-soft); color: var(--ink); box-shadow: inset 0 0 0 1px rgba(107, 78, 255, .12); }
.b.out.s-automation, .b.out.s-broadcast, .b.out.s-system { background: var(--info-soft); color: var(--ink); }
.b .by { font-size: 11px; font-weight: 700; letter-spacing: .02em; opacity: .65; display: flex; align-items: center; gap: 4px; }
.b .by .ic { width: 12px; height: 12px; }
.b.s-ai .by { color: var(--ai-ink); opacity: 1; }
.b.s-automation .by, .b.s-broadcast .by { color: var(--info); opacity: 1; }
.b .t a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.b .meta { justify-self: end; display: flex; align-items: center; gap: 4px; font-size: 10.5px; opacity: .55; font-weight: 500; }
.b .st .ic { width: 14px; height: 14px; }
.b .st.read { opacity: 1; color: #53BDEB; }
.b.s-ai .st.read, .b.s-automation .st.read { color: var(--info); }
.b .st.failed { color: var(--accent); opacity: 1; }
.b .err { font-size: 12px; color: var(--accent); background: var(--accent-soft); padding: 5px 9px; border-radius: 9px; }
.b .ref { font-size: 11px; opacity: .6; font-style: italic; }
.b .subj { font-size: 12px; font-weight: 700; opacity: .7; }
.b.reaction { background: transparent !important; border: 0 !important; box-shadow: none !important; font-size: 28px; padding: 0 4px; }
.media { max-width: 100%; border-radius: 12px; display: block; }
img.media { max-height: 320px; object-fit: cover; cursor: zoom-in; background: var(--surface-2); min-height: 60px; }
img.media.sticker { max-width: 140px; background: transparent; }
audio.media { width: 240px; max-width: 100%; }
.file { display: inline-flex; gap: 6px; align-items: center; font-weight: 600; font-size: 14px; }
.note { align-self: center; max-width: 90%; font-size: 12px; color: var(--muted); text-align: center; padding: 5px 10px; margin: 4px 0; line-height: 1.4; background: rgba(255, 255, 255, .7); border-radius: 10px; }
.note time { margin-left: 6px; color: var(--faint); }
.note.internal {
  background: var(--note); color: var(--note-ink); text-align: left; align-self: stretch; max-width: 100%;
  padding: 9px 12px; border-radius: var(--r-s); font-size: 13px; box-shadow: inset 0 0 0 1px rgba(168, 120, 0, .14);
}
.note.internal b { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; }
.note .ic { width: 13px; height: 13px; }

.draft { padding: 0 12px 8px; flex: none; }
.draft-card { border: 1px solid rgba(107, 78, 255, .25); border-radius: var(--r); padding: 12px 13px; display: grid; gap: 9px; background: var(--surface); box-shadow: var(--shadow-2); }
.draft-card strong { display: flex; gap: 6px; align-items: center; font-size: 13px; font-weight: 700; color: var(--ai-ink); }
.draft-card strong .ic { color: var(--ai); }
.draft-card textarea { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--ai-soft); resize: none; outline: none; }
.draft-card textarea:focus { border-color: var(--ai); }

.composer { flex: none; border-top: 1px solid var(--line); background: var(--surface); padding: 8px 8px calc(8px + var(--safe-b)); }
.compose-row { display: flex; align-items: flex-end; gap: 4px; }
.compose-row textarea {
  flex: 1; min-height: 44px; max-height: 160px; padding: 11px 16px; border-radius: 22px; border: 1px solid transparent;
  background: var(--surface-2); resize: none; outline: none; line-height: 1.35; scrollbar-width: none;
}
.compose-row textarea::-webkit-scrollbar { display: none; }
.compose-row textarea::placeholder { color: var(--muted); }
.compose-row textarea:focus { background: var(--surface); border-color: var(--line-2); }
.compose-row textarea:disabled { opacity: .55; }
.compose-row.note-mode textarea { background: var(--note); color: var(--note-ink); }
.compose-row .icon-btn { border-radius: 50%; }
.send { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--ink); color: #fff; display: grid; place-items: center; cursor: pointer; flex: none; transition: transform .08s, background .15s; }
.send:active { transform: scale(.94); }
.send .ic { width: 19px; height: 19px; }
.send:disabled { background: var(--surface-3); color: var(--faint); }
.send .spinner { width: 16px; height: 16px; }
.compose-row.with-mic.is-empty [data-act="send"], .compose-row.with-mic:not(.is-empty) [data-act="record"] { display: none; }
.rec-row { align-items: center; }
.rec-row [data-act="rec-cancel"] { color: var(--accent); }
.rec-status { flex: 1; min-height: 44px; display: flex; align-items: center; gap: 10px; padding: 0 16px; border-radius: 22px; background: var(--accent-soft); font-variant-numeric: tabular-nums; }
.rec-status #rec-time { font-weight: 600; }
.rec-hint { color: var(--muted); font-size: 13px; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); flex: none; animation: rec-pulse 1.2s ease-in-out infinite; }
@keyframes rec-pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .rec-dot { animation: none; } }
.win-closed { display: flex; align-items: center; gap: 10px; font-size: 13px; padding: 8px 10px; margin: 0 0 8px; color: var(--warn); background: var(--warn-soft); border-radius: 12px; }
.win-closed span { flex: 1; }
.win-closed.soft { color: var(--muted); background: var(--surface-2); }
.win-closed .ic { color: currentColor; }
.qr-pop { margin: 0 12px 6px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow-2); overflow: hidden; flex: none; }
.qr-pop button { display: flex; gap: 10px; width: 100%; text-align: left; padding: 12px 14px; border: 0; background: none; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 14px; }
.qr-pop button:hover { background: var(--surface-2); }
.qr-pop button:last-child { border-bottom: 0; }
.qr-pop b { font-weight: 700; color: var(--ai-ink); }
.chat-empty { height: 100%; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--faint); }
.chat-empty .ic { width: 40px; height: 40px; stroke-width: 1.2; }

/* ─── Hojas ───────────────────────────────────────────────────────── */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; }
.sheet-bg { position: absolute; inset: 0; background: rgba(17, 19, 24, .36); opacity: 0; transition: opacity .2s; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: calc(var(--vvh, 100dvh) - 40px); background: var(--surface);
  border-radius: 22px 22px 0 0; display: flex; flex-direction: column; transform: translateY(100%); transition: transform .24s cubic-bezier(.2, .8, .2, 1);
  padding-bottom: var(--safe-b); box-shadow: 0 -10px 40px rgba(17, 19, 24, .14);
}
.sheet.full { height: calc(var(--vvh, 100dvh) - 24px - var(--safe-t)); }
.sheet-wrap.in .sheet-bg { opacity: 1; }
.sheet-wrap.in .sheet { transform: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 8px 8px 20px; position: relative; flex: none; }
.sheet-head h2 { font-size: 18px; font-weight: 700; letter-spacing: -.02em; }
.grab { position: absolute; top: 7px; left: 50%; transform: translateX(-50%); width: 38px; height: 5px; border-radius: 5px; background: var(--line-2); }
.sheet-body { overflow-y: auto; padding: 6px 20px 22px; -webkit-overflow-scrolling: touch; }
.action-list { display: grid; gap: 2px; }
.action {
  display: flex; align-items: center; gap: 14px; min-height: 52px; padding: 10px 10px; border: 0; border-radius: 12px;
  background: none; text-align: left; cursor: pointer; font-size: 15px; font-weight: 500; transition: background .12s;
}
.action:hover, .action:active { background: var(--surface-2); }
.action .ic { color: var(--ink-2); stroke-width: 1.7; }
.action > span { flex: 1; }
.action small { margin-left: auto; color: var(--muted); font-size: 12px; text-align: right; max-width: 45%; }
.action.col { flex-direction: column; align-items: flex-start; gap: 4px; }
.action.col small { margin: 0; font-size: 13px; line-height: 1.4; max-width: none; text-align: left; }
.action.danger, .action.danger .ic { color: var(--accent); }
.action.on > span { font-weight: 700; }
.action.on { background: var(--ai-soft); }
img.zoomed { width: 100%; border-radius: var(--r-s); }
.tpl-preview { background: #E7F8EE; border-radius: var(--r-s); padding: 13px 14px; font-size: 14px; margin-bottom: 14px; white-space: pre-wrap; box-shadow: var(--shadow-1); }

/* ─── Tarjetas y secciones ────────────────────────────────────────── */
.card { border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: grid; gap: 10px; background: var(--surface); box-shadow: var(--shadow-1); }
.card.soft { background: var(--surface); }
.card h3 { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 9px; letter-spacing: -.01em; }
.card h3 .ic { width: 18px; height: 18px; stroke-width: 1.8; color: var(--ai); }
.cards { display: grid; gap: 10px; }
h3.sub { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 24px 4px 10px; font-weight: 700; }
.contact-head { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }
.contact-head > div { display: grid; }
.order { border-top: 1px solid var(--line); padding: 12px 0; display: grid; gap: 6px; font-size: 14px; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kpi { background: var(--surface-2); border-radius: var(--r-s); padding: 12px; display: grid; gap: 2px; }
.kpi:nth-child(1) { background: var(--ai-soft); }
.kpi:nth-child(2) { background: var(--ok-soft); }
.kpi:nth-child(3) { background: var(--accent-soft); }
.kpi b { font-size: 24px; font-weight: 700; letter-spacing: -.03em; }
.kpi span { font-size: 11px; color: var(--muted); font-weight: 600; }
.bar { height: 6px; background: var(--surface-3); border-radius: 6px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--ai); border-radius: 6px; }
.k-item { border: 1px solid var(--line); border-radius: var(--r); padding: 14px 15px; display: grid; gap: 7px; cursor: pointer; background: var(--surface); text-align: left; width: 100%; box-shadow: var(--shadow-1); transition: border-color .15s; }
.k-item:hover { border-color: var(--line-2); }
.k-item.draft { border-style: dashed; border-color: var(--line-2); box-shadow: none; background: #FCFCFD; }
.k-item .k-top { display: flex; gap: 6px; align-items: center; }
.k-item .k-top small { margin-left: auto; }
.k-item strong { font-size: 14.5px; font-weight: 700; }
.k-item p { font-size: 13px; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.k-item q { font-size: 12px; color: var(--muted); font-style: italic; }
.fab {
  position: fixed; right: 16px; bottom: calc(var(--tab-h) + var(--safe-b) + 16px); z-index: 15; height: 52px; padding: 0 22px;
  border-radius: 16px; border: 0; background: var(--ink); color: #fff; font-weight: 600; display: flex; align-items: center; gap: 8px;
  box-shadow: 0 10px 30px rgba(17, 19, 24, .24); cursor: pointer;
}
.test-chat { display: grid; gap: 6px; padding: 14px; background: var(--chat-bg); border-radius: var(--r); min-height: 120px; }
.test-chat .b { max-width: 90%; }
.decision { border-radius: var(--r-s); padding: 13px; display: grid; gap: 6px; font-size: 13px; border: 1px solid var(--line); background: var(--surface); }
.decision.responder { background: var(--ok-soft); border-color: transparent; }
.decision.derivar { background: var(--accent-soft); border-color: transparent; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 5px 14px; font-size: 13px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: var(--surface-2); padding: 3px 7px; border-radius: 6px; overflow-wrap: anywhere; }
.steps { margin: 0; padding-left: 18px; display: grid; gap: 7px; font-size: 14px; color: var(--ink-2); }
details summary { cursor: pointer; padding: 4px 0; }
.hours-grid { display: grid; grid-template-columns: 78px minmax(0, 1fr) minmax(0, 1fr); gap: 8px; align-items: center; }
.hours-grid input { min-height: 42px; padding: 6px 8px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface); min-width: 0; width: 100%; }
.chip-select { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-select button { min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); font-size: 13px; font-weight: 600; cursor: pointer; color: var(--ink-2); }
.chip-select button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.list-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.list-row > .ic { color: var(--ink-2); stroke-width: 1.7; }
.list-row .grow { flex: 1; min-width: 0; display: grid; gap: 1px; }
.list-row .grow b { font-weight: 600; }
.list-row .grow small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ─── Login ───────────────────────────────────────────────────────── */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1200px 500px at 50% -10%, var(--ai-soft), transparent 60%), var(--canvas);
}
.login-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 34px 26px 28px; display: grid; gap: 8px; box-shadow: var(--shadow-2); }
.login-card h1 { font-size: 26px; font-weight: 700; letter-spacing: -.03em; margin-top: 24px; }
.login-card form { display: grid; gap: 16px; margin-top: 22px; }

/* ─── Toasts ──────────────────────────────────────────────────────── */
#toasts { position: fixed; left: 16px; right: 16px; top: calc(12px + var(--safe-t)); z-index: 80; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast {
  background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 14px; font-size: 14px; font-weight: 500; max-width: 440px;
  box-shadow: var(--shadow-2); transform: translateY(-12px); opacity: 0; transition: all .2s ease;
}
.toast.in { transform: none; opacity: 1; }
.toast.error { background: var(--accent); }
.toast.ok { background: var(--ok); }

/* ─── Escritorio ──────────────────────────────────────────────────── */
@media (min-width: 960px) {
  #view { padding: 0 0 0 236px; min-height: 100vh; }
  #tabs {
    top: 0; right: auto; width: 236px; height: 100vh; grid-template-columns: 1fr; grid-auto-rows: 46px; align-content: start;
    border-top: 0; border-right: 1px solid var(--line); padding: 24px 12px; gap: 4px; background: var(--surface);
  }
  #tabs a { grid-auto-flow: column; justify-content: start; align-content: center; gap: 10px; font-size: 14px; font-weight: 500; padding: 0 8px; border-radius: 12px; color: var(--ink-2); }
  #tabs a:hover { background: var(--surface-2); }
  #tabs a .tab-ic { width: 30px; height: 30px; border-radius: 9px; }
  #tabs a .ic { width: 19px; height: 19px; }
  #tabs a.active { background: var(--ai-soft); color: var(--ai-ink); }
  #tabs a.active .tab-ic { background: transparent; }
  #tabs .tab-badge { position: static; margin-left: auto; border: 0; }
  .side-only { display: block; padding: 4px 10px 24px; }
  img.side-only.logo { display: block; padding: 6px 10px 24px; height: 20px; box-sizing: content-box; }
  .topbar .wordmark, .topbar img.logo { visibility: hidden; } /* ya está en la barra lateral */
  body.in-chat #tabs { display: grid; }
  body.in-chat #view { padding-left: 236px; }
  .inbox { display: grid; grid-template-columns: 400px 1fr; height: 100vh; }
  .list-pane { border-right: 1px solid var(--line); overflow-y: auto; height: 100vh; min-height: 0; background: var(--surface); }
  .list-pane .topbar { background: rgba(255, 255, 255, .92); }
  .list-pane .conv-list { border: 0; }
  .list-pane .search { background: var(--surface-2); }
  body.in-chat .list-pane { display: block; }
  .chat-pane { display: block; height: 100vh; }
  .chat { height: 100vh; }
  .chat-head .back { display: none; }
  .msgs { padding: 18px 28px; }
  .sheet { left: 50%; right: auto; width: 540px; transform: translate(-50%, 100%); bottom: 0; }
  .sheet-wrap.in .sheet { transform: translate(-50%, 0); }
  .fab { bottom: 28px; right: 28px; }
  .page { padding: 6px 28px 48px; }
  .topbar { padding-left: 28px; padding-right: 28px; padding-top: 26px; }
  .seg-scroll, .tabs-inline { padding: 2px 28px 12px; }
  .search { margin-left: 28px; margin-right: 28px; }
}

/* ─── Comprobante de transferencia (en el chat) ───────────────────── */
.rcpt { display: grid; gap: 4px; background: var(--surface-2); border-radius: 12px; padding: 10px 11px; margin-top: 4px; min-width: 220px; }
.rcpt-top { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.rcpt-top .ic { width: 16px; height: 16px; color: var(--ok); }
.rcpt-top span { margin-left: auto; font-weight: 700; font-size: 15px; }
.rcpt small { color: var(--muted); font-size: 12px; }
.rcpt-match { font-size: 12.5px; font-weight: 600; color: var(--ok); }
.rcpt.monto_distinto .rcpt-match, .rcpt.monto_distinto .rcpt-top .ic { color: var(--warn); }
.rcpt.sin_pedido .rcpt-match, .rcpt.sin_pedido .rcpt-top .ic { color: var(--muted); }
.rcpt .btn { justify-self: start; margin-top: 4px; }
.rcpt-paid { display: flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 700; color: var(--ok); }
.rcpt-paid .ic { width: 15px; height: 15px; }
.rcpt .rcpt-why { color: var(--warn); }

/* Herramientas del chat: cambio o devolución, stock por talle y recomendador de talle */
.row.wrap { flex-wrap: wrap; }
.field.grow { flex: 1; min-width: 0; }
.tool-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 8px 0; }
.chip { display: inline-flex; align-items: center; gap: 5px; min-height: 32px; padding: 0 11px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); font-size: 13px; font-weight: 600; }
.chip .ic { width: 15px; height: 15px; }
.chip.ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.chip.off { color: var(--faint); text-decoration: line-through; background: var(--surface-2); border-color: transparent; }
.pol-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.pol { display: grid; gap: 2px; padding: 12px 14px; border-radius: 14px; background: var(--surface-2); }
.pol small { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.pol b { font-size: 22px; font-weight: 700; }
.pol span { color: var(--muted); font-size: 12.5px; }
.pol-list { margin: 12px 0; padding-left: 18px; display: grid; gap: 5px; font-size: 13px; color: var(--ink-2); }
.pol-list .warn-t { color: var(--warn); }
.stock { padding: 12px 0; border-top: 1px solid var(--line); }
.stock:first-child { border-top: 0; }
.stock a { display: inline-flex; align-items: center; gap: 4px; color: var(--info); }
.stock a .ic { width: 14px; height: 14px; }
.size-card { margin-top: 12px; display: grid; gap: 10px; }
.size-card .tpl-preview { margin: 0; }
.size-big { font-size: 44px; font-weight: 800; line-height: 1; }
