/**
 * StelPilot — Design System
 * Réplica del estilo visual de STEL Order
 * Colores, tipografía, componentes y layout
 */

/* ============================================================
   GOOGLE FONTS
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap');

/* ============================================================
   VARIABLES (STEL ORDER COLOR SYSTEM)
   ============================================================ */
:root {
  /* Colores principales */
  --stel-orange:        #f58220;
  --stel-orange-dark:   #d96e10;
  --stel-orange-hover:  #e07518;
  --stel-orange-light:  #fff3e8;
  --stel-orange-pale:   #fef9f5;
  --stel-navy:          #1e1e30;
  --stel-navy-hover:    #2a2a3e;

  /* Grises y fondos */
  --bg-page:            #f5f6fa;
  --bg-card:            #ffffff;
  --bg-sidebar:         #ffffff;
  --bg-input:           #f3f4f6;
  --bg-input-focus:     #ffffff;
  --bg-row-hover:       #f9fafb;
  --bg-header-row:      #f8f9fa;

  /* Bordes */
  --border-light:       #e8eaed;
  --border-medium:      #d1d5db;
  --border-focus:       #f58220;

  /* Textos */
  --text-dark:          #1f2937;
  --text-mid:           #4b5563;
  --text-light:         #6b7280;
  --text-placeholder:   #9ca3af;
  --text-white:         #ffffff;

  /* Estados */
  --success:            #10b981;
  --success-bg:         #d1fae5;
  --warning:            #f59e0b;
  --warning-bg:         #fef3c7;
  --error:              #ef4444;
  --error-bg:           #fee2e2;
  --info:               #3b82f6;
  --info-bg:            #dbeafe;

  /* Layout */
  --topbar-height:      44px;
  --sidebar-width:      160px;
  --content-padding:    20px;

  /* Radios y sombras */
  --radius-sm:          4px;
  --radius-md:          6px;
  --radius-lg:          8px;
  --radius-pill:        20px;
  --shadow-sm:          0 1px 3px rgba(0,0,0,0.08);
  --shadow-md:          0 2px 8px rgba(0,0,0,0.10);
  --shadow-lg:          0 4px 20px rgba(0,0,0,0.12);

  /* Tipografía */
  --font:               'Roboto', 'Helvetica Neue', Arial, sans-serif;
  --font-size-xs:       11px;
  --font-size-sm:       12px;
  --font-size-base:     14px;
  --font-size-md:       15px;
  --font-size-lg:       18px;
  --font-size-xl:       24px;
  --font-size-2xl:      32px;
}

/* ============================================================
   RESET Y BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: var(--font-size-base);
  color: var(--text-dark);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--stel-orange); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================================================
   LAYOUT PRINCIPAL (idéntico a STEL Order)
   ============================================================ */

/* Top Navigation Bar */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-height);
  background: var(--stel-navy);
  border-bottom: 2px solid #3b82f6;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 16px;
  z-index: 1000;
  box-shadow: 0 2px 15px rgba(59, 130, 246, 0.4);
  gap: 0;
}


.topbar__logo {
  color: white;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.3px;
  margin-right: 24px;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar__logo-icon {
  width: 24px;
  height: 24px;
  background: var(--stel-orange);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.topbar__nav {
  display: flex;
  align-items: stretch;
  height: 100%;
  flex: 1;
}

.topbar__nav-item {
  display: flex;
  align-items: center;
  padding: 0 14px;
  color: rgba(255,255,255,0.85);
  font-size: 13px;
  font-weight: 400;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s;
  text-decoration: none;
  border-bottom: 3px solid transparent;
}

.topbar__nav-item:hover {
  color: white;
  text-decoration: none;
  background: var(--stel-navy-hover);
}

.topbar__nav-item.active {
  background: linear-gradient(180deg, rgba(249,115,22,0.1) 0%, rgba(249,115,22,0.8) 100%);
  color: white;
  font-weight: 600;
  border-bottom: 3px solid var(--stel-orange);
  box-shadow: inset 0 -3px 10px rgba(249,115,22,0.5), 0 5px 15px rgba(249,115,22,0.4);
}

.topbar__right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.topbar__avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--stel-orange);
  color: white;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
}

.topbar__user-name {
  color: rgba(255,255,255,0.8);
  font-size: 12px;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Sidebar izquierdo */
.sidebar {
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-light);
  overflow-y: auto;
  padding: 8px 0;
  z-index: 900;
}

.sidebar__item {
  display: block;
  padding: 9px 16px;
  font-size: 13px;
  color: var(--text-mid);
  cursor: pointer;
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: all 0.1s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: relative;
  z-index: 1;
}

.sidebar__item::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg-row-hover);
  opacity: 0;
  z-index: -1;
  transition: opacity 0.3s ease;
}

.sidebar__item:hover::before {
  opacity: 1;
}

.sidebar__item.active {
  color: var(--text-dark);
  font-weight: 600;
  border-left-color: var(--stel-orange);
  background: var(--stel-orange-pale);
  box-shadow: inset 4px 0 10px rgba(249, 115, 22, 0.1);
  position: relative;
}

