:root {
  --navy: #131A33; --navy-2: #1B2446; --navy-3: #26305A; --navy-4: #0F1530;
  --orange: #F28C28; --mint: #34D399; --red: #F87171; --amber: #FBBF24; --violet: #A78BFA;
  --ink: #EEF1F8; --soft: #A9B1C9;
  --r: 14px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--navy); color: var(--ink); font: 400 15.5px/1.55 Figtree, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
       padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
h1, h2, h3 { font-family: Poppins, Figtree, sans-serif; margin: 0; letter-spacing: -.01em; line-height: 1.2; }
h1 { font-size: 1.65rem; font-weight: 700; }
h2 { font-size: 1.2rem; font-weight: 600; }
h3 { font-size: 1.02rem; font-weight: 600; }
p { margin: 0; }
a { color: var(--orange); }
img { max-width: 100%; }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--soft); }
.small { font-size: .88rem; }
.hidden { display: none !important; }

/* Estructura */
.layout { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.side { background: var(--navy-4); border-right: 1px solid var(--navy-3); padding: 18px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.side .brand { display: flex; justify-content: center; padding: 6px 0 18px; }
.side .brand img { width: 150px; }
.nav { display: grid; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--soft); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--navy-2); color: var(--ink); }
.nav a.on { background: rgba(242, 140, 40, .14); color: var(--orange); }
.nav a .soon { margin-left: auto; font-size: .7rem; color: var(--soft); border: 1px solid var(--navy-3); border-radius: 999px; padding: 1px 8px; }
.nav .sep { font-size: .78rem; color: var(--soft); opacity: .7; padding: 14px 12px 4px; }
.nav svg { width: 19px; height: 19px; flex: none; }
.side .me { margin-top: auto; padding: 14px 10px 4px; border-top: 1px solid var(--navy-3); font-size: .9rem; }
.side .me strong { display: block; }
.main { min-width: 0; }
.topbar { display: none; }
.content { padding: 28px 34px 60px; max-width: 1180px; }
.page-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head .grow { flex: 1; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 40; left: 0; top: 0; width: 270px; transform: translateX(-100%); transition: transform .2s; padding-top: calc(18px + env(safe-area-inset-top, 0px)); }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.5); }
  .topbar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--navy-4); border-bottom: 1px solid var(--navy-3); position: sticky; top: env(safe-area-inset-top, 0px); z-index: 30; }
  .topbar img { height: 30px; }
  .content { padding: 20px 16px 50px; }
}

