/* Shelsy · visual layer (loaded last). Structure, element IDs and section names are untouched: only how they look.
   Direction: deep navy, one violet→cyan brand gradient, color-coded states (green ok, amber attention, red problem),
   generous spacing and cards that read as cards. */
:root {
  --bg: #0b0f1e;
  --surface: #141a2e;
  --surface-2: #1b2240;
  --surface-3: #232b4d;
  --text: #f1f3fc;
  --muted: #a5adc9;
  --line: #262e4f;
  --glass: var(--surface);
  --glass-hi: var(--surface-2);
  --accent: #a493ff;
  --accent-2: #4fd1e8;
  --accent-soft: rgba(164, 147, 255, 0.15);
  --brand: linear-gradient(120deg, #a493ff 0%, #6aa8ff 55%, #4fd1e8 100%);
  --grad: var(--brand);
  --ok: #4fd69c;
  --ok-soft: rgba(79, 214, 156, 0.14);
  --warn: #f6c453;
  --warn-soft: rgba(246, 196, 83, 0.15);
  --danger: #f47e7a;
  --danger-soft: rgba(244, 126, 122, 0.14);
  --radius: 16px;
  --border: var(--line);
  --shadow: 0 10px 30px rgba(3, 6, 20, 0.35);
}

body {
  background: radial-gradient(1200px 600px at 85% -10%, rgba(106, 168, 255, 0.10), transparent 60%),
              radial-gradient(900px 500px at -10% 110%, rgba(164, 147, 255, 0.10), transparent 60%), var(--bg);
  background-attachment: fixed; color: var(--text); font-size: 14.5px; line-height: 1.55; -webkit-font-smoothing: antialiased;
}
.bg-glow { display: none; }
.glass { background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); backdrop-filter: none; }
a { color: var(--accent-2); }