.sidebar__item.active::after {
  content: '';
  position: absolute;
  left: -3px; top: 0; bottom: 0; width: 3px;
  background: var(--stel-orange);
  box-shadow: 0 0 8px var(--stel-orange), 0 0 12px var(--stel-orange);
  border-radius: 0 2px 2px 0;
}

/* Electric effect specifically for automations group */
div[data-group="automations"] .sidebar__item.active::after {
  background: #a855f7;
  box-shadow: 0 0 8px #a855f7, 0 0 12px #c084fc, 0 0 20px #e879f9;
}
div[data-group="automations"] .sidebar__item.active {
  border-left-color: #a855f7;
  background: rgba(168, 85, 247, 0.05);
}

/* Contenido principal */
.main-content {
  margin-top: var(--topbar-height);
  margin-left: var(--sidebar-width);
  min-height: calc(100vh - var(--topbar-height));
  background: var(--bg-page);
}

/* Barra de herramientas de página (Nuevo + | Más | Filtrar | Buscar) */
.page-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px var(--content-padding);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-light);
  flex-wrap: wrap;
}

.page-toolbar__right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-content {
  padding: var(--content-padding);
}

/* ============================================================
   BOTONES (réplica exacta de STEL Order)
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
}

/* Primario: naranja (Nuevo +, guardar) */
.btn-primary {
  background: var(--stel-orange);
  color: white;
  border-color: var(--stel-orange);
}
.btn-primary:hover {
  background: var(--stel-orange-hover);
  border-color: var(--stel-orange-hover);
  text-decoration: none;
  color: white;
}

/* Secundario: fondo blanco, borde gris (Más, Volver, Cancelar) */
.btn-secondary {
  background: white;
  color: var(--text-mid);
  border-color: var(--border-medium);
}
.btn-secondary:hover {
  background: var(--bg-row-hover);
  color: var(--text-dark);
  text-decoration: none;
}

/* Peligro: rojo */
.btn-danger {
  background: white;
  color: var(--error);
  border-color: var(--error);
}
.btn-danger:hover {
  background: var(--error-bg);
  text-decoration: none;
}

/* Ghost: sin borde, solo texto */
.btn-ghost {
  background: transparent;
  color: var(--stel-orange);
  border-color: transparent;
  padding: 4px 8px;
}
.btn-ghost:hover {
  background: var(--stel-orange-light);
  text-decoration: none;
}

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 9px 20px; font-size: 15px; }

/* ============================================================
   TARJETAS / CARDS
   ============================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dark);
}

.card-body { padding: 16px; }

/* ============================================================
   FORMULARIOS E INPUTS (estilo STEL Order)
   ============================================================ */
.form-group {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dark);
  min-width: 120px;
  padding-top: 7px;
  white-space: nowrap;
}

.form-label .required {
  color: var(--error);
  margin-left: 2px;
}

.form-control {
  flex: 1;
  height: 32px;
  padding: 5px 10px;
  font-size: 13px;
  font-family: var(--font);
  color: var(--text-dark);
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
  width: 100%;
}

.form-control:focus {
  border-color: var(--border-focus);
  background: var(--bg-input-focus);
}

.form-control::placeholder { color: var(--text-placeholder); }

textarea.form-control {
  height: auto;
  min-height: 80px;
  resize: vertical;
  padding-top: 8px;
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%239ca3af'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  cursor: pointer;
}

/* ============================================================
   TABLAS (réplica de STEL Order: header, búsqueda, filas)
   ============================================================ */
.stel-table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.stel-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

/* Header de columnas */
.stel-table thead tr:first-child th {
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dark);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-light);
  text-align: left;
  white-space: nowrap;
  user-select: none;
}

.stel-table thead th .sort-icon {
  display: inline-block;
  margin-left: 4px;
  color: var(--stel-orange);
  font-size: 10px;
}

/* Fila de búsqueda debajo del header (característica STEL) */
.stel-table thead tr.search-row th {
  padding: 4px 8px;
  background: var(--bg-header-row);
  border-bottom: 1px solid var(--border-light);
}

.stel-table thead tr.search-row input {
  width: 100%;
  padding: 3px 8px;
  font-size: 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-dark);
  outline: none;
}
.stel-table thead tr.search-row input:focus { border-color: var(--stel-orange); }
.stel-table thead tr.search-row input::placeholder { color: var(--text-placeholder); }

/* Filas de datos */
.stel-table tbody tr {
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background 0.1s;
}

.stel-table tbody tr:hover { background: var(--bg-row-hover); }
.stel-table tbody tr:last-child { border-bottom: none; }
.stel-table tbody tr.clickable { cursor: pointer; }
.stel-table tbody tr.clickable:hover { background: var(--stel-orange-pale); }

.stel-table td {
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text-dark);
  vertical-align: middle;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stel-table td.bold { font-weight: 600; }

/* Checkbox */
.stel-table .cb-col { width: 36px; }
.stel-table input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--stel-orange);
  cursor: pointer;
}

