:root {
    --bg: #0f0f0f;
    --bg-header: #0d1d30;
    --card: #1e1e1e;
    --card-alt: #222;
    --red: #e53935;
    --green: #4caf50;
    --yellow: #fbc02d;
    --gray: #9e9e9e;
    --shadow: 0 10px 30px rgba(0, 0, 0, .35);
    --row-h: 44px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', sans-serif;
    color: #fff
}

body {
    background: var(--bg)
}

/* === LOGIN === */
#loginScreen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-header);
    padding: 24px;
}

#loginBox {
    background: var(--card);
    padding: 30px;
    border-radius: 10px;
    box-shadow: var(--shadow);
    width: 320px;
    text-align: center;
}

#loginBox h2 {
    margin-bottom: 18px
}

#loginBox input {
    width: 100%;
    padding: 10px;
    margin: 8px 0;
    background: var(--card-alt);
    border: 1px solid #444;
    border-radius: 6px;
    color: #fff
}

#loginBox button {
    width: 100%;
    padding: 10px;
    margin-top: 10px;
    border: 0;
    border-radius: 6px;
    background: var(--red);
    font-weight: 600;
    cursor: pointer
}

#loginError {
    color: var(--yellow);
    font-size: 13px;
    margin-top: 10px;
    min-height: 18px
}

/* === APP PRINCIPAL === */
#app {
    display: none
}

header {
    background: var(--bg-header);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 24px;
    border-bottom: 3px solid var(--red);
    position: sticky;
    top: 0;
    z-index: 10;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 20px
}

.logo i {
    background: var(--red);
    padding: 10px;
    border-radius: 50%
}

.logo small {
    font-size: 12px;
    color: var(--gray);
    display: block
}

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

.hdr-btn {
    background: var(--gray);
    border: 0;
    border-radius: 6px;
    padding: 8px 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer
}

.hdr-btn.red {
    background: var(--red)
}

#logoutBtn {
    margin-left: 12px;
    background: var(--red) !important
}

/* Date nav */
.date-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px 24px;
    background: var(--card)
}

.date-nav button {
    background: none;
    border: 0;
    font-size: 20px;
    cursor: pointer;
    color: var(--gray)
}

#selectedDate {
    font-size: 16px;
    font-weight: 600
}

#currentTime {
    font-size: 14px;
    color: var(--yellow);
    margin-left: 20px
}

/* KPIs */
.kpis {
    display: flex;
    gap: 20px;
    margin: 24px;
    flex-wrap: wrap
}

.kpi {
    flex: 1 1 250px;
    background: var(--card);
    border-radius: 10px;
    padding: 22px;
    position: relative;
    min-width: 220px
}

.kpi i {
    position: absolute;
    right: 18px;
    top: 18px;
    color: var(--gray);
    font-size: 24px
}

.kpi h5 {
    font-size: 14px;
    color: var(--gray);
    margin-bottom: 6px
}

.kpi .val {
    font-size: 30px;
    font-weight: 700
}

/* Filtros */
.filters {
    display: flex;
    gap: 10px;
    margin: 0 24px 18px;
    align-items: center;
    flex-wrap: wrap
}

.searchWrap {
    flex: 1 1 240px;
    position: relative
}

.searchWrap i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray)
}

.search {
    width: 100%;
    padding: 9px 12px 9px 34px;
    background: var(--card-alt);
    border: 0;
    border-radius: 6px;
    color: #fff
}

select {
    padding: 9px 12px;
    background: var(--card-alt);
    border: 0;
    border-radius: 6px;
    color: #fff
}

/* Tabla */
.section {
    margin: 0 24px 32px
}

.section h3 {
    margin-bottom: 8px
}

.tableWrap {
    background: var(--card);
    border-radius: 10px;
    overflow: auto;
    max-width: 100%
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    min-width: 960px
}

th,
td {
    padding: 14px 18px;
    text-align: left
}

th {
    background: #181818;
    color: var(--gray)
}

tbody tr:nth-child(even) {
    background: var(--card-alt)
}

.avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--red);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    margin-right: 6px
}

.pill {
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    display: inline-block
}

.activo {
    background: var(--green)
}

.inactivo {
    background: #666
}

.licencia {
    background: var(--yellow);
    color: #000
}

/* Config / Export */
.export-wrap {
    position: relative
}

.export-menu {
    position: absolute;
    right: 0;
    top: 110%;
    background: var(--card);
    border: 1px solid #2a2a2a;
    border-radius: 10px;
    padding: 14px;
    width: 420px;
    box-shadow: var(--shadow);
    display: none
}

.export-menu.open {
    display: block
}

.row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px
}

.row.col {
    flex-direction: column;
    align-items: stretch
}

.sub {
    font-size: 12px;
    color: var(--gray);
    margin-top: 2px
}

.btn {
    background: var(--red);
    border: 0;
    border-radius: 6px;
    padding: 8px 12px;
    font-weight: 600;
    cursor: pointer
}

.btn.outline {
    background: transparent;
    border: 1px solid #444
}

.hint {
    font-size: 12px;
    color: var(--gray);
    margin-top: 8px
}

