:root {
  --bg: #0B1016;
  --card: #111821;
  --card-raised: #18212C;
  --border: #253140;
  --border-strong: #344256;
  --text: #F1F5F9;
  --text-secondary: #A3AFBF;
  --text-tertiary: #697789;
  --accent: #8FA6C1;
  --accent-hover: #A9BDD3;
  --accent-glow: rgba(143, 166, 193, 0.09);
  --accent-light: #C5D3E1;
  --green: #45C486;
  --yellow: #E6B95C;
  --red: #EC6A70;
  --msg-client: #1A2430;
  --msg-own: #DCE6F0;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  letter-spacing: -0.005em;
  height: 100vh;
  overflow: hidden;
}

.app { display: block; height: 100vh; }

/* ---------- Sidebar (same operational console as Administración) ---------- */
.top-bar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 232px;
  height: 100vh;
  padding: 20px 14px;
  background: #0E151D;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 0;
  z-index: 20;
}
.top-left { display: flex; align-items: center; gap: 9px; padding: 0 4px; min-width: 0; }
.back-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.2s;
  flex-shrink: 0;
}
.back-btn:hover { background: #16202B; border-color: var(--border); color: var(--text); }
.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: #DCE6F0;
  background: #18222E;
  border: 1px solid #2A394A;
  border-radius: 7px;
  flex-shrink: 0;
}
.brand-copy { min-width: 0; line-height: 1.1; }
.brand-copy > span {
  display: block;
  color: var(--text-tertiary);
  font-size: 0.63rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 3px;
}
.brand-copy h1 { font-size: 0.92rem; font-weight: 650; letter-spacing: -0.01em; }

.admin-tabs {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 5px;
  margin-top: 30px;
}
.admin-tab {
  width: 100%;
  min-height: 54px;
  padding: 9px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  text-align: left;
  font-family: inherit;
  font-size: 0.83rem;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.admin-tab svg { flex: 0 0 auto; color: #7F8EA0; }
.admin-tab span { display: flex; flex-direction: column; gap: 2px; }
.admin-tab strong { color: inherit; font-size: 0.8rem; font-weight: 600; }
.admin-tab small { color: var(--text-tertiary); font-size: 0.66rem; font-weight: 400; }
.admin-tab:hover { color: var(--text); background: #131C26; border-color: #202C39; }
.admin-tab.active {
  color: var(--text);
  background: #1A2430;
  border-color: #2C3A4A;
  box-shadow: inset 3px 0 0 #91A8C0;
}
.admin-tab.active svg { color: #B9C9D9; }

.top-right {
  margin-top: auto;
  padding: 14px 5px 2px;
  border-top: 1px solid #202B38;
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  gap: 8px;
}
.sidebar-agent-row { display: flex; align-items: center; gap: 6px; width: 100%; }
.sidebar-agent-row .agent-wrap { flex: 1; min-width: 0; }

.env-indicator {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 550;
}
.env-indicator i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--yellow);
  box-shadow: 0 0 0 3px rgba(230, 185, 92, 0.1);
}
.env-indicator.live i {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.14);
}
.env-note { color: var(--text-tertiary); font-size: 0.66rem; }

.icon-btn {
  position: relative;
  background: #141C25;
  border: 1px solid #2B3745;
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: 5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}
.icon-btn:hover { background: #1B2632; border-color: #4A5B70; color: #F4F7FA; }
.notif-dot {
  position: absolute;
  top: 4px;
  right: 5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--red);
  border: 1.5px solid #0E151D;
}

.agent-chip {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  background: #141C25;
  border: 1px solid #2B3745;
  color: var(--text);
  padding: 0.35rem 0.55rem 0.35rem 0.35rem;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.agent-chip:hover { background: #1B2632; border-color: #4A5B70; }
.agent-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #26384B;
  border: 1px solid #40556C;
  color: #E5EDF5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.78rem;
  flex-shrink: 0;
}
.agent-info { display: flex; flex-direction: column; align-items: flex-start; gap: 0.1rem; min-width: 0; }
.agent-name { font-size: 0.8rem; font-weight: 600; line-height: 1; }
.agent-presence { display: flex; align-items: center; gap: 0.3rem; font-size: 0.65rem; color: var(--text-secondary); line-height: 1; }
.agent-chip > svg { margin-left: auto; flex-shrink: 0; color: var(--text-tertiary); }

.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.dot.animated { animation: pulse 2s infinite; }
.dot-sm { width: 6px; height: 6px; }
.dot.green { background: var(--green); }
.dot.yellow { background: var(--yellow); }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.45} }