/* Paginación */
.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg-card);
  border-top: 1px solid var(--border-light);
  font-size: 12px;
  color: var(--text-light);
}

.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pagination a, .pagination span {
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-mid);
  cursor: pointer;
}
.pagination a:hover { background: var(--bg-row-hover); text-decoration: none; }
.pagination a.active { background: var(--stel-orange); color: white; }

/* ============================================================
   BADGES / PILLS DE ESTADO (estilo STEL Order)
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* Estados de incidencias */
.badge-pending   { background: var(--warning-bg);  color: #92400e; }
.badge-open      { background: var(--info-bg);     color: #1e40af; }
.badge-progress  { background: #ede9fe;            color: #5b21b6; }
.badge-done      { background: var(--success-bg);  color: #065f46; }
.badge-cancelled { background: #f3f4f6;            color: #6b7280; }
.badge-paid      { background: var(--success-bg);  color: #065f46; }
.badge-sent      { background: var(--info-bg);     color: #1e40af; }
.badge-overdue   { background: var(--error-bg);    color: #991b1b; }

/* Prioridades */
.badge-normal  { background: var(--warning-bg); color: #78350f; }
.badge-high    { background: #fee2e2;           color: #991b1b; }
.badge-low     { background: #f3f4f6;           color: #374151; }

/* Dashboard extras */
.badge-warn  { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }
.badge-info  { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }

/* form-input: alias of form-control used in dashboard modals */
.form-input {
  display: block;
  width: 100%;
  padding: 7px 10px;
  font-size: 13px;
  font-family: var(--font);
  color: var(--text-dark);
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
}
.form-input:focus { border-color: var(--stel-orange); }
.form-input::placeholder { color: var(--text-placeholder); }
textarea.form-input { min-height: 80px; resize: vertical; }
select.form-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%239ca3af'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  cursor: pointer;
}

/* ============================================================
   TABS (estilo STEL Order — underline naranja)
   ============================================================ */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-card);
  padding: 0 16px;
}

.tab-item {
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-light);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: all 0.15s;
  text-decoration: none;
}

.tab-item:hover { color: var(--text-dark); text-decoration: none; }
.tab-item.active { color: var(--stel-orange); border-bottom-color: var(--stel-orange); font-weight: 600; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ============================================================
   MODALES
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.show {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  transform: translateY(-10px);
  transition: transform 0.2s;
}

.modal-overlay.show .modal { transform: translateY(0); }
.modal-lg { max-width: 800px; }

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-dark);
}

.modal-close {
  width: 28px;
  height: 28px;
  border: none;
  background: var(--bg-input);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--text-light);
  transition: all 0.1s;
}
.modal-close:hover { background: var(--border-medium); color: var(--text-dark); }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ============================================================
   DROPDOWNS / MENÚ MÁS
   ============================================================ */
.dropdown {
  position: relative;
  display: inline-flex;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: white;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  min-width: 160px;
  z-index: 1500;
  display: none;
  overflow: hidden;
}

.dropdown-menu.show { display: block; }

.dropdown-item {
  display: block;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text-dark);
  cursor: pointer;
  transition: background 0.1s;
  text-decoration: none;
}
.dropdown-item:hover { background: var(--bg-row-hover); text-decoration: none; }
.dropdown-item.danger { color: var(--error); }
.dropdown-sep { height: 1px; background: var(--border-light); margin: 4px 0; }

/* ============================================================
   DASHBOARD KPI CARDS
   ============================================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: box-shadow 0.15s;
}

.kpi-card:hover { box-shadow: var(--shadow-md); }

.kpi-card__left {}

.kpi-card__value {
  font-size: 28px;
  font-weight: 700;
  color: var(--stel-orange);
  line-height: 1.1;
}

.kpi-card__label {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 4px;
}

.kpi-card__icon {
  width: 40px;
  height: 40px;
  background: var(--stel-orange-light);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

/* ============================================================
   FICHA DE REGISTRO (estilo STEL Order — ver incidencia)
   ============================================================ */
.record-header {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: 0;
  overflow: hidden;
}

.record-header__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
}

.record-header__actions { display: flex; gap: 8px; align-items: center; }

.record-header__date {
  font-size: 12px;
  color: var(--text-light);
  display: flex;
  align-items: center;
  gap: 4px;
}

.record-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-dark);
  padding: 16px 16px 8px;
}

.record-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  padding: 8px 16px 16px;
}

.record-field {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 16px 6px 0;
}

.record-field__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dark);
  min-width: 100px;
  flex-shrink: 0;
}

.record-field__value {
  font-size: 13px;
  color: var(--text-mid);
  flex: 1;
}

.record-field__actions {
  display: flex;
  gap: 4px;
  margin-left: 4px;
}

/* ============================================================
   FEED DE ACTIVIDAD / TIMELINE
   ============================================================ */
.timeline { list-style: none; }

.timeline-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 12px;
}

.timeline-item:last-child { border-bottom: none; }

.timeline-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--stel-orange);
  flex-shrink: 0;
  margin-top: 4px;
}

.timeline-time {
  color: var(--text-light);
  white-space: nowrap;
  min-width: 50px;
}