.mini {
    font-size: 12px;
    opacity: .8
}

.fld {
    width: 100%;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #444;
    background: #121212;
    color: #fff
}

.split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%
}

.notice {
    font-size: 12px;
    color: var(--yellow)
}

.mt-8 {
    margin-top: 8px
}

.hr {
    border: 0;
    border-top: 1px solid #333;
    margin: 8px 0
}



.pill.area {
  background: var(--card-alt);
  border: 1px solid #444;
  color: #fff;
  padding: 2px 8px;       /* más chico que el estado */
  font-size: 11px;        /* mini */
  margin-left: 6px;       /* separadito de la hora */
  vertical-align: baseline;
}
.pill.area.mini { font-size: 11px; padding: 2px 8px; }

/* ===================================== */
/*   ASISTENTE IA – BURBUJA + SIDEBAR    */
/* ===================================== */

/* Utilidad para ocultar cosas (typing) */
.hidden {
  display: none !important;
}

/* Panel lateral del bot */
.bot-sidebar {
  position: fixed;
  top: 0;
  right: -500px;
  width: 500px;
  height: 100vh;
  background: #05070c;
  border-left: 1px solid #20232b;
  z-index: 100;
  transition: right 0.3s ease;
  display: flex;
  flex-direction: column;
  box-shadow: -5px 0 20px rgba(0, 0, 0, 0.6);
}

.bot-sidebar.open {
  right: 0;
}

/* Header del bot */
.bot-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #0b1724;
  border-bottom: 1px solid #20232b;
}

.bot-sidebar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 15px;
}

.bot-sidebar-title .dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.2);
}

.bot-sidebar-close {
  background: transparent;
  border: none;
  color: #9e9e9e;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bot-sidebar-close:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

/* Cuerpo del chat */
.bot-sidebar-body {
  flex: 1;
  overflow: auto;
  padding: 16px;
}

.bot-sidebar-chat {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 100%;
}

.bot-sidebar-message {
  display: flex;
  gap: 8px;
}

.bot-sidebar-message.user {
  flex-direction: row-reverse;
}

/* Avatar */
.bot-sidebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111827;
  border: 1px solid #20232b;
  font-size: 16px;
  flex-shrink: 0;
}

/* Burbuja */
.bot-sidebar-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 14px;
  background: #111827;
  border: 1px solid #20232b;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  font-size: 13px;
  line-height: 1.4;
}

.bot-sidebar-message.user .bot-sidebar-bubble {
  background: #1e3a8a;
  border-color: #3b82f6;
}

/* Hora del mensaje */
.bot-sidebar-message-time {
  margin-top: 4px;
  font-size: 11px;
  opacity: 0.6;
}

/* Indicador “escribiendo…” */
.bot-sidebar-typing {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px 12px;
  border-top: 1px solid #20232b;
  font-size: 12px;
  color: var(--gray);
}

.bot-sidebar-typing-dots {
  display: flex;
  gap: 4px;
}

.bot-sidebar-typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #9e9e9e;
  animation: bot-typing 1s infinite ease-in-out;
}

.bot-sidebar-typing-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.bot-sidebar-typing-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes bot-typing {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40% { transform: translateY(-3px); opacity: 1; }
}

/* Composer (textarea + botón enviar) */
.bot-sidebar-composer {
  border-top: 1px solid #20232b;
  padding: 10px 12px;
  background: #05070c;
}

.bot-sidebar-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.bot-sidebar-input {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  padding: 8px 10px;
  border-radius: 8px;
  resize: vertical;
  border: 1px solid #333;
  background: #0b0b0b;
  font-size: 13px;
  line-height: 1.35;
}

.bot-sidebar-input::placeholder {
  color: #777;
}

.bot-sidebar-send {
  background: var(--red);
  border: none;
  border-radius: 8px;
  padding: 9px 14px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

.bot-sidebar-send:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Resizer lateral */
.bot-sidebar-resizer {
  position: absolute;
  top: 0;
  left: -4px;
  width: 4px;
  height: 100%;
  cursor: ew-resize;
  background: transparent;
}

.bot-sidebar-resizer:hover {
  background: rgba(255, 255, 255, 0.08);
}

.bot-sidebar-resizer.dragging {
  background: rgba(255, 255, 255, 0.16);
}

/* Overlay cuando el panel está abierto */
.bot-sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.45);
  z-index: 90;
  display: none;
}

.bot-sidebar-overlay.open {
  display: block;
}

/* Botón flotante (burbuja) abajo a la derecha */
.bot-sidebar-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  background: #1e3a8a;
  color: #fff;
  border: none;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 99;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.55);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.bot-sidebar-launcher:hover {
  background: #1e40af;
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.7);
}

.bot-sidebar-launcher-icon {
  font-size: 1.4rem;
}

/* Responsive: en mobile ocupa todo el ancho */
@media (max-width: 768px) {
  .bot-sidebar {
    width: 100%;
    right: -100%;
  }

  .bot-sidebar.open {
    right: 0;
  }

  .bot-sidebar-resizer {
    display: none;
  }
}

