:root {
  /* WhatsApp Desktop / Web (tema claro) */
  --wa-green: #3d962c;
  --wa-green-dark: #2b721d;
  --wa-green-badge: #41bd28;
  --wa-teal: #70d65c;

  --bg-app: #ffffff;
  --bg-rail: #ffffff;
  --bg-panel: #ffffff;
  --bg-chat: #efeae2;
  --bg-hover: #f5f6f6;
  --bg-active: #f0f2f5;
  --bg-input: #f0f2f5;
  --bg-composer: #f0f2f5;

  --line: #e9edef;
  --line-2: #d1d7db;

  --text: #111b21;
  --text-2: #667781;
  --text-3: #8696a0;

  --bubble-in: #ffffff;
  --bubble-out: #d9fdd3;
  --tick-blue: #53bdeb;

  --font: "Geist", "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  font-family: var(--font);
  font-size: 14.2px;
  color: var(--text);
  background: #d1d7db;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
[hidden] { display: none !important; }

.muted { color: var(--text-2); }
.small { font-size: 12px; }

/* --------------------------- iconos Material --------------------------- */

.mi {
  font-family: "Material Symbols Outlined";
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: "liga";
  -webkit-font-smoothing: antialiased;
  font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
  user-select: none;
}
.mi.big { font-size: 34px; }
.mi.fill { font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 24; }

/* ------------------------------- login -------------------------------- */

.login {
  height: 100%;
  display: grid;
  place-items: center;
  background: #f0f2f5;
}

.login-card {
  width: min(400px, 92vw);
  background: #fff;
  border-radius: 3px;
  padding: 34px 32px 30px;
  box-shadow: 0 1px 3px rgba(11, 20, 26, .13), 0 8px 24px rgba(11, 20, 26, .08);
  display: grid;
  gap: 14px;
}

.login-logo { display: grid; justify-items: center; margin-bottom: 2px; }
.login-logo .mi { color: var(--wa-green); }

.brand-iso {
  width: 72px;
  height: 72px;
  display: block;
}
.brand-iso.sm { width: 30px; height: 30px; }
.brand-line { display: flex; align-items: center; gap: 10px; min-width: 0; }
.login-card h1 {
  margin: 0;
  text-align: center;
  font-size: 22px;
  font-weight: 500;
  color: #404040;
}
.login-card .muted { text-align: center; margin: -8px 0 8px; font-size: 13px; }
.login-card label { display: grid; gap: 6px; font-size: 12px; color: var(--text-2); }
.login-card input {
  padding: 11px 12px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: #fff;
  outline: none;
}
.login-card input:focus { border-color: var(--wa-green); }
.error { color: #ea0038; font-size: 12px; margin: 0; min-height: 14px; text-align: center; }

.btn {
  border: 1px solid var(--line-2);
  background: #fff;
  padding: 8px 14px;
  border-radius: 6px;
  font-weight: 500;
  color: var(--text);
}
.btn:hover { background: #f5f6f6; }
.btn.primary {
  background: var(--wa-green);
  border-color: var(--wa-green);
  color: #fff;
  border-radius: 24px;
  padding: 10px 18px;
}
.btn.primary:hover { background: #318321; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.small { padding: 5px 10px; font-size: 12.5px; }

/* -------------------------------- app ---------------------------------- */

.app {
  height: 100%;
  display: grid;
  grid-template-columns: 64px 400px 1fr;
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
  background: var(--bg-app);
}

.app.with-panel { grid-template-columns: 64px 400px 1fr 380px; }

/* -------------------------------- rail --------------------------------- */

.rail {
  background: var(--bg-rail);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0 12px;
}

.rail-top, .rail-bottom {
  display: grid;
  justify-items: center;
  gap: 4px;
  width: 100%;
}

/* Instancias activas, siempre visibles en el rail */
.rail-instances {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  width: 100%;
  max-height: calc(100vh - 230px);
  overflow-y: auto;
  padding: 2px 0;
  scrollbar-width: none;
}
.rail-instances::-webkit-scrollbar { display: none; }
.rail-inst {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  flex: none;
  display: grid;
  place-items: center;
}
.rail-inst .pic {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  background: #dfe5e7;
}
.rail-inst .ini {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #e7e5e4;
  color: #54656f;
  font-size: 13px;
  font-weight: 600;
}
.rail-inst .dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #b0b9be;
  border: 2px solid #fff;
  box-sizing: content-box;
}
.rail-inst.on .dot { background: var(--wa-green-badge); }
.rail-inst.active { box-shadow: 0 0 0 2px var(--wa-green); }

.rail-btn {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #54656f;
}
.rail-btn .mi { font-size: 24px; }
.rail-btn:hover { background: #f0f2f5; }
.rail-btn.active { color: #111b21; }
.rail-btn.active .mi { font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 24; }

.rail-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--wa-green-badge);
  color: #fff;
  font-size: 10.5px;
  font-weight: 600;
  display: grid;
  place-items: center;
}

.rail-profile {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #dfe5e7;
  color: #54656f;
  font-size: 12px;
  font-weight: 600;
  display: grid;
  place-items: center;
  overflow: hidden;
  margin-top: 4px;
}
.rail-profile:hover { background: #d1d7db; }

/* ------------------------------- inbox --------------------------------- */

.inbox {
  background: var(--bg-panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.inbox-head { padding: 0 0 8px; }

.inbox-title {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 0 22px;
}
.inbox-title h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  color: #404040;
  letter-spacing: -0.3px;
}

.head-actions { display: flex; align-items: center; gap: 10px; }

.icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #54656f;
}
.icon .mi { font-size: 22px; }
.icon:hover { background: #f0f2f5; }

.new-chat {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--wa-green);
  color: #fff;
  display: grid;
  place-items: center;
}
.new-chat .mi { font-size: 22px; }
.new-chat:hover { background: #318321; }

.search { position: relative; margin: 0 12px 10px; }
.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 20px;
  color: var(--text-2);
}
.search input {
  width: 100%;
  height: 35px;
  padding: 0 12px 0 38px;
  border: 0;
  border-radius: 18px;
  background: var(--bg-input);
  outline: none;
  font-size: 14.5px;
}
.search input::placeholder { color: var(--text-2); }
.search input:focus { background: #fff; box-shadow: inset 0 0 0 1px var(--line-2); }

.chips-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
}
.chips {
  display: flex;
  gap: 5px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
  min-width: 0;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  height: 32px;
  padding: 0 10px;
  border-radius: 16px;
  border: 1px solid var(--line-2);
  background: #fff;
  color: #54656f;
  font-size: 13px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.chip:hover { background: #f5f6f6; }
.chip.active {
  background: #d9fdd3;
  border-color: #d9fdd3;
  color: var(--wa-green-dark);
  font-weight: 500;
}
.chip-count { color: var(--wa-green-dark); font-size: 12.5px; }
.chip.more { width: 34px; padding: 0; justify-content: center; }
.chip.more .mi { font-size: 18px; }

.more-menu {
  position: absolute;
  top: 176px;
  right: 12px;
  z-index: 40;
  min-width: 220px;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 2px 5px rgba(11,20,26,.13), 0 8px 24px rgba(11,20,26,.13);
  padding: 6px 0;
  max-height: 60vh;
  overflow-y: auto;
}
.more-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 22px;
  font-size: 14.5px;
  color: var(--text);
}
.more-menu button:hover { background: #f5f6f6; }
.more-menu button.sel { color: var(--wa-green-dark); font-weight: 500; }
.menu-sep { height: 1px; background: var(--line); margin: 6px 0; }
.menu-label {
  padding: 6px 22px;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-3);
}

.row-archived {
  display: flex;
  align-items: center;
  gap: 18px;
  width: 100%;
  padding: 0 22px 0 18px;
  height: 52px;
  color: var(--text);
  font-size: 15px;
  border-bottom: 1px solid var(--line);
}
.row-archived .mi { font-size: 22px; color: var(--text-2); }
.row-archived em { margin-left: auto; font-style: normal; color: var(--text-2); font-size: 13px; }
.row-archived:hover { background: var(--bg-hover); }

.chat-list {
  overflow-y: auto;
  flex: 1;
  padding: 4px 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-item {
  position: relative;
  display: grid;
  grid-template-columns: 49px 1fr auto;
  align-items: center;
  gap: 15px;
  width: 100%;
  padding: 9px 10px;
  text-align: left;
  background: transparent;
  border-radius: 12px;
}
.chat-item:hover { background: var(--bg-hover); }
.chat-item.active { background: var(--bg-active); }

/* Scrollbars finas, como WhatsApp */
.chat-list::-webkit-scrollbar,
.messages::-webkit-scrollbar,
.panel-body::-webkit-scrollbar,
.search-results::-webkit-scrollbar,
.more-menu::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.chat-list::-webkit-scrollbar-thumb,
.messages::-webkit-scrollbar-thumb,
.panel-body::-webkit-scrollbar-thumb,
.search-results::-webkit-scrollbar-thumb,
.more-menu::-webkit-scrollbar-thumb {
  background: rgba(11, 20, 26, .22);
  border-radius: 3px;
}
.chat-list::-webkit-scrollbar-thumb:hover,
.messages::-webkit-scrollbar-thumb:hover,
.panel-body::-webkit-scrollbar-thumb:hover {
  background: rgba(11, 20, 26, .35);
}
.chat-list::-webkit-scrollbar-track,
.messages::-webkit-scrollbar-track,
.panel-body::-webkit-scrollbar-track,
.search-results::-webkit-scrollbar-track,
.more-menu::-webkit-scrollbar-track {
  background: transparent;
}

.avatar {
  width: 49px;
  height: 49px;
  border-radius: 50%;
  background: #dfe5e7;
  color: #54656f;
  display: grid;
  place-items: center;
  font-weight: 500;
  font-size: 15px;
  overflow: hidden;
  flex: none;
  position: relative;
}
.avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 2;
}
.avatar .mi { font-size: 26px; color: #8696a0; }
.avatar.group { background: #e7e5e4; }

.chat-main { min-width: 0; display: grid; gap: 3px; }
.chat-top { display: flex; align-items: center; gap: 6px; min-width: 0; }
.chat-name {
  flex: 1;
  min-width: 0;
  font-size: 17px;
  font-weight: 400;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-time {
  font-size: 12px;
  color: var(--text-2);
  flex: none;
}
.chat-time.on { color: var(--wa-green-dark); }

.chat-preview {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  color: var(--text-2);
  min-width: 0;
}
.chat-preview .txt {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-preview .mi { font-size: 16px; }
.chat-preview .mi.tick-blue { color: var(--tick-blue); }

.chat-meta {
  display: grid;
  gap: 6px;
  justify-items: end;
  align-content: space-between;
  height: 40px;
  padding: 1px 0;
}
.badge {
  background: var(--wa-green-badge);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  display: grid;
  place-items: center;
}
.pin { font-size: 17px; color: var(--text-3); }

.inbox-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 14px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--text-3);
  background: #fff;
}
.ws-state { display: flex; align-items: center; gap: 6px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #8696a0; flex: none; }
.dot.on { background: var(--wa-green-badge); box-shadow: 0 0 0 3px rgba(37,211,102,.16); }
.dot.off { background: #f5a623; }

/* --------------------------- resultados búsqueda ------------------------ */

.search-results {
  border-bottom: 1px solid var(--line);
  max-height: 46%;
  overflow-y: auto;
  background: #fff;
}
.sr-head {
  position: sticky;
  top: 0;
  padding: 8px 18px;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-3);
  background: #f7f8fa;
  border-bottom: 1px solid var(--line);
}
.sr-item {
  display: grid;
  gap: 3px;
  width: 100%;
  text-align: left;
  padding: 9px 18px;
  border-bottom: 1px solid #f2f3f4;
}
.sr-item:hover { background: var(--bg-hover); }
.sr-item strong { font-size: 14px; font-weight: 500; }
.sr-item span {
  font-size: 13px;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.sr-item em { font-style: normal; font-size: 11.5px; color: var(--text-3); }

.empty { padding: 30px 22px; text-align: center; color: var(--text-3); }

/* ----------------------------- conversación ---------------------------- */

.conversation {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  position: relative;
  background: var(--bg-chat);
}

.conv-placeholder {
  margin: auto;
  text-align: center;
  color: var(--text-2);
  display: grid;
  gap: 10px;
  justify-items: center;
  padding: 40px;
  max-width: 560px;
}
.ph-art { color: #d1d7db; }
.ph-art .mi { font-size: 120px; font-variation-settings: "wght" 300, "opsz" 48, "FILL" 0; }
.conv-placeholder h2 { margin: 8px 0 0; font-size: 32px; font-weight: 300; color: #41525d; }
.conv-placeholder p { margin: 0; font-size: 14px; line-height: 20px; color: #667781; }
.ph-lock { margin-top: 22px; font-size: 13px; color: #8696a0; }

.conv-wrap { display: flex; flex-direction: column; height: 100%; min-height: 0; }

.conv-head {
  display: flex;
  align-items: center;
  gap: 13px;
  height: 59px;
  padding: 0 16px 0 13px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  flex: none;
  cursor: pointer;
}
.conv-head .icon,
.conv-head .avatar { cursor: pointer; }
.head-avatar { width: 40px; height: 40px; font-size: 14px; }
.head-avatar .mi { font-size: 22px; }
.conv-title { display: grid; line-height: 1.25; min-width: 0; }
.conv-title strong {
  font-size: 16px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-title span { font-size: 13px; color: var(--text-2); }
.conv-tools { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.conv-tools .icon { width: 40px; height: 40px; }
.back { display: none; }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 6.5% 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--bg-chat);
}

.day-sep {
  align-self: center;
  background: #fff;
  color: #54656f;
  font-size: 12.5px;
  line-height: 21px;
  padding: 2px 12px;
  border-radius: 8px;
  margin: 12px 0 8px;
  box-shadow: 0 1px .5px rgba(11,20,26,.13);
}

.msg {
  position: relative;
  max-width: min(65%, 620px);
  background: var(--bubble-in);
  border-radius: 7.5px;
  padding: 5px 7px 6px 9px;
  box-shadow: 0 1px .5px rgba(11,20,26,.13);
  font-size: 14.2px;
  line-height: 19px;
  overflow-wrap: anywhere;
  margin-bottom: 2px;
  align-self: flex-start;
}
.msg.out {
  align-self: flex-end;
  background: var(--bubble-out);
}
.msg.first-in-group { margin-top: 8px; }

.msg .msg-head {
  font-size: 12.8px;
  font-weight: 500;
  color: #1f7a63;
  margin-bottom: 2px;
}
.msg .body {
  white-space: pre-wrap;
  display: block;
}
.msg .body b, .msg .body strong { font-weight: 600; }
.msg .body i, .msg .body em { font-style: italic; }
.msg .body s { text-decoration: line-through; }
.msg .body code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12.5px;
  background: rgba(0, 0, 0, .06);
  padding: 1px 4px;
  border-radius: 3px;
}
.msg .body blockquote {
  margin: 2px 0;
  padding: 2px 0 2px 10px;
  border-left: 4px solid rgba(0, 0, 0, .18);
  color: var(--text-2);
}
.msg.out .body blockquote { border-left-color: rgba(0, 0, 0, .16); }
.msg .body a { color: #027eb5; text-decoration: underline; }

.msg .spacer { display: inline-block; width: 66px; height: 0; }
.msg .foot {
  position: absolute;
  right: 7px;
  bottom: 4px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: var(--text-2);
  line-height: 15px;
  white-space: nowrap;
}
.msg .foot .mi { font-size: 16px; }
.msg .foot .mi.tick-blue { color: var(--tick-blue); }
.msg .foot .mi.tick-error { color: #ea0038; }

.msg.media-only .foot {
  background: rgba(11, 20, 26, .42);
  color: #fff;
  border-radius: 10px;
  padding: 0 6px;
  right: 8px;
  bottom: 8px;
}
.msg.media-only .foot .mi { color: #fff; }

.msg img.media, .msg video.media {
  max-width: 100%;
  max-height: 330px;
  border-radius: 6px;
  display: block;
  cursor: zoom-in;
  margin-bottom: 3px;
  background: rgba(0,0,0,.05);
}

/* Burbuja con multimedia: padding uniforme de 3px para que la imagen quede
   centrada con el mismo borde en los cuatro lados, como en WhatsApp. */
.msg.has-media {
  padding: 3px;
  max-width: min(85%, 340px);
}
.msg.has-media img.media,
.msg.has-media video.media {
  width: 100%;
  height: auto;
  max-height: 330px;
  border-radius: 5px;
  margin-bottom: 0;
  object-fit: cover;
}
/* Sin texto: la burbuja se ajusta a la imagen y mantiene su proporción. */
.msg.media-only img.media,
.msg.media-only video.media {
  width: auto;
  height: auto;
  object-fit: contain;
}
.msg.has-media .msg-head { padding: 3px 5px 0; }
.msg.has-media .body { padding: 3px 5px 4px; }
.msg.has-media .quote { margin: 3px 3px 4px; }
.msg.media-only .foot { bottom: 8px; right: 8px; }
.msg.has-media:not(.media-only) .foot { right: 9px; bottom: 5px; }
.msg.media-only,
.msg:has(> img.media),
.msg:has(> video.media) {
  max-width: min(85%, 340px);
}
.msg audio { max-width: 100%; display: block; margin-bottom: 3px; }
.msg .file {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 6px;
  background: rgba(255,255,255,.6);
  text-decoration: none;
  color: var(--text);
  font-size: 13.5px;
  margin-bottom: 3px;
}
.msg .file .mi { font-size: 20px; color: var(--text-2); }
.msg .media-ph {
  border-radius: 6px;
  background: rgba(0,0,0,.06);
  padding: 16px;
  font-size: 12px;
  color: var(--text-2);
  text-align: center;
  min-width: 150px;
  margin-bottom: 3px;
}

.msg .quote {
  border-left: 4px solid var(--wa-teal);
  background: rgba(0,0,0,.045);
  border-radius: 4px;
  padding: 5px 8px;
  margin-bottom: 4px;
  font-size: 12.8px;
  color: var(--text-2);
  max-height: 64px;
  overflow: hidden;
}
.msg .quote strong { display: block; color: var(--wa-teal); font-weight: 500; font-size: 12.8px; }

.msg .reply-btn {
  position: absolute;
  top: -12px;
  right: 8px;
  display: none;
  background: #fff;
  border-radius: 14px;
  padding: 3px 9px;
  font-size: 11px;
  color: var(--text-2);
  box-shadow: 0 1px 3px rgba(11,20,26,.2);
}
.msg:hover .reply-btn { display: block; }

.scroll-down {
  position: absolute;
  right: 22px;
  bottom: 92px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #fff;
  color: #54656f;
  display: grid;
  place-items: center;
  box-shadow: 0 1px 3px rgba(11,20,26,.24);
  z-index: 5;
}
.scroll-down .mi { font-size: 20px; }

.composer {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 8px 12px;
  background: var(--bg-composer);
  flex: none;
  position: relative;
  flex-wrap: wrap;
}
.composer .icon { color: #54656f; width: 40px; height: 40px; flex: none; }
.composer textarea {
  flex: 1;
  resize: none;
  border: 0;
  border-radius: 20px;
  padding: 9px 14px;
  max-height: 130px;
  outline: none;
  background: #fff;
  font-size: 15px;
  line-height: 20px;
}
.composer textarea::placeholder { color: var(--text-2); }
.composer .send { color: var(--wa-green-dark); }

/* Archivo pendiente de enviar (arrastrado o elegido con el clip) */
.attach-preview {
  flex: 0 0 100%;
  order: -1;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  padding: 8px 10px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(11, 20, 26, .12);
}
.attach-thumb {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  overflow: hidden;
  background: #f0f2f5;
  display: grid;
  place-items: center;
  flex: none;
}
.attach-thumb img,
.attach-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.attach-thumb .mi { font-size: 26px; color: #54656f; }
.attach-meta { display: grid; gap: 2px; min-width: 0; flex: 1; }
.attach-meta strong {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.attach-meta span { font-size: 12px; color: var(--text-2); }
#attach-remove { width: 36px; height: 36px; flex: none; }
.composer.has-attach .emoji-pop { bottom: 146px; }

/* Zona para soltar archivos */
.drop-overlay {
  position: absolute;
  inset: 12px;
  z-index: 40;
  display: grid;
  place-items: center;
  border: 2px dashed var(--wa-green);
  border-radius: 12px;
  background: rgba(239, 234, 226, .9);
  pointer-events: none;
}
.drop-card {
  display: grid;
  justify-items: center;
  gap: 6px;
  color: var(--wa-green-dark);
  text-align: center;
}
.drop-card .mi { font-size: 52px; font-variation-settings: "wght" 300; }
.drop-card strong { font-size: 17px; font-weight: 600; }
.drop-card span:last-child { font-size: 13px; color: var(--text-2); }

.emoji-pop {
  position: absolute;
  bottom: 58px;
  left: 10px;
  width: 292px;
  background: #fff;
  border-radius: 10px;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  box-shadow: 0 2px 10px rgba(11,20,26,.2);
  z-index: 20;
}
.emoji-pop button {
  font-size: 20px;
  line-height: 30px;
  height: 32px;
  border-radius: 6px;
}
.emoji-pop button:hover { background: #f0f2f5; }

.recording {
  position: absolute;
  inset: 0;
  background: var(--bg-composer);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
}
.rec-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #ea0038;
  animation: pulse 1s infinite;
}
@keyframes pulse { 50% { opacity: .25; } }

/* -------------------------------- panel -------------------------------- */

.contact-panel {
  background: #fff;
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  gap: 20px;
  height: 60px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
  flex: none;
}
.panel-head strong { font-size: 16px; font-weight: 500; }
.panel-body { overflow-y: auto; padding: 0 0 30px; display: block; }

.panel-profile {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 28px 20px 24px;
  background: #f7f8fa;
}
.panel-profile .avatar { width: 130px; height: 130px; font-size: 44px; }
.panel-profile .avatar .mi { font-size: 64px; }
.panel-profile h3 { margin: 6px 0 0; font-size: 20px; font-weight: 500; }
.panel-profile p { margin: 0; color: var(--text-2); font-size: 14px; }

.panel-card { padding: 16px 20px; border-bottom: 8px solid #f7f8fa; display: grid; gap: 10px; }
.panel-card:last-child { border-bottom: 0; }
.panel-card h4 {
  margin: 0;
  font-size: 13px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-3);
  font-weight: 500;
}

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-sm {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f0f2f5;
  border-radius: 14px;
  padding: 4px 10px;
  font-size: 13px;
  color: #3b4a54;
}
.chip-sm button { color: var(--text-3); font-size: 14px; line-height: 1; }
.chip-sm button:hover { color: #ea0038; }
.chip-sm.label-chip { background: #d9fdd3; color: var(--wa-green-dark); }

.inline-form { display: flex; gap: 8px; }
.inline-form input, .inline-form select {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 0;
  border-bottom: 1px solid var(--line-2);
  background: transparent;
  outline: none;
  font-size: 14px;
}
.inline-form input:focus, .inline-form select:focus { border-bottom-color: var(--wa-green); }

.inst-list { display: grid; max-height: 46vh; overflow-y: auto; margin: 0 -6px; }
.inst-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 6px;
  border-bottom: 1px solid var(--line);
}
.inst-row:last-child { border-bottom: 0; }
.inst-row .avatar { width: 40px; height: 40px; font-size: 13px; }
.inst-row .avatar .mi { font-size: 22px; }
.inst-info { display: grid; gap: 2px; min-width: 0; flex: 1; }
.inst-info strong {
  font-size: 14.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.inst-info span { font-size: 12px; color: var(--text-2); }

.switch {
  width: 36px;
  height: 20px;
  border-radius: 10px;
  background: #c8d0d6;
  position: relative;
  flex: none;
  transition: background .15s;
}
.switch i {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(11, 20, 26, .2);
  transition: left .15s;
}
.switch.on { background: var(--wa-green); }
.switch.on i { left: 18px; }

.note {
  background: #fff8c4;
  border-radius: 6px;
  padding: 9px 11px;
  font-size: 13px;
  display: grid;
  gap: 4px;
  box-shadow: 0 1px 2px rgba(11,20,26,.08);
}
.note .note-top { display: flex; justify-content: space-between; color: #7d7a55; font-size: 11px; }
.note button { color: #9a946b; }
.note button:hover { color: #ea0038; }

.kv { display: grid; grid-template-columns: 1fr auto; gap: 8px; font-size: 13.5px; }
.kv span:first-child { color: var(--text-2); }

/* -------------------------------- misc --------------------------------- */

.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  background: #323739;
  color: #e9edef;
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 13.5px;
  box-shadow: 0 2px 8px rgba(11,20,26,.3);
  z-index: 60;
  max-width: 80vw;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(11, 20, 26, .45);
  display: grid;
  place-items: center;
  z-index: 70;
}
.modal-card {
  background: #fff;
  border-radius: 6px;
  padding: 24px 26px;
  width: min(440px, 92vw);
  display: grid;
  gap: 16px;
  box-shadow: 0 4px 24px rgba(11,20,26,.3);
}
.modal-card h3 { margin: 0; font-size: 18px; font-weight: 500; color: var(--text); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.modal-card .field { display: grid; gap: 8px; font-size: 13px; color: var(--text-2); }
.modal-card input[type="number"] {
  padding: 9px 11px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  width: 130px;
  outline: none;
}

/* --------------------------- panel de admin ---------------------------- */

.admin-card {
  width: min(790px, 94vw);
  max-height: 88vh;
  overflow: hidden;
}
#admin-body { min-height: 0; overflow-y: auto; }
.admin-grid {
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  gap: 20px;
}
.admin-list h4,
.admin-form h4 {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--text-2);
}
.admin-users { display: grid; gap: 8px; }
.admin-user {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.admin-user .who { display: grid; gap: 1px; min-width: 0; }
.admin-user strong { font-size: 14px; font-weight: 600; }
.admin-user small { font-size: 11.5px; color: var(--text-2); }
.admin-user .chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.admin-user .chip {
  font-size: 11px;
  line-height: 17px;
  padding: 0 7px;
  border-radius: 9px;
  background: #f0f2f5;
  color: #54656f;
}
.admin-user .acts { display: flex; gap: 2px; }
.admin-user .acts .icon { width: 32px; height: 32px; }
.admin-user .acts .mi { font-size: 19px; }
.admin-form {
  display: grid;
  gap: 12px;
  align-content: start;
  border-left: 1px solid var(--line);
  padding-left: 20px;
}
.admin-form .field input {
  padding: 9px 11px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  outline: none;
  font-size: 14px;
}
.admin-form .field input:focus { border-color: var(--wa-green); }
.admin-insts { display: grid; gap: 7px; }
.admin-insts label,
.admin-form .checkline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
}
.admin-form .actions { display: flex; gap: 8px; margin-top: 2px; }
.admin-empty { margin: 0; font-size: 13px; color: var(--text-2); }
.admin-section {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
}
.admin-section h4 {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--text-2);
}
.maint-list { display: grid; gap: 6px; max-height: 130px; overflow-y: auto; }
.maint-row {
  display: grid;
  gap: 1px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.maint-row span { font-size: 13px; font-weight: 600; }
.maint-row small { font-size: 11.5px; color: var(--text-2); }
.maint-grid,
.history-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr auto;
  gap: 10px;
  align-items: end;
}
.history-grid { grid-template-columns: 1.2fr 1fr 1fr; }
.maint-grid .field input,
.history-grid .field input,
.history-grid .field select,
.maint-grid .field select {
  padding: 8px 10px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  outline: none;
  font-size: 13px;
  background: #fff;
}
.admin-section .field { display: grid; gap: 5px; font-size: 12px; color: var(--text-2); }
.admin-section .checkline { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.admin-section .actions { display: flex; gap: 8px; }
.admin-status { margin: 0; font-size: 12px; color: var(--text-2); min-height: 16px; }
.btn.danger { background: #fff; border-color: #d9534f; color: #b42318; }
.btn.danger:hover { background: #fff1f0; }
.panel-admin-actions { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }
.chip-sm.danger { color: #b42318; border-color: #f1b5b0; }
.chip-sm.danger:hover { background: #fff1f0; }
@media (max-width: 740px) {
  .admin-grid { grid-template-columns: 1fr; }
  .admin-form {
    border-left: 0;
    padding-left: 0;
    border-top: 1px solid var(--line);
    padding-top: 16px;
  }
  .maint-grid,
  .history-grid { grid-template-columns: 1fr; }
}

/* ----------------------------- responsive ------------------------------ */

@media (max-width: 1250px) {
  .app { grid-template-columns: 64px 360px 1fr; }
  .app.with-panel { grid-template-columns: 64px 360px 1fr; }
  .contact-panel {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 340px;
    z-index: 30;
    box-shadow: -2px 0 12px rgba(11, 20, 26, .15);
  }
}

@media (max-width: 980px) {
  .app { grid-template-columns: 64px 320px 1fr; }
  .app.with-panel { grid-template-columns: 64px 320px 1fr; }
}

@media (max-width: 780px) {
  .app { grid-template-columns: 1fr; }
  .rail { display: none; }
  .inbox { border-right: 0; }
  .app.show-chat .inbox { display: none; }
  .app:not(.show-chat) .conversation { display: none; }
  .back { display: grid; }
  .contact-panel { width: 100%; }
  .messages { padding: 10px 10px 6px; }
  .msg { max-width: 85%; }
}