.timeline-text { color: var(--text-dark); flex: 1; }

/* ============================================================
   BUSCADOR GLOBAL (en topbar)
   ============================================================ */
.search-input {
  display: flex;
  align-items: center;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 20px;
  padding: 4px 12px;
  gap: 6px;
}

.search-input input {
  background: none;
  border: none;
  outline: none;
  color: white;
  font-size: 12px;
  width: 180px;
}

.search-input input::placeholder { color: rgba(255,255,255,0.5); }
.search-input .icon { color: rgba(255,255,255,0.5); font-size: 12px; }

/* ============================================================
   PÁGINA DE LOGIN
   ============================================================ */
.login-page {
  min-height: 100vh;
  background: var(--bg-page);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: white;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 380px;
  padding: 36px 32px;
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo__icon {
  width: 52px;
  height: 52px;
  background: var(--stel-navy);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 10px;
  font-size: 22px;
}

.login-logo__title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-dark);
}

.login-logo__subtitle {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 2px;
}

.login-form .form-group { display: block; margin-bottom: 16px; }
.login-form .form-label { display: block; margin-bottom: 6px; min-width: auto; padding-top: 0; }
.login-form .form-control { height: 38px; }

.login-btn {
  width: 100%;
  height: 40px;
  background: var(--stel-navy);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 20px;
  transition: background 0.15s;
}
.login-btn:hover { background: var(--stel-navy-hover); }

.login-error {
  background: var(--error-bg);
  color: #991b1b;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}
.login-error.show { display: block; }

.login-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 11px;
  color: var(--text-light);
}

/* ============================================================
   CHAT DE ARIANA (bot flotante)
   ============================================================ */
.chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 52px;
  height: 52px;
  background: var(--stel-orange);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(245,130,32,0.4);
  z-index: 1800;
  transition: transform 0.2s, box-shadow 0.2s;
  font-size: 22px;
}
.chat-fab:hover { transform: scale(1.08); box-shadow: 0 6px 20px rgba(245,130,32,0.5); }

.chat-panel {
  position: fixed;
  bottom: 90px;
  right: 24px;
  width: 340px;
  height: 480px;
  background: white;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 1800;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.9) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s;
}

.chat-panel.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

.chat-panel__header {
  background: var(--stel-navy);
  color: white;
  padding: 14px 16px;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-panel__messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-msg {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.4;
}

.chat-msg.user {
  background: var(--stel-navy);
  color: white;
  border-radius: 12px 12px 0 12px;
  align-self: flex-end;
}

.chat-msg.ai {
  background: var(--bg-input);
  color: var(--text-dark);
  border-radius: 12px 12px 12px 0;
  align-self: flex-start;
}

.chat-panel__input {
  padding: 10px 12px;
  border-top: 1px solid var(--border-light);
  display: flex;
  gap: 8px;
}

.chat-panel__input input {
  flex: 1;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border-medium);
  border-radius: 20px;
  font-size: 13px;
  outline: none;
}
.chat-panel__input input:focus { border-color: var(--stel-orange); }

.chat-panel__input button {
  width: 34px;
  height: 34px;
  background: var(--stel-orange);
  border: none;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================================
   KANBAN (vista alternativa de incidencias)
   ============================================================ */
.kanban {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 16px;
}

.kanban-col {
  min-width: 230px;
  background: var(--bg-input);
  border-radius: var(--radius-md);
  overflow: hidden;
  flex-shrink: 0;
}

.kanban-col__header {
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-mid);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kanban-col__count {
  background: var(--bg-card);
  border-radius: var(--radius-pill);
  padding: 1px 8px;
  font-size: 11px;
  color: var(--text-light);
}

.kanban-col__body {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 100px;
}

.kanban-card {
  background: white;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  cursor: pointer;
  transition: box-shadow 0.15s;
}
.kanban-card:hover { box-shadow: var(--shadow-md); }
.kanban-card.dragging { opacity: 0.35; transform: scale(0.97); }

.kanban-col.dragover .kanban-col__body { background: #fef3c7; border-radius: 6px; }
.kanban-col.dragover { background: #fffbf0; }

/* ——— Quick template card (Messages Hub) ——— */
.msg-template-quick {
  padding: 10px 14px;
  margin-bottom: 8px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s;
  background: var(--bg-card);
}
.msg-template-quick:hover {
  border-color: var(--stel-orange);
  background: var(--stel-orange-pale);
}

.kanban-card__ref   { font-size: 11px; color: var(--text-light); font-weight: 600; }
.kanban-card__client{ font-size: 13px; font-weight: 600; margin: 3px 0 2px; }
.kanban-card__desc  { font-size: 12px; color: var(--text-mid); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kanban-card__tech  { font-size: 11px; color: var(--text-light); margin-top: 6px; border-top: 1px solid var(--border-light); padding-top: 5px; }

.kanban-empty {
  text-align: center;
  padding: 24px 12px;
  color: var(--text-placeholder);
  font-size: 12px;
  border: 2px dashed var(--border-light);
  border-radius: var(--radius-md);
  margin: 4px;
}

/* ============================================================
   SLIDE-IN PANEL DE DETALLE DE INCIDENCIA
   ============================================================ */
.slidein-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 1800;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.slidein-overlay.show {
  opacity: 1;
  pointer-events: all;
}

.slidein-panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 500px;
  max-width: 95vw;
  background: var(--bg-card);
  box-shadow: -4px 0 32px rgba(0,0,0,0.16);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
}

.slidein-overlay.show .slidein-panel {
  transform: translateX(0);
}

.slidein-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-card);
  gap: 8px;
  flex-shrink: 0;
}

.slidein-body {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 32px;
}

/* KPIs en el slide-in (row de stats rápidos) */
.slidein-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  border-bottom: 1px solid var(--border-light);
}

