/* El atributo [hidden] pierde contra reglas de clase que setean display (ej .app{display:grid}) por
   especificidad -- forzarlo a ganar siempre, es el toggle real de visibilidad de toda la app. */
[hidden]{ display: none !important; }

/* ══════════════════════════════════════════
   TOKENS
   ══════════════════════════════════════════ */
:root{
  /* superficies */
  --bg-deep:      #061620;
  --bg-app:       #0B2531;
  --surface-1:    #10303D;
  --surface-2:    #143A48;
  --surface-3:    #1A4655;
  --line:         rgba(255,255,255,.07);
  --line-strong:  rgba(255,255,255,.13);

  /* acento */
  --teal:         #21B0A8;
  --teal-bright:  #2FD4C4;
  --teal-deep:    #12786F;
  --teal-soft:    rgba(33,176,168,.14);

  /* texto */
  --text:         #E8F3F4;
  --text-dim:     #8FB0BA;
  --text-faint:   #5E828F;

  /* señales */
  --alert:        #F0555B;
  --amber:        #F3C24B;

  /* forma */
  --r-lg: 20px;
  --r-md: 14px;
  --r-sm: 10px;
  --shadow: 0 18px 45px -20px rgba(0,0,0,.75);

  --sidebar-w: 208px;
  --inbox-w:   282px;
  --profile-w: 268px;
}

*{ box-sizing: border-box; }

html, body{ height: 100%; }

body{
  margin: 0;
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(900px 600px at 82% 8%,  rgba(33,176,168,.10), transparent 60%),
    radial-gradient(700px 500px at 10% 95%, rgba(33,120,111,.12), transparent 60%),
    var(--bg-deep);
  -webkit-font-smoothing: antialiased;
}