/* ---------- Sidebar ---------- */
.sidebar { background: linear-gradient(180deg, #11172b, #0d1224); border-right: 1px solid var(--line); box-shadow: none; }
.brand-name { background: var(--brand); -webkit-background-clip: text; background-clip: text; color: transparent; }
.nav { gap: 2px; }
.nav-group { margin: 16px 12px 6px; font-size: 10.5px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: #6f789c; }
.nav-group:first-child { margin-top: 4px; }
.nav-item { border-radius: 11px; padding: 10px 12px; color: #c8cde6; font-weight: 600; transition: background .15s, color .15s; }
.nav-item svg { stroke: #8790b5; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item:hover svg { stroke: var(--text); }
.nav-item.active { background: linear-gradient(90deg, rgba(164, 147, 255, .22), rgba(79, 209, 232, .06)); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.nav-item.active svg { stroke: var(--accent); }
.badge { background: var(--warn); color: #241a00; font-weight: 800; }

/* ---------- Top bar ---------- */
.topbar { border-radius: var(--radius); padding: 12px 18px; }
.topbar-avatar { background: var(--brand); color: #12122a; font-weight: 800; }
.topbar-pills { gap: 8px; flex-wrap: wrap; }
.status-pill { background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; font-size: 12px; font-weight: 600; padding: 6px 12px; }
.status-pill:hover { border-color: #3a4573; }
.status-dot.on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.usage-track { background: #2c3560; height: 6px; border-radius: 99px; min-width: 70px; }
.usage-fill { background: var(--brand); border-radius: 99px; }
.usage-pill.warn { border-color: rgba(246, 196, 83, .55); background: var(--warn-soft); }
.usage-pill.warn .usage-fill { background: var(--warn); }
.usage-pill.full { border-color: rgba(244, 126, 122, .6); background: var(--danger-soft); }
.usage-pill.full .usage-fill { background: var(--danger); }
.credit-pill .usage-fill { background: linear-gradient(90deg, #4fd69c, #4fd1e8); }

/* ---------- Page headings ---------- */
.page-head h1 { font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.page-head p { color: var(--muted); max-width: 72ch; }
.eyebrow { background: var(--brand); -webkit-background-clip: text; background-clip: text; color: transparent; letter-spacing: .12em; font-size: 11px; font-weight: 800; }
.hint { color: var(--muted); }

/* ---------- Buttons ---------- */
.btn { border-radius: 11px; font-weight: 650; }
.btn-primary { background: var(--brand); color: #10122a; border: 0; box-shadow: 0 6px 18px rgba(106, 168, 255, .25); }
.btn-primary:hover { filter: brightness(1.08); box-shadow: 0 8px 22px rgba(106, 168, 255, .35); }
.btn-ghost { background: var(--surface-2); border: 1px solid var(--line); color: var(--text); }
.btn-ghost:hover { border-color: #3d4878; background: var(--surface-3); }
.btn-danger-text { color: var(--danger) !important; }

/* ---------- Inbox ---------- */
.inbox, .chat, .panel-card { border-radius: var(--radius); }
.conv-item { border-radius: 12px; border: 1px solid transparent; }
.conv-item:hover { background: var(--surface-2); }
.conv-item.active { background: var(--surface-2); border-color: rgba(164, 147, 255, .45); }
.conv-item .avatar, .avatar { background: var(--brand); color: #12122a; font-weight: 800; }
/* Status labels wrap onto a new line instead of being cut off. */
.conv-flags { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; max-width: 100%; }
.conv-flags .chip { white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.chip { border-radius: 999px; font-weight: 650; }
.chip-mission { background: var(--ok-soft); color: var(--ok); border: 1px solid rgba(79, 214, 156, .35); }
.chip-off, .chip-warn { background: var(--warn-soft); color: var(--warn); border: 1px solid rgba(246, 196, 83, .35); }

/* ---------- Chat ---------- */
.chat-head { gap: 8px; flex-wrap: wrap; align-items: center; position: relative; z-index: 5; }
.messages { background: linear-gradient(180deg, #10152a, #0e1326); }
.msg-group.user .bubble { background: var(--surface-3); border: 1px solid #2f3a66; }
.msg-group.agent .bubble { background: linear-gradient(135deg, rgba(164, 147, 255, .20), rgba(106, 168, 255, .12)); border: 1px solid rgba(164, 147, 255, .28); }
.msg-group.human_owner .bubble { background: linear-gradient(135deg, rgba(79, 214, 156, .18), rgba(79, 209, 232, .10)); border: 1px solid rgba(79, 214, 156, .3); }
.banner { border-radius: 10px; }
.composer input { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; }

/* "⋯ Más": rarely used chat actions, out of the way */
.more-menu { position: relative; }
.more-menu > summary { list-style: none; cursor: pointer; }
.more-menu > summary::-webkit-details-marker { display: none; }
.more-menu-list { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; display: grid; gap: 4px; min-width: 210px; padding: 6px;
  background: var(--surface-2); border: 1px solid #3b4675; border-radius: 12px; box-shadow: 0 14px 34px rgba(0, 0, 0, .5); }
.more-menu-list .btn { justify-content: flex-start; width: 100%; background: transparent; border: 0; text-align: left; }
.more-menu-list .btn:hover { background: var(--accent-soft); }

/* ---------- Cards and settings panes (Conexiones, Agente) ---------- */
.card, [data-connection-pane], .setup-step, .report-section {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
[data-connection-pane] { padding: 24px 28px; max-width: 900px; }
[data-connection-pane] h2, [data-connection-pane] h3 { margin-top: 0; }
details.technical-settings[data-connection-pane] { padding: 16px 22px; }
.connection-tabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 5px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; width: fit-content; max-width: 100%; }
.connection-tabs button { border: 0; border-radius: 10px; padding: 9px 16px; background: transparent; color: var(--muted); font: inherit; font-weight: 650; cursor: pointer; }
.connection-tabs button:hover { color: var(--text); background: var(--surface-2); }
.connection-tabs button.active { background: linear-gradient(90deg, rgba(164, 147, 255, .25), rgba(79, 209, 232, .10)); color: #fff; box-shadow: inset 0 -2px 0 var(--accent); }
.yape-list { border-radius: 12px; }
.saved-banner { background: var(--ok-soft); border: 1px solid rgba(79, 214, 156, .35); border-radius: 12px; }

/* Gemini credit meter */
.credit-box { padding: 16px 18px; border-radius: 14px; background: linear-gradient(135deg, rgba(79, 214, 156, .10), rgba(79, 209, 232, .06)); border: 1px solid rgba(79, 214, 156, .28); display: grid; gap: 10px; }
.credit-box h4 { margin: 0; }
.credit-meter { height: 10px; border-radius: 99px; background: #2c3560; overflow: hidden; }
.credit-meter span { display: block; height: 100%; background: linear-gradient(90deg, #4fd69c, #4fd1e8); border-radius: 99px; transition: width .3s; }

/* Agent page: four parts as tabs */
.agent-tabs { display: flex; gap: 6px; flex-wrap: wrap; padding: 5px; margin: 4px 0 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.agent-tab { flex: 1 1 140px; padding: 10px 12px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font: inherit; font-weight: 700; cursor: pointer; }
.agent-tab:hover { color: var(--text); background: var(--surface-2); }
.agent-tab.active { background: linear-gradient(90deg, rgba(164, 147, 255, .25), rgba(79, 209, 232, .10)); color: #fff; box-shadow: inset 0 -2px 0 var(--accent); }
.setup-step { position: relative; overflow: hidden; }
.setup-step::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--brand); }
.step-number { background: var(--accent-soft); color: var(--accent); border-radius: 10px; font-weight: 800; }
.routing-disclosure > summary { display: none; }
[data-agent-pane]:not([data-agent-pane="strategy"]) .step-number { display: none; }
/* Without its number the step has one column (otherwise the text is squeezed into the 32px number column). */
[data-agent-pane]:not([data-agent-pane="strategy"]).setup-step, [data-agent-pane]:not([data-agent-pane="strategy"]) .setup-step { grid-template-columns: minmax(0, 1fr); }
.setup-step { padding: 24px 26px; }
.routing-disclosure[data-agent-pane] { border: 0; background: none; box-shadow: none; padding: 0; }

/* KPIs: colored by meaning */
.kpi { border-radius: 14px; border: 1px solid var(--line); background: var(--surface); position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--brand); }

/* ---------- Forms ---------- */
input, select, textarea { background: #0f1428; border: 1px solid var(--line); border-radius: 10px; color: var(--text); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: 3px solid var(--accent-soft); outline-offset: 0; }

@media (max-width: 760px) {
  .agent-tab { flex-basis: 45%; }
  .more-menu-list { right: auto; left: 0; }
  [data-connection-pane] { padding: 18px 16px; }
  .connection-tabs { width: 100%; }
}
.msg-link { color: var(--accent-2); text-decoration: underline; overflow-wrap: anywhere; }

/* Phones: the sidebar becomes a top block; the menu scrolls sideways inside the screen, never widening the page. */
@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { flex-wrap: wrap; min-width: 0; max-width: 100vw; }
  .sidebar > * { min-width: 0; max-width: 100%; }
  .brand, .ws-switch, .nav, .side-actions { width: 100%; }
  .nav { min-width: 0; overflow-x: auto; flex-wrap: nowrap; scrollbar-width: thin; }
  .nav-group { display: none; }
  .nav-item { flex: none; }
  .content { min-width: 0; }
}
@media (max-width: 820px) {
  .topbar, .topbar-biz, .topbar-biz > div { min-width: 0; max-width: 100%; }
  .topbar-title-row { flex-wrap: wrap; }
  #topBizMeta, #topBizCategory { overflow-wrap: anywhere; white-space: normal; }
}

/* "Campañas y agentes": every campaign with the agent that answers it */
.assign-board { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 24px; margin-bottom: 22px; position: relative; overflow: hidden; }
.assign-board::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--brand); }
.assign-head { display: flex; gap: 16px; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; }
.assign-head h2 { margin: 0 0 4px; font-size: 19px; }
.assign-head .hint { max-width: 70ch; margin: 0; }
.assign-head .form-actions { margin: 0; }
.assign-list { display: grid; gap: 12px; margin-top: 10px; }
.assign-campaign { border: 1px solid var(--line); border-radius: 14px; background: #10162b; overflow: hidden; }
.assign-row { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(180px, 260px); gap: 12px; align-items: center; padding: 12px 16px; }
.assign-row-campaign { background: linear-gradient(90deg, rgba(164, 147, 255, .10), transparent); }
.assign-row-set { border-top: 1px solid var(--line); padding-left: 36px; position: relative; }
.assign-row-set::before { content: "↳"; position: absolute; left: 16px; color: #6f789c; }
.assign-name { display: grid; min-width: 0; }
.assign-name strong, .assign-name span { overflow-wrap: anywhere; }
.assign-name small { color: var(--muted); }
.assign-status { font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 99px; background: var(--surface-3); color: var(--muted); white-space: nowrap; }
.assign-status.on { background: var(--ok-soft); color: var(--ok); }
.assign-select { width: 100%; }
.assign-select.is-set { border-color: rgba(164, 147, 255, .7); background: rgba(164, 147, 255, .12); font-weight: 650; }
@media (max-width: 820px) {
  .assign-board { padding: 18px 16px; }
  .assign-row { grid-template-columns: minmax(0, 1fr) auto; }
  .assign-row .assign-select { grid-column: 1 / -1; }
}

/* Agente page: "Agentes" | "Campañas y agentes" */
.page-switch { display: inline-flex; gap: 6px; padding: 5px; margin: 0 0 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; max-width: 100%; }
.page-switch-btn { border: 0; border-radius: 10px; padding: 10px 18px; background: transparent; color: var(--muted); font: inherit; font-weight: 700; cursor: pointer; }
.page-switch-btn:hover { color: var(--text); background: var(--surface-2); }
.page-switch-btn.active { background: linear-gradient(90deg, rgba(164, 147, 255, .25), rgba(79, 209, 232, .10)); color: #fff; box-shadow: inset 0 -2px 0 var(--accent); }
.chip-blocked { background: var(--danger-soft); color: var(--danger); border: 1px solid rgba(244, 126, 122, .35); }

/* Customers who paid */
.chip-paid { background: linear-gradient(90deg, rgba(246, 196, 83, .20), rgba(79, 214, 156, .14)); color: #ffd98a; border: 1px solid rgba(246, 196, 83, .45); }
.purchase-total { margin-bottom: 6px; }
.purchase-total strong { color: #ffd98a; }
.purchase-item { display: grid; padding: 6px 0; border-top: 1px solid var(--line); }
.purchase-item span { font-weight: 700; }
.purchase-item small { color: var(--muted); }
.inbox-head { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.inbox-filter { max-width: 190px; font-size: 13px; padding: 6px 8px; }
.inbox-none { padding: 16px; }

/* Conexiones → Seguridad */
.security-pane h3 { margin-top: 10px; font-size: 15px; }
#secStatus.ok { color: var(--ok); font-weight: 600; }
.security-qr { width: 220px; height: 220px; border-radius: 12px; background: #fff; padding: 6px; }
.security-backup { border: 1px solid var(--warn); background: var(--warn-soft); border-radius: 12px; padding: 14px 16px; }
.security-codes { columns: 2; gap: 24px; font-family: ui-monospace, Consolas, monospace; font-size: 15px; letter-spacing: 0.04em; padding-left: 22px; }
.security-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.security-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; font-size: 13px; color: var(--muted); }
.security-list.small li { font-size: 12px; padding: 6px 8px; }
@media (max-width: 640px) { .security-codes { columns: 1; } .security-list li { flex-direction: column; align-items: flex-start; } }