.slidein-kpi {
  padding: 12px 14px;
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}

.slidein-kpi:last-child { border-right: none; }

.slidein-kpi__label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Secciones en el slide-in */
.slidein-section {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
}

.slidein-section__label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 4px;
}

.slidein-section__value {
  font-size: 13px;
  color: var(--text-dark);
  line-height: 1.5;
}

/* ============================================================
   UTILITIES
   ============================================================ */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.p-16 { padding: 16px; }
.text-sm { font-size: 12px; }
.text-light { color: var(--text-light); }
.text-orange { color: var(--stel-orange); }
.font-bold { font-weight: 700; }
.font-medium { font-weight: 500; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* Loading spinner */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-medium);
  border-top-color: var(--stel-orange);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.toast {
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.2s ease;
  white-space: nowrap;
}
.toast-success { background: var(--stel-navy); color: white; }
.toast-error   { background: var(--error); color: white; }
.toast-info    { background: var(--info); color: white; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; }
  .record-fields { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .slidein-panel { width: 100vw; }
  .slidein-kpis { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================================
   UNIVERSAL SIDEBAR (USB)
   ============================================================ */

/* Overlay / backdrop */
.usb-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 1100;
    backdrop-filter: blur(2px);
    animation: usbFadeIn .2s ease;
}
.usb-overlay.show { display: block; }

/* Panel */
.usb-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 460px;
    max-width: 100vw;
    height: 100dvh;
    background: var(--bg-card);
    box-shadow: -8px 0 40px rgba(0,0,0,0.18);
    z-index: 1200;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform .3s cubic-bezier(.32,.72,0,1);
    border-left: 1px solid var(--border-light);
}
.usb-panel.open { transform: translateX(0); }

/* Header */
.usb-header {
    display: flex;
    flex-direction: column;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-card);
    flex-shrink: 0;
    position: relative;
}
.usb-header__topbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #f8fafc;
    border-bottom: 1px solid rgba(0,0,0,0.04);
}
.usb-header__main {
    padding: 12px 16px 10px;
}
.usb-header__meta { flex: 1; min-width: 0; }

.usb-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    background: #f1f5f9;
    color: #475569;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}