/* Avisos */
.banner { background: rgba(167, 139, 250, .14); border: 1px solid rgba(167, 139, 250, .4); color: #DDD6FE; padding: 10px 16px; border-radius: 12px; margin-bottom: 18px;
          display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.banner .grow { flex: 1; }
.notice { background: var(--navy-2); border: 1px dashed var(--navy-3); border-radius: var(--r); padding: 22px; color: var(--soft); }

/* Botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 10px; padding: 10px 16px;
       font: 600 .95rem Figtree, sans-serif; cursor: pointer; text-decoration: none; background: var(--navy-2); color: var(--ink); border-color: var(--navy-3); }
.btn:hover { border-color: var(--soft); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--mint); color: #0B2A20; border-color: var(--mint); }
.btn.primary:hover { background: #4ADEA9; }
.btn.danger { color: var(--red); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 11px; font-size: .86rem; border-radius: 8px; }
.icon-btn { background: transparent; border: 0; color: var(--ink); cursor: pointer; padding: 6px; border-radius: 8px; }

/* Tarjetas y tablas */
.card { background: var(--navy-2); border: 1px solid var(--navy-3); border-radius: var(--r); padding: 20px; }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 900px) { .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; } }
.stat strong { display: block; font: 700 1.9rem Poppins, sans-serif; }
.stat span { color: var(--soft); font-size: .9rem; }
.modules { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.module { display: block; text-decoration: none; color: var(--ink); background: var(--navy-2); border: 1px solid var(--navy-3); border-radius: var(--r); padding: 16px; }
.module:hover { border-color: var(--orange); }
.module strong { display: block; font-weight: 600; }
.module span { color: var(--soft); font-size: .88rem; }
.list { display: grid; gap: 10px; }
.row { display: flex; align-items: center; gap: 14px; background: var(--navy-2); border: 1px solid var(--navy-3); border-radius: 12px; padding: 14px 16px; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; }
.table-wrap { overflow-x: auto; border: 1px solid var(--navy-3); border-radius: var(--r); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { text-align: left; font-weight: 600; color: var(--soft); background: var(--navy-4); padding: 10px 14px; white-space: nowrap; }
td { padding: 10px 14px; border-top: 1px solid var(--navy-3); vertical-align: top; }
.badge { display: inline-block; font-size: .78rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: rgba(169,177,201,.15); color: var(--soft); }
.badge.ok { background: rgba(52,211,153,.15); color: var(--mint); }
.badge.warn { background: rgba(251,191,36,.15); color: var(--amber); }
.badge.bad { background: rgba(248,113,113,.15); color: var(--red); }
.badge.violet { background: rgba(167,139,250,.15); color: var(--violet); }

/* Formularios */
.form { display: grid; gap: 14px; }
.form.two { grid-template-columns: 1fr 1fr; }
.form .full { grid-column: 1 / -1; }
@media (max-width: 700px) { .form.two { grid-template-columns: 1fr; } }
label.field { display: grid; gap: 6px; font-size: .88rem; color: var(--soft); }
input, select, textarea { font: inherit; color: var(--ink); background: var(--navy-4); border: 1px solid var(--navy-3); border-radius: 10px; padding: 10px 12px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--orange); }
textarea { min-height: 110px; resize: vertical; }
.check { display: flex; align-items: center; gap: 10px; color: var(--ink); font-size: .95rem; }
.check input { width: 18px; height: 18px; accent-color: var(--mint); }
.hint { font-size: .82rem; color: var(--soft); }
.error-text { color: var(--red); font-size: .9rem; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: .8rem; border: 1px solid var(--navy-3); background: var(--navy-4); color: var(--soft); border-radius: 999px; padding: 3px 10px; cursor: pointer; }
.chip:hover { color: var(--ink); border-color: var(--soft); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs button { background: transparent; border: 1px solid var(--navy-3); color: var(--soft); border-radius: 999px; padding: 6px 14px; font: 600 .9rem Figtree, sans-serif; cursor: pointer; }
.tabs button.on { background: rgba(242,140,40,.14); border-color: var(--orange); color: var(--orange); }

/* Ventanas */
.overlay { position: fixed; inset: 0; background: rgba(5, 8, 20, .7); display: grid; place-items: center; z-index: 60; padding: 16px; }
.modal { background: var(--navy-2); border: 1px solid var(--navy-3); border-radius: 18px; width: min(560px, 100%); max-height: 90vh; overflow: auto; padding: 22px; }
.modal h2 { margin-bottom: 14px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.toasts { position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 8px; z-index: 80; }
.toast { background: #0B1026; border: 1px solid var(--navy-3); border-left: 4px solid var(--mint); padding: 12px 16px; border-radius: 10px; max-width: 360px; box-shadow: 0 12px 30px rgba(0,0,0,.4); }
.toast.err { border-left-color: var(--red); }
.spinner { width: 26px; height: 26px; border: 3px solid var(--navy-3); border-top-color: var(--orange); border-radius: 50%; animation: spin .8s linear infinite; margin: 30px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } .side { transition: none; } }

/* Ingreso */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px;
         background: radial-gradient(circle at 80% 0%, rgba(242,140,40,.22), transparent 50%), var(--navy); }
.login .box { width: min(400px, 100%); }
.login .box > img { width: 230px; display: block; margin: 0 auto 24px; }
.login .card { padding: 26px; }
.login .links { display: flex; justify-content: space-between; margin-top: 16px; font-size: .9rem; }
.logo-box { width: 140px; height: 140px; border-radius: 16px; background: var(--navy-4); border: 1px dashed var(--navy-3); display: grid; place-items: center; overflow: hidden; }
.logo-box img { max-width: 100%; max-height: 100%; }
.module svg { width: 26px; height: 26px; }
.page-head svg, .btn svg { width: 18px; height: 18px; }
.icon-btn svg { width: 24px; height: 24px; display: block; }
.nav svg, .module svg, .icon-btn svg { flex: none; }
.modules { grid-template-columns: repeat(auto-fill, minmax(min(220px, 44%), 1fr)); }
@media (max-width: 900px) { .grid.cols-3.stats { grid-template-columns: repeat(3, 1fr); gap: 8px; } .grid.cols-3.stats .card { padding: 12px; } .stat strong { font-size: 1.4rem; } }
.nav .unread { margin-left: auto; background: var(--mint); color: #0B2A20; font-size: .72rem; font-weight: 700; border-radius: 999px; padding: 1px 8px; }

/* WhatsApp */
.qr-box { background: #fff; border-radius: 16px; padding: 16px; width: 280px; max-width: 100%; }
.qr-box img, .qr-box svg { width: 100%; height: auto; display: block; }
.pair-code { font: 700 2.2rem Poppins, monospace; letter-spacing: .25em; color: var(--ink); background: var(--navy-4); border: 1px solid var(--navy-3); border-radius: 14px; padding: 14px 22px; display: inline-block; }

/* Chats */
.chat-layout { display: grid; grid-template-columns: 340px 1fr; height: calc(100vh - 56px); border: 1px solid var(--navy-3); border-radius: var(--r); overflow: hidden; background: var(--navy-2); }
.content:has(.chat-layout) { max-width: none; padding: 28px 24px 0; }
.chat-list { border-right: 1px solid var(--navy-3); display: flex; flex-direction: column; min-height: 0; }
.chat-list .head { padding: 14px; display: grid; gap: 10px; border-bottom: 1px solid var(--navy-3); }
.chat-items { overflow-y: auto; flex: 1; }
.chat-item { display: flex; gap: 12px; padding: 12px 14px; border-bottom: 1px solid rgba(38,48,90,.6); cursor: pointer; text-decoration: none; color: inherit; }
.chat-item:hover, .chat-item.on { background: var(--navy-3); }
.chat-item .grow { flex: 1; min-width: 0; }
.chat-item .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .prev { color: var(--soft); font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .meta { text-align: right; font-size: .75rem; color: var(--soft); display: grid; gap: 4px; justify-items: end; }
.avatar { width: 42px; height: 42px; border-radius: 50%; background: var(--navy-4); display: grid; place-items: center; font-weight: 700; color: var(--orange); flex: none; }
.conv { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.conv .top { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--navy-3); }
.conv .msgs { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; background: var(--navy-4); }
.bubble-row { display: flex; }
.bubble-row.me { justify-content: flex-end; }
.msg { max-width: min(72%, 560px); background: var(--navy-2); border: 1px solid var(--navy-3); padding: 8px 12px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; }
.me .msg { background: #12443A; border-color: #1C5A4C; }
.msg .info { font-size: .72rem; color: var(--soft); text-align: right; margin-top: 3px; }
.msg img.media { max-width: 280px; width: 100%; border-radius: 10px; cursor: zoom-in; display: block; }
.msg audio, .msg video { max-width: 300px; width: 100%; display: block; }
.day { align-self: center; font-size: .75rem; color: var(--soft); background: var(--navy-2); border-radius: 999px; padding: 2px 10px; margin: 8px 0; }
.composer { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--navy-3); align-items: flex-end; }
.composer textarea { min-height: 44px; max-height: 160px; resize: none; }
.tick-read { color: #60A5FA; }
.empty-conv { display: grid; place-items: center; height: 100%; color: var(--soft); text-align: center; padding: 30px; }
@media (max-width: 900px) {
  .chat-layout { grid-template-columns: 1fr; height: calc(100vh - 110px); }
  .content:has(.chat-layout) { padding: 12px 10px 0; }
  .chat-layout.open .chat-list { display: none; }
  .chat-layout:not(.open) .conv { display: none; }
  .msg { max-width: 85%; }
}
.back-mobile { display: none; }
@media (max-width: 900px) { .back-mobile { display: inline-flex; } }

/* 7.1: ver contraseña, contacto del proveedor, ventas */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { width: 100%; padding-right: 46px; }
.pw-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 0; border-radius: 8px; color: var(--soft); cursor: pointer; }
.pw-eye:hover { color: var(--ink); background: var(--navy-3); }
.pw-eye svg { width: 20px; height: 20px; }
.pw-eye.inline { position: static; transform: none; width: 30px; height: 30px; vertical-align: middle; }
.secret-wrap { display: inline-flex; align-items: center; gap: 4px; }
.secret { font-family: ui-monospace, Menlo, Consolas, monospace; }
.provider { margin-top: 18px; text-align: center; font-size: .92rem; color: var(--soft); }
.provider a.btn { margin-top: 8px; }
.wa-btn { background: #25D366; color: #06301A; border-color: #25D366; }
.wa-btn:hover { background: #3BE07A; }
.credbox { background: var(--navy-4); border: 1px solid var(--navy-3); border-radius: 10px; padding: 12px 14px; white-space: pre-wrap; font-size: .92rem; }
.opt-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.opt-row .grow { flex: 1; min-width: 160px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: .92rem; }