/* ---------- Popovers ---------- */
.popover-wrap { position: relative; }
.popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 400;
  min-width: 224px;
  padding: 5px;
  background: #18212C;
  border: 1px solid #334153;
  border-radius: 7px;
  box-shadow: 0 18px 40px rgba(0,0,0,.55);
  overflow: hidden;
}
.popover.up { top: auto; bottom: calc(100% + 8px); right: auto; left: 0; min-width: 200px; }
.agent-wrap .popover.up { left: auto; right: 0; }
.popover-title {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  padding: 0.5rem 0.65rem 0.35rem;
}
.popover-body { padding: 0 0.2rem 0.2rem; max-height: 220px; overflow-y: auto; }
.popover-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  min-height: 32px;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 0.77rem;
  padding: 0.42rem 0.55rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
}
.popover-item:hover { background: #222E3B; }
.popover-item.danger { color: var(--red); }
.popover-sep { height: 1px; background: var(--border); margin: 0.3rem 0.2rem; }
.notif-empty, .notif-line { font-size: 0.78rem; padding: 0.5rem 0.65rem; color: var(--text-secondary); }
.notif-line strong { color: var(--text); }

/* ---------- Buttons ---------- */
.btn {
  background: #141C25;
  border: 1px solid #2B3745;
  color: #D6DEE7;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 540;
  padding: 0.5rem 0.85rem;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.btn:hover { background: #1B2632; border-color: #4A5B70; color: #F4F7FA; }
.btn.primary { background: #DCE6F0; border-color: #DCE6F0; color: #10161D; font-weight: 620; }
.btn.primary:hover { background: #F0F5F9; border-color: #F0F5F9; color: #0A0F14; }
.btn.danger { color: #F08A8F; }
.btn.sm { padding: 0.35rem 0.6rem; font-size: 0.72rem; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- Content ---------- */
.content {
  margin-left: 232px;
  height: 100vh;
  padding: 24px 28px 26px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- Stats grid (same strip as Administración) ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0;
  margin-bottom: 14px;
  background: #101720;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
}
.stat-card {
  min-height: 88px;
  background: transparent;
  border: 0;
  border-right: 1px solid var(--border);
  border-radius: 0;
  padding: 15px 18px;
}
.stat-card:last-child { border-right: 0; }
.stat-card .stat-label {
  color: #7D8999;
  font-size: 0.64rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 6px;
}
.stat-card .stat-val { font-size: 1.42rem; font-weight: 620; letter-spacing: -0.02em; }
.stat-card .stat-val.good { color: var(--green); }
.stat-card .stat-val.warn { color: var(--yellow); }
.stat-card .stat-val.danger { color: var(--red); }

/* ---------- 3-column layout ---------- */
.main-layout {
  display: grid;
  grid-template-columns: var(--conv-width, 300px) 8px minmax(360px, 1fr) 8px var(--context-width, 340px);
  flex: 1;
  min-height: 0;
}

.col-resizer {
  position: relative;
  cursor: col-resize;
  z-index: 5;
}
.col-resizer::after {
  content: '';
  position: absolute;
  top: 8%;
  bottom: 8%;
  left: 50%;
  width: 2px;
  border-radius: 2px;
  background: transparent;
  transform: translateX(-50%);
  transition: background 0.15s;
}
.col-resizer:hover::after { background: #2B3745; }
.col-resizer.dragging::after { background: #4A5B70; }
body.col-resizing { cursor: col-resize; }
body.col-resizing * { user-select: none; }

.panel {
  position: relative;
  background: #101821;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.panel-head {
  min-height: 45px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.panel-title { font-size: 0.82rem; font-weight: 620; }
.panel-count {
  min-width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  color: #C5D0DC;
  background: #18222C;
  border: 1px solid #2A3848;
  border-radius: 99px;
  font-size: 0.65rem;
  font-weight: 650;
  padding: 0 6px;
}

/* ---------- Conversation list ---------- */
.search-box-wrap { position: relative; margin: 10px 12px 0; flex-shrink: 0; }
.search-box-icon {
  position: absolute;
  left: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  pointer-events: none;
}
.search-box {
  min-height: 34px;
  background: #080D12;
  border: 1px solid #202B38;
  border-radius: 5px;
  padding: 0.48rem 0.72rem 0.48rem 2.05rem;
  color: var(--text);
  font-size: 0.82rem;
  outline: none;
  width: 100%;
  font-family: inherit;
}
.search-box:focus { border-color: #50647B; box-shadow: 0 0 0 2px rgba(143,166,193,.08); }

.conv-list { flex: 1; overflow-y: auto; padding: 8px; }

.conv-item {
  padding: 10px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 3px;
  transition: background 0.12s, border-color 0.12s;
  display: flex;
  gap: 0.65rem;
}
.conv-item:hover { background: #17212B; }
.conv-item.active {
  background: #1A2430;
  border-color: #2C3A4A;
  box-shadow: inset 3px 0 0 #91A8C0;
}
.conv-item.priority-alta .conv-list-avatar { box-shadow: 0 0 0 2px var(--red); }

.conv-list-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #E5EDF5;
  border: 1px solid rgba(255,255,255,.07);
  font-weight: 700;
  font-size: 0.72rem;
  position: relative;
}
.conv-list-online {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  border: 2px solid #101821;
}

.conv-item-body { flex: 1; min-width: 0; }
.conv-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 0.15rem; gap: 0.5rem; }
.conv-name {
  font-weight: 590;
  font-size: 0.82rem;
  color: #ECF2F8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-item:not(.is-unread) .conv-name { font-weight: 500; color: #C9D3DD; }
.conv-empresa {
  font-size: 0.68rem;
  color: #91A5BA;
  margin-top: 0.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-time { font-size: 0.66rem; color: var(--text-tertiary); flex-shrink: 0; white-space: nowrap; }
.conv-preview {
  font-size: 0.76rem;
  color: #718095;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-item.is-unread .conv-preview { color: var(--text); }
.conv-meta { display: flex; align-items: center; gap: 0.35rem; margin-top: 0.35rem; flex-wrap: wrap; }

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.6rem;
  font-weight: 580;
  padding: 0.16rem 0.42rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
  background: #18212B;
  color: #AAB6C5;
  border: 1px solid #2B3744;
}
.badge.unread { background: var(--red); border-color: var(--red); color: #10161D; font-weight: 700; }
.badge.priority { background: rgba(236,106,112,.1); color: var(--red); border-color: rgba(236,106,112,.28); }
.badge.tag { background: rgba(143,166,193,.1); color: var(--accent-light); border-color: rgba(143,166,193,.25); }
.badge.status-pendiente { background: rgba(230,185,92,.1); color: var(--yellow); border-color: rgba(230,185,92,.25); }

/* ---------- Chat ---------- */
.chat-panel { min-width: 0; }

.chat-head {
  min-height: 57px;
  padding: 0.5rem 16px;
  background: #131B24;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-shrink: 0;
}
.chat-user { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }
.avatar-wrap { position: relative; flex-shrink: 0; }
.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #26384B;
  border: 1px solid #40556C;
  color: #E5EDF5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.presence-indicator {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  border: 2px solid #131B24;
}
.chat-user-info { min-width: 0; }
.chat-user-info h3 {
  font-size: 0.92rem;
  font-weight: 620;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-user-info p {
  font-size: 0.73rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-head-actions { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }

.assign-chip {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: #141C25;
  border: 1px solid #2B3745;
  color: #D6DEE7;
  padding: 0.42rem 0.65rem;
  border-radius: 5px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 540;
  transition: all 0.15s;
}
.assign-chip:hover { background: #1B2632; border-color: #4A5B70; color: #F4F7FA; }

.status-select {
  background: #141C25;
  border: 1px solid #2B3745;
  color: #D6DEE7;
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 540;
  padding: 0.42rem 0.55rem;
  border-radius: 5px;
  cursor: pointer;
  outline: none;
}
.status-select:focus { border-color: #5B7189; box-shadow: 0 0 0 2px rgba(143,166,193,.08); }

.sla-banner {
  padding: 0.5rem 16px;
  font-size: 0.74rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}
.sla-banner.ok { background: rgba(69,196,134,.07); color: var(--green); }
.sla-banner.warn { background: rgba(230,185,92,.08); color: var(--yellow); }
.sla-banner.danger { background: rgba(236,106,112,.09); color: var(--red); }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: #0B1016;
}

.msg { display: flex; gap: 0.6rem; max-width: 72%; animation: fadeIn 0.2s; }
@keyframes fadeIn { from{opacity:0;transform:translateY(4px)} to{opacity:1;transform:none} }
.msg.own { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #26384B;
  border: 1px solid #40556C;
  color: #E5EDF5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  font-weight: 600;
  flex-shrink: 0;
  align-self: flex-end;
}
.msg.own .msg-avatar { background: #31465C; }
.msg-bubble {
  padding: 0.6rem 0.85rem;
  border-radius: 10px;
  font-size: 0.86rem;
  line-height: 1.45;
}
.msg:not(.own) .msg-bubble {
  background: var(--msg-client);
  border: 1px solid #2A3646;
  color: #E6ECF2;
  border-bottom-left-radius: 4px;
}
.msg.own .msg-bubble {
  background: var(--msg-own);
  color: #10161D;
  border-bottom-right-radius: 4px;
}
.msg-time {
  font-size: 0.64rem;
  color: #718095;
  opacity: 1;
  margin-top: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.msg.own .msg-time { text-align: right; justify-content: flex-end; }

.date-sep { text-align: center; margin: 0.5rem 0; }
.date-sep span {
  background: #18212C;
  border: 1px solid #334153;
  padding: 0.22rem 0.7rem;
  border-radius: 999px;
  font-size: 0.68rem;
  color: var(--text-secondary);
}

.suggest-box, .canned-box {
  margin: 0 16px 8px;
  padding: 0.7rem 0.9rem;
  background: rgba(143,166,193,.07);
  border: 1px solid rgba(143,166,193,.22);
  border-radius: 7px;
  font-size: 0.8rem;
  flex-shrink: 0;
}
.suggest-box label, .canned-box label {
  font-size: 0.66rem;
  color: var(--accent-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-bottom: 0.35rem;
}
.suggest-text { color: var(--text-secondary); margin-bottom: 0.5rem; line-height: 1.4; }

.canned-list { display: flex; flex-direction: column; gap: 0.35rem; }
.canned-item {
  text-align: left;
  background: #141C25;
  border: 1px solid #2B3745;
  color: var(--text);
  font-family: inherit;
  font-size: 0.78rem;
  padding: 0.5rem 0.65rem;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.15s;
}
.canned-item:hover { background: #1B2632; border-color: #4A5B70; }
.canned-item span { display: block; color: var(--text-secondary); font-size: 0.68rem; margin-bottom: 0.15rem; }

.input-area {
  padding: 10px 16px 12px;
  background: #131B24;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.input-row { display: flex; gap: 0.5rem; align-items: flex-end; }
.attach-btn {
  background: #141C25;
  border: 1px solid #2B3745;
  color: var(--text-secondary);
  width: 38px;
  height: 38px;
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.attach-btn:hover:not(:disabled) { background: #1B2632; border-color: #4A5B70; color: #F4F7FA; }
.attach-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.upload-progress { font-size: 0.72rem; color: var(--text-secondary); margin-top: 0.4rem; }
.input-hint { font-size: 0.66rem; color: var(--text-tertiary); margin-top: 0.4rem; }
.attach-preview-row { display: flex; gap: 0.5rem; margin-bottom: 0.65rem; flex-wrap: wrap; }
.attach-preview-item {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.attach-preview-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attach-preview-item .file-chip {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #0A1016;
  font-size: 0.6rem;
  color: var(--text-secondary);
  text-align: center;
  padding: 0.2rem;
  gap: 0.15rem;
  overflow: hidden;
}
.attach-preview-item .file-chip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 56px; }
.attach-preview-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0,0,0,.7);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  line-height: 1;
  padding: 0;
}
.attach-preview-remove:hover { background: var(--red); }
.msg-image { max-width: 260px; border-radius: 8px; margin-top: 0.2rem; cursor: pointer; display: block; }
.msg-file { display: flex; align-items: center; gap: 0.4rem; text-decoration: none; color: inherit; font-size: 0.85rem; }
.msg-input {
  flex: 1;
  background: #080D12;
  border: 1px solid #293645;
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  color: var(--text);
  font-family: inherit;
  font-size: 0.86rem;
  resize: none;
  outline: none;
  min-height: 38px;
  max-height: 100px;
}
.msg-input:focus { border-color: #5B7189; box-shadow: 0 0 0 2px rgba(143,166,193,.08); }
.msg-input:disabled { opacity: 0.5; }
.send-btn {
  background: #DCE6F0;
  border: 1px solid #DCE6F0;
  color: #10161D;
  border-radius: 6px;
  padding: 0.6rem 1.05rem;
  cursor: pointer;
  font-weight: 620;
  font-size: 0.82rem;
  font-family: inherit;
  transition: background 0.15s, opacity 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}
.send-btn:hover:not(:disabled) { background: #F0F5F9; border-color: #F0F5F9; }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- Context panel ---------- */
.context-body { flex: 1; overflow-y: auto; padding: 12px; }

.ctx-section { margin-bottom: 1.1rem; }
.ctx-section-title {
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid #202B37;
  color: #748295;
  font-size: 0.66rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.ctx-section-title svg { flex-shrink: 0; opacity: 0.85; }

.empresa-card {
  background: #0D141B;
  border: 1px solid #263342;
  border-radius: 8px;
  padding: 0.875rem;
}
.empresa-name { font-size: 0.92rem; font-weight: 620; margin-bottom: 0.15rem; }
.empresa-cif { font-size: 0.7rem; color: #718095; margin-bottom: 0.65rem; }
.plan-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #18212B;
  border: 1px solid #344559;
  color: #C5D3E1;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.22rem 0.5rem;
  border-radius: 4px;
  margin-bottom: 0.65rem;
}
.plan-badge.trial { background: rgba(230,185,92,.1); border-color: rgba(230,185,92,.28); color: var(--yellow); }

.kv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.45rem; }
.kv { background: #0A1016; border: 1px solid #253241; border-radius: 5px; padding: 0.5rem 0.65rem; }
.kv-label { font-size: 0.62rem; color: #748295; text-transform: uppercase; letter-spacing: 0.03em; }
.kv-val { font-size: 0.82rem; font-weight: 600; margin-top: 0.15rem; color: #DEE6EE; }
.kv-val.danger { color: var(--red); }
.kv-val.warn { color: var(--yellow); }
.kv-val.good { color: var(--green); }

.usage-bar { grid-column: 1 / -1; }
.usage-bar-track { height: 3px; background: #25303C; border-radius: 99px; margin-top: 0.4rem; overflow: hidden; }
.usage-bar-track > span { display: block; height: 100%; background: #7894B2; border-radius: 99px; }
.usage-bar-track > span.warn { background: var(--yellow); }
.usage-bar-track > span.danger { background: var(--red); }

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  padding: 0.42rem 0;
  border-bottom: 1px solid #202B37;
  font-size: 0.76rem;
}
.info-row:last-child { border-bottom: none; }
.info-row span:first-child { color: #6F7D90; flex-shrink: 0; }
.info-row span:last-child { text-align: right; overflow-wrap: anywhere; }
.info-row a { color: var(--accent); text-decoration: none; overflow-wrap: anywhere; }
.info-row a:hover { color: var(--accent-hover); text-decoration: underline; }

.priority-segment {
  display: flex;
  border: 1px solid #293645;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 0.55rem;
}
.priority-segment button {
  flex: 1;
  background: #0A1016;
  border: none;
  border-right: 1px solid #293645;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.45rem 0.4rem;
  cursor: pointer;
  transition: all 0.15s;
}
.priority-segment button:last-child { border-right: none; }
.priority-segment button:hover { color: var(--text); }
.priority-segment button.active[data-level="baja"] { background: rgba(69,196,134,.12); color: var(--green); }
.priority-segment button.active[data-level="normal"] { background: #243141; color: #E2EAF2; }
.priority-segment button.active[data-level="alta"] { background: rgba(236,106,112,.13); color: var(--red); }

.tag-editor { display: flex; gap: 0.35rem; margin-bottom: 0.55rem; }
.tag-editor input {
  flex: 1;
  background: #080D12;
  border: 1px solid #293645;
  border-radius: 5px;
  padding: 0.45rem 0.6rem;
  color: var(--text);
  font-family: inherit;
  font-size: 0.75rem;
  outline: none;
}
.tag-editor input:focus { border-color: #5B7189; box-shadow: 0 0 0 2px rgba(143,166,193,.08); }

.quick-actions { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.quick-actions .btn { font-size: 0.72rem; }

.note-input {
  width: 100%;
  background: #080D12;
  border: 1px solid #293645;
  border-radius: 5px;
  padding: 0.55rem 0.65rem;
  color: var(--text);
  font-family: inherit;
  font-size: 0.78rem;
  line-height: 1.45;
  resize: none;
  min-height: 60px;
  outline: none;
  margin-bottom: 0.45rem;
}
.note-input:focus { border-color: #5B7189; box-shadow: 0 0 0 2px rgba(143,166,193,.08); }
.notes-list { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 0.5rem; }
.note-item {
  background: #0D141B;
  border: 1px solid #263342;
  border-radius: 6px;
  padding: 0.55rem 0.65rem;
  font-size: 0.76rem;
  color: #D0D8E0;
}
.note-meta { font-size: 0.64rem; color: #6F7D90; margin-top: 0.25rem; }

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  font-size: 0.74rem;
  color: #728094;
  padding: 0.38rem 0;
  border-bottom: 1px solid #202B37;
}
.activity-item:last-child { border-bottom: none; }
.activity-item svg { flex-shrink: 0; margin-top: 0.1rem; opacity: 0.7; }

/* ---------- Empty state ---------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-secondary);
  text-align: center;
  padding: 2rem;
  font-size: 0.85rem;
}
.empty svg { width: 42px; height: 42px; opacity: 0.35; margin-bottom: 0.75rem; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: #18232F;
  border: 1px solid #3A495C;
  border-radius: 6px;
  padding: 0.7rem 1.1rem;
  font-size: 0.85rem;
  z-index: 500;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  box-shadow: 0 18px 40px rgba(0,0,0,.55);
}
.toast.show { opacity: 1; }

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ---------- Responsive ---------- */
@media (max-width: 1400px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .stat-card { min-height: 0; border-bottom: 1px solid var(--border); }
  .stat-card:nth-child(3n) { border-right: 0; }
  .stat-card:nth-last-child(-n+3) { border-bottom: 0; }
}
@media (max-width: 1100px) {
  .main-layout { grid-template-columns: var(--conv-width, 260px) 8px minmax(300px, 1fr); }
  .context-panel, .resizer-right { display: none; }
}
@media (max-width: 1050px) {
  .top-bar { width: 196px; }
  .content { margin-left: 196px; padding: 20px 20px 22px; }
}
@media (max-width: 760px) {
  .top-bar {
    position: sticky;
    width: 100%;
    height: auto;
    padding: 10px;
    flex-direction: row;
    align-items: center;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .brand-copy > span, .admin-tab small, .top-right { display: none; }
  .admin-tabs { margin: 0 0 0 auto; flex-direction: row; gap: 4px; }
  .admin-tab { width: auto; min-height: 38px; padding: 7px 9px; }
  .admin-tab.active { box-shadow: none; }
  .admin-tab span { display: block; }
  .content { margin-left: 0; height: calc(100vh - 55px); padding: 12px; }
  .stats-grid { display: none; }
  .main-layout { grid-template-columns: 1fr; }
  .conv-panel, .resizer-left, .resizer-right { display: none; }
}