.usb-badge-orange { background: #fff7ed; color: #c2410c; }
.usb-badge-blue   { background: #eff6ff; color: #1d4ed8; }
.usb-badge-purple { background: #f5f3ff; color: #7c3aed; }
.usb-badge-cyan   { background: #ecfeff; color: #0e7490; }
.usb-badge-green  { background: #f0fdf4; color: #15803d; }

.usb-header__date {
    font-size: 11px;
    color: var(--text-light);
    font-weight: 500;
    margin-left: auto;
}

.usb-title {
    font-size: 17px;
    font-weight: 800;
    color: var(--text-dark);
    line-height: 1.25;
    letter-spacing: -0.3px;
    margin-bottom: 2px;
}
.usb-subtitle {
    font-size: 11px;
    color: var(--text-light);
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.usb-ref {
    font-family: var(--font-mono, monospace);
    background: #f1f5f9;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 10px;
}
.usb-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: var(--text-light);
    padding: 4px 6px;
    line-height: 1;
    border-radius: 6px;
    flex-shrink: 0;
    transition: all .15s;
    position: absolute;
    top: 8px;
    right: 12px;
}
.usb-close-btn:hover { background: #fee2e2; color: #ef4444; }

/* Phone link in header */
.usb-phone-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 6px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    text-decoration: none;
    font-size: 11px;
    font-weight: 600;
    color: #166534;
    transition: all .15s;
}
.usb-phone-link:hover { background: #dcfce7; }
.usb-complete-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 6px;
    border: 1px solid #bbf7d0;
    background: #f0fdf4;
    color: #166534;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: all .15s;
}
.usb-complete-btn:hover { background: #22c55e; color: white; border-color: #22c55e; }

/* Status bar */
.usb-status-bar {
    padding: 8px 16px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-light);
    min-height: 32px;
    flex-shrink: 0;
}

/* Action buttons */
.usb-action-buttons {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-card);
    min-height: 44px;
    flex-shrink: 0;
}

/* Inline selects dentro del action bar de incidencia */
.usb-inline-select {
    width: 100%;
    border: 1px solid var(--border-medium);
    border-radius: 6px;
    padding: 5px 6px;
    font-size: 12px;
    background: var(--bg-input, #f8fafc);
    color: var(--text-dark);
    cursor: pointer;
    transition: border-color .15s;
    appearance: auto;
}
.usb-inline-select:focus   { outline: none; border-color: var(--stel-orange); }
.usb-inline-select:disabled { opacity: 0.5; cursor: not-allowed; }

/* Tabs — rediseño premium */
.usb-tabs {
    display: flex;
    background: var(--bg-card);
    padding: 10px 14px;
    gap: 8px;
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
    overflow-x: auto;
}
.usb-tabs::-webkit-scrollbar { display: none; } /* Ocultar scrollbar horizontal en tabs */
.usb-tab {
    flex: none;
    background: transparent;
    border: 1px solid transparent;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-light);
    cursor: pointer;
    border-radius: 20px;
    transition: all .2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}
.usb-tab:hover {
    color: var(--text-dark);
    background: #f1f5f9;
}
.usb-tab.active {
    color: var(--stel-orange);
    background: rgba(249,115,22,0.1);
    border-color: rgba(249,115,22,0.2);
}

/* Animaciones Premium */
@keyframes usbPulseRing {
    0% { box-shadow: 0 0 0 0 rgba(59,130,246,0.5); }
    70% { box-shadow: 0 0 0 6px rgba(59,130,246,0); }
    100% { box-shadow: 0 0 0 0 rgba(59,130,246,0); }
}
.usb-pulse-ring {
    animation: usbPulseRing 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Tab content */
.usb-tab-content {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

/* KPIs */
.usb-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: 0;
    border-bottom: 1px solid var(--border-light);
}
.usb-kpi {
    padding: 8px 10px;
    text-align: center;
    border-right: 1px solid var(--border-light);
}
.usb-kpi:last-child { border-right: none; }
.usb-kpi__value {
    font-size: 16px;
    font-weight: 800;
    line-height: 1;
}
.usb-kpi__label {
    font-size: 10px;
    color: var(--text-light);
    margin-top: 3px;
    text-transform: uppercase;
    letter-spacing: .3px;
}

/* Fields */
.usb-fields { padding: 4px 0; }
.usb-field {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-light);
}
.usb-field:last-child { border-bottom: none; }
.usb-field__label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-light);
    margin-bottom: 3px;
}
.usb-field__value { font-size: 13px; color: var(--text-dark); }
.usb-pre { white-space: pre-wrap; font-size: 12px; }

/* Skeleton */
.usb-skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: usbSkeleton 1.5s infinite;
    border-radius: 6px;
    margin: 8px 16px;
}
@keyframes usbSkeleton {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Timeline */
.usb-timeline-controls {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-light);
    background: #f8fafc;
    position: sticky;
    top: 0;
    z-index: 1;
}
.usb-filter-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.usb-chip {
    padding: 3px 10px;
    border-radius: 20px;
    border: 1px solid var(--border-light);
    background: var(--bg-card);
    font-size: 11px;
    cursor: pointer;
    transition: all .15s;
    color: var(--text-light);
}
.usb-chip:hover, .usb-chip.active {
    background: var(--stel-orange);
    color: #fff;
    border-color: var(--stel-orange);
}

.usb-timeline-list {
    padding: 8px 12px 20px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.usb-timeline-date-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-light);
    margin: 14px 0 6px;
    padding-left: 32px;
}
.usb-tl-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    position: relative;
}
.usb-tl-row--right { flex-direction: row-reverse; }

.usb-tl-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-top: 8px;
    flex-shrink: 0;
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px rgba(0,0,0,0.08);
}