svg{
  width: 18px; height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

button{ font: inherit; color: inherit; cursor: pointer; }

::-webkit-scrollbar{ width: 6px; height: 6px; }
::-webkit-scrollbar-thumb{ background: var(--surface-3); border-radius: 99px; }
::-webkit-scrollbar-track{ background: transparent; }

/* ══════════════════════════════════════════
   SHELL
   ══════════════════════════════════════════ */
.app{
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: minmax(0, 1fr); /* sin esto la fila implícita crece con el contenido en
    vez de quedar atada a los 100vh del grid -- rompe el min-height:0 de todo lo de adentro */
  height: 100vh;
  margin: 0 auto;
  max-width: 1520px;
  background: var(--bg-app);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* ══════════════════════════════════════════
   SIDEBAR
   ══════════════════════════════════════════ */
.sidebar{
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
  background: rgba(6,22,32,.45);
  border-right: 1px solid var(--line);
}

.brand{
  display: flex; align-items: center; gap: 10px;
  padding: 0 8px 26px;
}
.brand-mark{
  width: 26px; height: 26px; border-radius: 9px;
  background: linear-gradient(140deg, var(--teal-bright), var(--teal-deep));
  box-shadow: 0 0 0 4px var(--teal-soft);
}
.brand-name{ font-weight: 700; letter-spacing: -.01em; }

.nav{ display: flex; flex-direction: column; gap: 2px; }
.nav-foot{ margin-top: auto; padding-top: 20px; border-top: 1px solid var(--line); }

.nav-item{
  position: relative;
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  color: var(--text-dim);
  text-decoration: none;
  transition: background .16s, color .16s;
}
.nav-item:hover{ background: rgba(255,255,255,.04); color: var(--text); }
.nav-item.is-active{ background: var(--teal-soft); color: var(--teal-bright); }
.nav-item.is-active::before{
  content: "";
  position: absolute; left: -14px; top: 50%;
  width: 3px; height: 20px;
  transform: translateY(-50%);
  border-radius: 0 3px 3px 0;
  background: var(--teal-bright);
}

.dot{
  width: 7px; height: 7px; border-radius: 50%;
  display: inline-block;
}
.dot-alert{ background: var(--alert); }
.nav-item .dot{ margin-left: auto; }

/* ══════════════════════════════════════════
   TOPBAR
   ══════════════════════════════════════════ */
.main{ display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.topbar{
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 14px;
}
.page-title{ margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.02em; }

.topbar-actions{ display: flex; align-items: center; gap: 12px; }

.btn{
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px;
  border: 0; border-radius: 99px;
  font-weight: 600; font-size: 13px;
}
.btn-primary{
  background: linear-gradient(135deg, var(--teal-bright), var(--teal));
  color: #04262A;
  box-shadow: 0 8px 20px -10px var(--teal);
}
.btn-primary:hover{ filter: brightness(1.07); }
.btn svg{ width: 15px; height: 15px; stroke-width: 2.4; }

.icon-btn{
  position: relative;
  display: grid; place-items: center;
  width: 36px; height: 36px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-1);
  color: var(--text-dim);
  transition: color .16s, border-color .16s;
}
.icon-btn:hover{ color: var(--text); border-color: var(--line-strong); }
.icon-btn.ghost{ border: 0; background: transparent; }
.icon-btn .dot{ position: absolute; top: 7px; right: 8px; }

.me{
  display: flex; align-items: center; gap: 9px;
  padding-left: 8px;
  font-size: 13px; font-weight: 500;
}
.me img{ width: 34px; height: 34px; border-radius: 50%; object-fit: cover; }

/* ══════════════════════════════════════════
   WORKSPACE / PANELES
   ══════════════════════════════════════════ */
.workspace{
  flex: 1;
  display: grid;
  grid-template-columns: var(--inbox-w) 1fr var(--profile-w);
  gap: 14px;
  padding: 0 20px 20px;
  min-height: 0;
}

.panel{
  display: flex; flex-direction: column;
  min-height: 0;
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}

.panel-head{
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 10px;
}
.panel-head h2{ margin: 0; font-size: 15px; font-weight: 600; }

.pill{
  margin-left: 6px;
  padding: 3px 9px;
  border-radius: 99px;
  background: var(--alert);
  font-size: 10.5px; font-weight: 600;
  color: #fff;
  vertical-align: middle;
}

/* ── Filtro tipo WhatsApp (Todos / No leídos) ── */
.filter-chips{
  display: flex; gap: 8px;
  margin: 0 16px 12px;
}
.chip{
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: transparent;
  color: var(--text-dim);
  font-size: 12.5px; font-weight: 600;
  transition: background .16s, color .16s, border-color .16s;
}
.chip:hover{ border-color: var(--line-strong); color: var(--text); }
.chip.is-active{
  background: var(--teal-soft);
  border-color: var(--teal);
  color: var(--teal-bright);
}

/* ── Buscador ── */
.search{
  display: flex; align-items: center; gap: 9px;
  margin: 0 16px 12px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: rgba(6,22,32,.4);
  color: var(--text-faint);
}
.search:focus-within{ border-color: var(--teal); }
.search svg{ width: 15px; height: 15px; flex: none; }
.search input{
  flex: 1; min-width: 0;
  border: 0; outline: 0; background: none;
  color: var(--text); font: inherit;
}
.search input::placeholder{ color: var(--text-faint); }

/* ── Lista de conversaciones ── */
.thread-list{
  flex: 1;
  margin: 0; padding: 0 10px 12px;
  list-style: none;
  overflow-y: auto;
}
.thread{
  position: relative;
  padding: 12px;
  margin-bottom: 6px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background .16s;
}
.thread:hover{ background: rgba(255,255,255,.035); }
.thread.is-active{
  background: linear-gradient(135deg, var(--teal), var(--teal-deep));
  box-shadow: 0 12px 26px -14px var(--teal);
}
.thread.is-active .thread-name,
.thread.is-active .thread-code,
.thread.is-active .thread-time,
.thread.is-active .thread-preview{ color: #EAFFFD; }
.thread.is-active .thread-code,
.thread.is-active .thread-time{ opacity: .8; }

.thread-top{ display: flex; align-items: center; gap: 10px; }
.thread-top img{ width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex: none; }
.thread-name{ font-size: 13px; font-weight: 600; }
.thread-code{ font-size: 11px; color: var(--text-faint); }
.thread-time{ margin-left: auto; font-size: 11px; color: var(--text-faint); }
.thread-preview{
  margin: 8px 0 0;
  font-size: 12.5px; color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.thread.is-unread::after{
  content: "";
  position: absolute; left: 4px; top: 18px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--alert);
}

/* ══════════════════════════════════════════
   CONVERSACIÓN
   ══════════════════════════════════════════ */
.conversation{ position: relative; }

.conv-head{
  display: flex; align-items: center; gap: 11px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.avatar{ width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.conv-id{ display: flex; flex-direction: column; line-height: 1.3; }
.conv-id strong{ font-size: 14px; }
.conv-id span{ font-size: 11px; color: var(--text-faint); }
.conv-head .icon-btn{ margin-left: auto; }

.messages{
  flex: 1;
  min-height: 0; /* si no, un flex item con overflow-y:auto no se achica: crece con el
                    contenido y empuja el composer fuera de la pantalla en vez de scrollear */
  padding: 20px 18px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 16px;
}

.day-divider{
  align-self: center;
  padding: 4px 14px;
  border-radius: 99px;
  background: var(--surface-2);
  font-size: 11px; color: var(--text-dim);
}

.msg{ display: flex; gap: 10px; max-width: 72%; }
.msg img{ width: 30px; height: 30px; border-radius: 50%; object-fit: cover; flex: none; align-self: flex-end; }
.msg-body{ display: flex; flex-direction: column; gap: 5px; }
.bubble{
  padding: 12px 15px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.55;
}
.msg-time{ font-size: 10.5px; color: var(--text-faint); }

/* entrante */
.msg.in .bubble{
  background: var(--surface-2);
  border-bottom-left-radius: 5px;
}
/* saliente */
.msg.out{ margin-left: auto; flex-direction: row-reverse; }
.msg.out .bubble{
  background: linear-gradient(135deg, var(--teal), var(--teal-deep));
  color: #ECFFFD;
  border-bottom-right-radius: 5px;
}
.msg.out .msg-time{ text-align: right; }
.bubble.is-failed{ background: rgba(240,85,91,.16); border: 1px solid rgba(240,85,91,.4); }
.msg-failed{ font-size: 10.5px; color: var(--alert); font-weight: 600; }
.msg.out .msg-failed{ text-align: right; }

/* nota de voz */
.voice{
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  border: 1px solid rgba(47,212,196,.35);
  border-radius: 14px;
  background: rgba(33,176,168,.10);
}
.voice-play{
  display: grid; place-items: center;
  width: 30px; height: 30px; flex: none;
  border: 0; border-radius: 50%;
  background: var(--teal-bright);
  color: #04262A;
}
.voice-play svg{ width: 13px; height: 13px; fill: currentColor; stroke: none; }
.wave{ display: flex; align-items: center; gap: 2.5px; height: 26px; flex: 1; }
.wave span{
  flex: 1;
  min-width: 2px;
  border-radius: 2px;
  background: var(--teal-bright);
  opacity: .45;
}
.voice.is-playing .wave span{ animation: pulse 1s ease-in-out infinite; }
@keyframes pulse{ 50%{ opacity: 1; } }
.voice-len{ font-size: 11px; color: var(--text-dim); }

/* composer */
.composer{
  display: flex; align-items: center; gap: 6px;
  margin: 0 16px 16px;
  padding: 7px 8px 7px 8px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: rgba(6,22,32,.45);
}
.composer:focus-within{ border-color: var(--teal); }
.composer input{
  flex: 1; min-width: 0;
  border: 0; outline: 0; background: none;
  color: var(--text); font: inherit;
}
.composer input::placeholder{ color: var(--text-faint); }
.send{
  display: grid; place-items: center;
  width: 34px; height: 34px; flex: none;
  border: 0; border-radius: 50%;
  background: linear-gradient(135deg, var(--teal-bright), var(--teal));
  color: #04262A;
}
.send svg{ fill: currentColor; stroke: none; width: 15px; height: 15px; }

/* ── Botón de plantillas ("\") en el composer ── */
.composer-icon-btn{
  display: grid; place-items: center;
  width: 34px; height: 34px; flex: none;
  border: 0; border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-dim);
  font: 700 15px/1 "Plus Jakarta Sans", monospace;
  transition: background .16s, color .16s;
}
.composer-icon-btn:hover{ background: var(--surface-3); color: var(--teal-bright); }

/* ── Autocompletado de plantillas (estilo Kommo: "/atajo" + Tab o clic) ── */
.canned-suggest{
  position: absolute;
  left: 16px; right: 16px; bottom: 66px;
  max-height: 240px;
  overflow-y: auto;
  margin: 0; padding: 6px;
  list-style: none;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
  z-index: 10;
}
.canned-suggest-item{
  display: flex; flex-direction: column; gap: 2px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
}
.canned-suggest-item:hover, .canned-suggest-item.is-active{ background: var(--teal-soft); }
.canned-suggest-code{ font-size: 12.5px; font-weight: 700; color: var(--teal-bright); }
.canned-suggest-text{
  font-size: 11.5px; color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.canned-suggest-empty{ padding: 9px 10px; font-size: 12px; color: var(--text-faint); }

/* ══════════════════════════════════════════
   PERFIL
   ══════════════════════════════════════════ */
.profile{ overflow-y: auto; }
.profile.is-hidden{ display: none; }

.profile-card{
  display: flex; flex-direction: column; align-items: center;
  padding: 8px 16px 22px;
  text-align: center;
}
.profile-avatar{
  width: 96px; height: 96px;
  padding: 4px;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--amber), #B7822A);
}
.profile-avatar img{
  width: 100%; height: 100%;
  border-radius: 50%; object-fit: cover;
  border: 3px solid var(--surface-1);
}
.profile-card h3{ margin: 14px 0 2px; font-size: 15px; }
.muted{ font-size: 11.5px; color: var(--text-faint); }

.rating{
  display: flex; align-items: center; gap: 5px;
  margin-top: 10px;
  font-size: 12px; color: var(--text-dim);
}
.star{ width: 14px; height: 14px; fill: var(--amber); stroke: none; }

.profile-section{ padding: 0 14px 18px; }
.section-head{
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 10px;
  padding: 0 2px;
}
.section-head h4{ margin: 0; font-size: 12.5px; font-weight: 600; color: var(--text-dim); }
.section-head a{ font-size: 11.5px; color: var(--teal-bright); text-decoration: none; }

.orders{ margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.order{
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background .16s;
}
.order:hover{ background: rgba(255,255,255,.035); }
.order.is-active{
  background: linear-gradient(135deg, var(--teal), var(--teal-deep));
  box-shadow: 0 12px 26px -16px var(--teal);
}
.order.is-active .order-sub{ color: #CFF6F2; }
.order img{
  width: 38px; height: 42px; flex: none;
  border-radius: 8px; object-fit: cover;
  background: var(--surface-2);
}
.order-info{ min-width: 0; }
.order-name{ font-size: 12.5px; font-weight: 600; }
.order-sub{
  font-size: 11px; color: var(--text-faint);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.order-code{ margin-left: auto; font-size: 11.5px; font-weight: 600; color: var(--text-dim); }
.order.is-active .order-code{ color: #fff; }

/* ── Datos del jugador (cajerosEZ) ── */
.jugador-stats{ display: flex; flex-direction: column; gap: 2px; padding: 0 2px; }
.jstat{
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 8px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}
.jstat:last-child{ border-bottom: 0; }
.jstat-label{ color: var(--text-dim); }
.jstat-value{ font-weight: 600; }
.jstat-value.up{ color: var(--teal-bright); }
.jstat-value.down{ color: var(--alert); }
#jExcluidoRow{
  justify-content: flex-start;
  color: var(--amber); font-weight: 600;
  border-bottom: 0;
}
.jstat-big{
  padding: 12px 8px;
  margin: 2px 0;
  border-radius: var(--r-sm);
  background: var(--teal-soft);
  border-bottom: 0;
}
.jstat-big .jstat-label{ color: var(--text); font-weight: 600; }
.jstat-big .jstat-value{ font-size: 15px; color: var(--teal-bright); }
.jstat-updated{ border-bottom: 0; }
.jstat-value.muted{ font-weight: 400; color: var(--text-faint); font-size: 11px; }

/* ── Checklist de plataformas + acciones (placeholder, ver comentario en app.js) ── */
.platform-checklist{
  margin: 0 0 14px; padding: 0 2px;
  list-style: none;
  display: flex; flex-direction: column; gap: 6px;
}
.platform-item{
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: rgba(6,22,32,.3);
}
.platform-check{
  display: grid; place-items: center;
  width: 18px; height: 18px; flex: none;
  border-radius: 5px;
  background: var(--teal);
  color: #04262A;
  font-size: 12px; font-weight: 700;
}
.platform-name{ font-size: 12.5px; font-weight: 600; letter-spacing: .01em; }

.action-btns{ display: flex; flex-direction: column; gap: 8px; padding: 0 2px; }
.action-btn{
  width: 100%;
  padding: 12px;
  border: 0; border-radius: var(--r-sm);
  font-size: 13px; font-weight: 700; letter-spacing: .02em;
  color: #fff;
  transition: filter .15s;
}
.action-btn:hover{ filter: brightness(1.1); }
.action-btn:active{ filter: brightness(.92); }
.action-carga{
  background: linear-gradient(135deg, #2FD46B, #1C9C4C);
  box-shadow: 0 10px 22px -12px #1C9C4C;
}
.action-descarga{
  background: linear-gradient(135deg, #F0555B, #C6333A);
  box-shadow: 0 10px 22px -12px #C6333A;
}

/* ── Vista placeholder (Panel / Jugadores / Alertas / Ayuda) ── */
.placeholder-view{
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px;
  margin: 0 20px 20px;
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  text-align: center;
}
.placeholder-icon{ font-size: 34px; margin-bottom: 4px; opacity: .8; }
.placeholder-view h2{ margin: 0; font-size: 17px; }
.placeholder-view .muted{ max-width: 340px; }

/* ══════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════ */
@media (max-width: 1180px){
  .workspace{ grid-template-columns: var(--inbox-w) 1fr; }
  .profile{ display: none; }
}
@media (max-width: 880px){
  .app{ grid-template-columns: 64px 1fr; border-radius: 0; border: 0; height: 100dvh; }
  .brand-name, .nav-item span{ display: none; }
  .nav-item{ justify-content: center; }
  .workspace{ grid-template-columns: 1fr; padding: 0 12px 12px; }
  .inbox{ display: none; }
  .msg{ max-width: 88%; }
}

@media (prefers-reduced-motion: reduce){
  *{ animation: none !important; transition: none !important; }
}

:focus-visible{ outline: 2px solid var(--teal-bright); outline-offset: 2px; }

/* ══════════════════════════════════════════
   LOGIN
   ══════════════════════════════════════════ */
.login-screen{
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
}
.login-card{
  width: 100%; max-width: 340px;
  padding: 32px 28px;
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  text-align: center;
}
.login-card h1{ margin: 0 0 4px; font-size: 20px; }
.login-card .muted{ margin: 0 0 22px; }
.login-card label{
  display: block; text-align: left;
  font-size: 12.5px; color: var(--text-dim);
  margin-bottom: 14px;
}
.login-card input{
  display: block; width: 100%; margin-top: 6px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: rgba(6,22,32,.4);
  color: var(--text); font: inherit;
}
.login-card input:focus{ outline: none; border-color: var(--teal); }
.login-error{
  margin: 14px 0 0; padding: 9px 12px;
  border-radius: var(--r-sm);
  background: rgba(240,85,91,.12);
  color: var(--alert);
  font-size: 12.5px;
}

/* ══════════════════════════════════════════
   EMPTY STATE
   ══════════════════════════════════════════ */
.empty-state{
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-faint);
  font-size: 13px;
}

/* ══════════════════════════════════════════
   CONFIGURACIÓN (Canales / Plantillas / Bots y automatizaciones)
   ══════════════════════════════════════════ */
.config-view{
  flex: 1;
  display: flex; flex-direction: column;
  min-height: 0;
  margin: 0 20px 20px;
  overflow-y: auto;
}

.config-tabs{
  display: flex; gap: 8px;
  margin-bottom: 18px;
}
.config-tab{
  padding: 9px 18px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--surface-1);
  color: var(--text-dim);
  font-size: 13px; font-weight: 600;
  transition: background .16s, color .16s, border-color .16s;
}
.config-tab:hover{ border-color: var(--line-strong); color: var(--text); }
.config-tab.is-active{
  background: var(--teal-soft);
  border-color: var(--teal);
  color: var(--teal-bright);
}

.config-panel{
  padding: 20px;
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.config-panel-head{
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.config-panel-head h3{ margin: 0 0 4px; font-size: 15px; font-weight: 700; }
.config-panel-head .muted{ max-width: 460px; }
.config-panel-head-2{ margin-top: 30px; padding-top: 24px; border-top: 1px solid var(--line); }

.empty-list{ padding: 10px 2px 18px; font-size: 12.5px; }

/* ── Canales ── */
.channel-grid{
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}
.channel-card{
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: rgba(6,22,32,.3);
}
.channel-card-top{ display: flex; align-items: center; gap: 10px; }
.channel-icon{
  display: grid; place-items: center;
  width: 36px; height: 36px; flex: none;
  border-radius: 10px;
  font-size: 17px;
  background: var(--surface-2);
}
.channel-name{ font-size: 13px; font-weight: 700; }
.channel-type{ font-size: 11px; color: var(--text-faint); text-transform: capitalize; }
.channel-card.is-connected .channel-icon{ background: var(--teal-soft); }
.channel-status{
  align-self: flex-start;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 10.5px; font-weight: 700;
}
.channel-status.on{ background: rgba(47,212,196,.14); color: var(--teal-bright); }
.channel-status.off{ background: rgba(255,255,255,.06); color: var(--text-faint); }
.channel-card .btn{ align-self: flex-start; padding: 7px 14px; font-size: 12px; }
.channel-card .btn-ghost{
  background: transparent; border: 1px solid var(--line); color: var(--text-dim);
}
.channel-card .btn-ghost:hover{ border-color: var(--line-strong); color: var(--text); }

/* ── Listas tipo tabla (plantillas / automatizaciones / bots) ── */
.table-list{ display: flex; flex-direction: column; gap: 8px; }
.list-row{
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: rgba(6,22,32,.3);
}
.list-row-main{ flex: 1; min-width: 0; }
.list-row-title{ font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.list-row-sub{ margin-top: 2px; font-size: 11.5px; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row-actions{ display: flex; align-items: center; gap: 8px; flex: none; }
.row-btn{
  display: grid; place-items: center;
  width: 30px; height: 30px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-dim);
}
.row-btn:hover{ color: var(--text); border-color: var(--line-strong); }
.row-btn.danger:hover{ color: var(--alert); border-color: var(--alert); }
.row-btn svg{ width: 14px; height: 14px; }

.tag{
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 10px; font-weight: 700;
  background: var(--surface-2); color: var(--text-dim);
}
.tag.on{ background: rgba(47,212,196,.14); color: var(--teal-bright); }
.tag.off{ background: rgba(255,255,255,.06); color: var(--text-faint); }

/* ── Toggle switch (activo/inactivo) ── */
.toggle{
  position: relative;
  width: 36px; height: 20px; flex: none;
  border-radius: 99px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  transition: background .16s;
}
.toggle::after{
  content: "";
  position: absolute; top: 1px; left: 1px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: transform .16s, background .16s;
}
.toggle.is-on{ background: var(--teal-soft); border-color: var(--teal); }
.toggle.is-on::after{ transform: translateX(16px); background: var(--teal-bright); }

/* ── Modal genérico ── */
.modal-overlay{
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(3,12,17,.6);
  backdrop-filter: blur(2px);
  z-index: 50;
}
.modal{
  width: 100%; max-width: 460px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 22px;
  background: var(--surface-1);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}
.modal-head{
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.modal-head h3{ margin: 0; font-size: 16px; }
.modal-close{
  display: grid; place-items: center;
  width: 30px; height: 30px;
  border: 0; border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-dim);
}
.modal-close:hover{ color: var(--text); }

.field{ display: block; margin-bottom: 14px; font-size: 12.5px; color: var(--text-dim); }
.field span{ display: block; margin-bottom: 6px; }
.field input[type="text"],
.field input[type="url"],
.field textarea,
.field select{
  display: block; width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: rgba(6,22,32,.4);
  color: var(--text); font: inherit;
}
.field input:focus, .field textarea:focus, .field select:focus{ outline: none; border-color: var(--teal); }
.field textarea{ resize: vertical; min-height: 70px; }
.field-check{ display: flex; align-items: center; gap: 9px; font-size: 12.5px; color: var(--text-dim); margin-bottom: 14px; }
.field-hint{ margin: -8px 0 14px; font-size: 11px; color: var(--text-faint); }
.modal code{
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(255,255,255,.08);
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 11px;
}
.field-error{
  margin: -6px 0 14px; padding: 8px 11px;
  border-radius: var(--r-sm);
  background: rgba(240,85,91,.12);
  color: var(--alert);
  font-size: 12px;
}

.type-grid{
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 6px;
}
.type-card{
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: rgba(6,22,32,.3);
  text-align: left;
  transition: border-color .16s, background .16s;
}
.type-card:hover{ border-color: var(--teal); background: var(--teal-soft); }
.type-card .channel-icon{ width: 30px; height: 30px; font-size: 14px; }
.type-card-name{ font-size: 12.5px; font-weight: 700; }
.type-card-sub{ font-size: 10.5px; color: var(--text-faint); }

.builder-rows{ display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.builder-row{
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 6px;
  align-items: center;
}
.builder-row select, .builder-row input{
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(6,22,32,.4);
  color: var(--text); font: inherit; font-size: 12px;
  width: 100%;
}
.builder-remove{
  display: grid; place-items: center;
  width: 26px; height: 26px; flex: none;
  border: 0; border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-faint);
}
.builder-remove:hover{ color: var(--alert); }
.builder-add{
  align-self: flex-start;
  padding: 6px 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 99px;
  background: transparent;
  color: var(--text-dim);
  font-size: 11.5px; font-weight: 600;
  margin-bottom: 16px;
}
.builder-add:hover{ color: var(--teal-bright); border-color: var(--teal); }
.builder-label{ font-size: 11px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em; margin: 0 0 8px; }

.modal-actions{
  display: flex; justify-content: flex-end; gap: 10px;
  margin-top: 6px;
}
.btn-secondary{
  background: var(--surface-2);
  color: var(--text-dim);
  border: 1px solid var(--line);
}
.btn-secondary:hover{ color: var(--text); border-color: var(--line-strong); }