.usb-tl-bubble {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 12px;
    max-width: calc(100% - 22px);
}
.usb-tl-bubble__head {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.usb-tl-bubble__icon { font-size: 14px; flex-shrink: 0; }
.usb-tl-bubble__title { font-weight: 600; color: var(--text-dark); flex: 1; }
.usb-tl-bubble__time { font-size: 10px; color: var(--text-light); margin-left: auto; white-space: nowrap; }
.usb-tl-bubble__detail {
    margin-top: 4px;
    color: var(--text-light);
    font-size: 11px;
    line-height: 1.4;
    word-break: break-word;
}
.usb-tl-bubble__meta { font-size: 10px; color: #94a3b8; margin-top: 2px; }

/* Notes */
.usb-notes-composer {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-light);
    background: #fafafa;
}
.usb-note-textarea {
    width: 100%;
    border: 1px solid var(--border-medium);
    border-radius: 8px;
    padding: 8px;
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
    min-height: 70px;
    background: var(--bg-card);
    color: var(--text-dark);
    box-sizing: border-box;
}
.usb-note-textarea:focus { outline: none; border-color: var(--stel-orange); }
.usb-note-type-select {
    border: 1px solid var(--border-medium);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 12px;
    background: var(--bg-card);
    color: var(--text-dark);
    cursor: pointer;
}
.usb-notes-list { padding: 8px 14px; display: flex; flex-direction: column; gap: 8px; }
.usb-note-item {
    background: #f8fafc;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 10px 12px;
}
.usb-note-item__head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 12px;
}
.usb-note-del {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-light);
    font-size: 13px;
    opacity: 0.5;
    padding: 0 2px;
}
.usb-note-del:hover { opacity: 1; color: #ef4444; }
.usb-note-item__content { font-size: 13px; color: var(--text-dark); white-space: pre-wrap; }

/* WA */
.usb-wa-panel { display: flex; flex-direction: column; height: 100%; }
.usb-wa-history {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 160px;
    max-height: 220px;
    background: #f0fdf4;
    border-bottom: 1px solid var(--border-light);
}
.usb-wa-bubble {
    max-width: 85%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 12px;
    line-height: 1.45;
    word-break: break-word;
}
.usb-wa-bubble--in {
    background: #fff;
    border: 1px solid #d1fae5;
    align-self: flex-start;
    border-bottom-left-radius: 3px;
}
.usb-wa-bubble--out {
    background: #dcfce7;
    border: 1px solid #a7f3d0;
    align-self: flex-end;
    border-bottom-right-radius: 3px;
}
.usb-wa-bubble__text { color: var(--text-dark); }
.usb-wa-bubble__meta { font-size: 10px; color: #64748b; margin-top: 3px; text-align: right; }

.usb-wa-composer {
    padding: 12px 14px;
    border-top: 1px solid var(--border-light);
    background: var(--bg-card);
    flex-shrink: 0;
}
.usb-wa-phone {
    flex: 1;
    border: 1px solid var(--border-medium);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 13px;
    background: var(--bg-card);
    color: var(--text-dark);
    min-width: 0;
}
.usb-wa-template-select {
    border: 1px solid var(--border-medium);
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 12px;
    background: var(--bg-card);
    color: var(--text-dark);
    flex-shrink: 0;
    max-width: 160px;
}
.usb-wa-textarea {
    width: 100%;
    border: 1px solid var(--border-medium);
    border-radius: 8px;
    padding: 8px;
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
    min-height: 80px;
    background: var(--bg-card);
    color: var(--text-dark);
    box-sizing: border-box;
}
.usb-wa-textarea:focus { outline: none; border-color: #25d366; }

/* Footer */
.usb-footer {
    padding: 10px 14px;
    border-top: 1px solid var(--border-light);
    background: #f8fafc;
    font-size: 11px;
    color: var(--text-light);
    flex-shrink: 0;
    min-height: 36px;
}

/* Animations */
@keyframes usbFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Responsive */
@media (max-width: 640px) {
    .usb-panel { width: 100vw; }
    .usb-kpis  { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================================
   FLUJOS — Canvas de automatizaciones inteligentes
   ============================================================ */
.panel-flows-section {
    margin-top: 24px;
}
.panel-flows-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.panel-flows-subtitle {
    font-size: 12px;
    color: var(--text-light);
    margin-bottom: 16px;
}
.panel-flow-card {
    background: var(--bg-white, #fff);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
}
.panel-flow-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}
.panel-flow-name {
    font-weight: 700;
    font-size: 14px;
    color: var(--text-dark);
}
.panel-flow-canvas {
    display: flex;
    align-items: center;
    gap: 0;
    overflow-x: auto;
    padding: 12px 0;
    min-height: 90px;
}
/* Nodo individual */
.panel-flow-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 100px;
    padding: 10px 12px;
    background: #f8f9fa;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    text-align: center;
}
.panel-flow-node:hover {
    border-color: #94a3b8;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.panel-flow-node.running {
    border-color: #f59e0b;
    animation: panelNodePulse 0.8s infinite;
}
.panel-flow-node.success {
    border-color: #10b981;
    background: #f0fdf4;
}
.panel-flow-node.error {
    border-color: #ef4444;
    background: #fef2f2;
}
.panel-flow-node__type {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #94a3b8;
    margin-bottom: 4px;
}
.panel-flow-node__name {
    font-size: 11px;
    font-weight: 600;
    color: #334155;
    line-height: 1.3;
}
.panel-flow-node__status {
    font-size: 14px;
    margin-top: 4px;
}
/* Conector entre nodos */
.panel-flow-connector {
    width: 28px;
    height: 2px;
    background: #e2e8f0;
    flex-shrink: 0;
    transition: background 0.3s ease;
}
.panel-flow-connector.success {
    background: #10b981;
}
.panel-flow-connector.error {
    background: #ef4444;
}
/* Log de ejecución en el panel */
.panel-flow-log {
    margin-top: 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px;
    font-size: 11px;
    font-family: var(--font-mono, monospace);
    max-height: 140px;
    overflow-y: auto;
}
.panel-flow-log-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dark);
}

@keyframes panelNodePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(245,158,11,0.4); }
    50%       { box-shadow: 0 0 0 6px rgba(245,158,11,0); }
}


/* ============================================================
   QUALITY UPGRADE — Web Interface Guidelines (2026-09)
   Bloque añadido al final para máxima seguridad y reversibilidad.
   Para revertir: git checkout public/panel/css/panel.css
   ============================================================ */

/* ── 1. SKIP LINK (accesibilidad teclado) ── */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0;
  margin: -1px; overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; top: -100%; left: 8px; z-index: 99999;
  background: var(--stel-navy); color: var(--text-white);
  padding: 8px 16px; border-radius: 0 0 var(--radius-md) var(--radius-md);
  font-size: 13px; font-weight: 600; text-decoration: none;
  transition: top 0.15s ease;
}
.skip-link:focus { top: 0; }

/* ── 2. FOCUS VISIBLE — anula outline:none sin reemplazo ── */
/* Solo se muestra al navegar con teclado, no en click */
:focus-visible {
  outline: 2px solid var(--stel-orange);
  outline-offset: 2px;
}
/* Inputs: el border naranja ya actúa como indicador; añadimos shadow de apoyo */
.form-control:focus-visible,
.form-input:focus-visible,
.stel-table thead tr.search-row input:focus-visible,
.usb-inline-select:focus-visible,
.usb-note-textarea:focus-visible,
.usb-wa-textarea:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(245, 130, 32, 0.25);
}
/* Botones y nav items */
.btn:focus-visible,
.topbar__nav-item:focus-visible,
.sidebar__item:focus-visible,
.tab-item:focus-visible,
.usb-tab:focus-visible,
.usb-chip:focus-visible,
.chat-fab:focus-visible,
.modal-close:focus-visible,
.usb-close-btn:focus-visible,
.topbar__avatar-btn:focus-visible,
.dropdown-item:focus-visible {
  outline: 2px solid var(--stel-orange);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ── 3. TRANSICIONES EXPLÍCITAS — reemplaza transition:all ── */
/* Anima solo las propiedades que cambian realmente */
.sidebar__item {
  transition: color 0.1s ease, background-color 0.1s ease,
              border-left-color 0.1s ease;
}
.btn {
  transition: background-color 0.15s ease, border-color 0.15s ease,
              color 0.15s ease, box-shadow 0.15s ease;
}
.topbar__nav-item {
  transition: color 0.15s ease, background-color 0.15s ease;
}
.tab-item {
  transition: color 0.15s ease, border-bottom-color 0.15s ease;
}
.chat-panel { transition: transform 0.2s ease, opacity 0.2s ease; }
.usb-panel  { transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1); }

/* ── 4. TIPOGRAFÍA — text-wrap, tabular-nums ── */
h1, h2, h3, h4,
.card__title, .page-title, .section-title, .modal-title {
  text-wrap: balance;
}
/* Números en tablas: alineados para comparación visual */
.stel-table td.col-amount,
.stel-table td.col-number,
.kpi-value,
.dashboard-metric {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}
/* Flex children con texto: permite truncado */
.topbar__nav-item, .sidebar__item, .btn { min-width: 0; }

/* ── 5. TOPBAR AVATAR BUTTON — reemplaza el div onclick (ver index.html) ── */
.topbar__avatar-btn {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--stel-orange); color: white;
  font-size: 13px; font-weight: 600;
  cursor: pointer; border: none;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  transition: background-color 0.15s ease;
}
.topbar__avatar-btn:hover { background: var(--stel-orange-hover); }

/* ── 6. CHAT CLOSE BUTTON ── */
.chat-close-btn {
  background: none; border: none; color: white; cursor: pointer;
  font-size: 20px; line-height: 1; padding: 4px 8px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  transition: background-color 0.12s ease;
}
.chat-close-btn:hover { background: rgba(255,255,255,0.15); }

/* ── 7. VIEW TRANSITIONS API ── */
/* Solo en navegadores que lo soportan (Chrome 111+, Edge 111+, Safari 18+) */
/* En Firefox la navegación funciona igual que antes — no hay efecto negativo */
@supports (view-transition-name: none) {
  #page-container { view-transition-name: main-content; }
  .topbar         { view-transition-name: topbar; }
  .sidebar        { view-transition-name: sidebar; }

  @keyframes vt-slide-in {
    from { opacity: 0; translate: 0 10px; }
    to   { opacity: 1; translate: 0 0; }
  }
  @keyframes vt-slide-out {
    from { opacity: 1; translate: 0 0; }
    to   { opacity: 0; translate: 0 -6px; }
  }
  ::view-transition-old(main-content) {
    animation: vt-slide-out 0.18s ease forwards;
  }
  ::view-transition-new(main-content) {
    animation: vt-slide-in 0.22s ease forwards;
  }
  /* Topbar y sidebar permanecen estáticos */
  ::view-transition-old(topbar), ::view-transition-new(topbar),
  ::view-transition-old(sidebar), ::view-transition-new(sidebar) {
    animation: none;
  }
}

/* ── 8. PREFERS-REDUCED-MOTION — WCAG 2.1 SC 2.3.3 ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  ::view-transition-old(main-content),
  ::view-transition-new(main-content) { animation: none !important; }
  .usb-skeleton, .skeleton {
    animation: none !important;
    background: var(--bg-input) !important;
  }
  .spinner {
    animation: none !important;
    opacity: 0.6;
  }
}

/* ── FIN QUALITY UPGRADE BLOCK ── */
