/* ════════════════════════════════════════════════════════════════════════════
   JET CRM — styles.css
   Sistema visual del panel: tokens de marca, layout, componentes.
   ════════════════════════════════════════════════════════════════════════════ */

:root {
  --bg0: #0b0813;
  --bg1: #120e1f;
  --surface: #171226;
  --line: rgba(255, 255, 255, .08);
  --line-strong: rgba(255, 255, 255, .14);
  --text: #f4f2fa;
  --text2: #cfc9e0;
  --text3: #a49dba;
  --purple-soft: #b57bff;
  --hover: rgba(255, 255, 255, .05);
  --shadow: rgba(0, 0, 0, .45);
  --overlay: rgba(7, 5, 12, .72);
  --purple: #7700f4;
  --cyan: #08f2cf;
  --grad: linear-gradient(90deg, #7700f4, #08f2cf);
  --pos: #2ee6a8;
  --neg: #ff5c7a;
  --radius: 12px;
}

/* ── Tema claro (data-theme="light" en <html>; conmutador en la barra lateral) ── */
[data-theme="light"] {
  --bg0: #f3f4f9;
  --bg1: #ffffff;
  --surface: #ffffff;
  --line: rgba(16, 23, 43, .10);
  --line-strong: rgba(16, 23, 43, .20);
  --text: #10172b;
  --text2: #3d4562;
  --text3: #667090;
  --cyan: #0a9c86;          /* el cian de marca no se lee sobre blanco: versión oscura para texto */
  --pos: #0f9d6f;
  --neg: #d6335a;
  --purple-soft: #6a1fd0;
  --hover: rgba(16, 23, 43, .05);
  --shadow: rgba(16, 23, 43, .10);
  --overlay: rgba(16, 23, 43, .45);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
  background: var(--bg0);
  background-image: linear-gradient(160deg, var(--bg0) 0%, var(--bg1) 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: 'Poppins', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

h1, h2, h3, h4 { font-weight: 600; line-height: 1.25; margin: 0 0 12px; }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
h4 { font-size: 14px; }
p { margin: 0 0 10px; }
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--text3); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--line-strong); }

/* ── Login ─────────────────────────────────────────────────────────────────── */

.login-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 40px 34px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: center;
  box-shadow: 0 24px 60px var(--shadow);
}

.login-logo { width: 108px; margin: 0 auto 4px; }
.login-card h1 { margin-bottom: 0; }
.login-card p { margin-bottom: 4px; font-size: 14px; }
.login-card input { width: 100%; text-align: center; }

/* ── Shell y sidebar ───────────────────────────────────────────────────────── */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 232px;
  background: var(--bg1);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 22px 14px 18px;
  z-index: 20;
}

.sidebar-logo { width: 86px; margin: 0 10px 26px; }

#nav { display: flex; flex-direction: column; gap: 4px; flex: 1; overflow-y: auto; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 13px;
  border-radius: var(--radius);
  color: var(--text2);
  font-size: 14.5px;
  font-weight: 500;
  text-decoration: none;
  transition: background .15s, color .15s;
}
.nav-item svg { width: 18px; height: 18px; flex: none; opacity: .8; }
.nav-item:hover { color: var(--text); background: var(--hover); text-decoration: none; }
.nav-item.active {
  color: #fff;
  background: linear-gradient(90deg, rgba(119, 0, 244, .32), rgba(8, 242, 207, .10));
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.nav-item.active svg { opacity: 1; }

.logout-btn {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 13px;
  margin-top: 10px;
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text3);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.logout-btn svg { width: 16px; height: 16px; }
.logout-btn:hover { color: var(--neg); border-color: rgba(255, 92, 122, .4); }

#view {
  flex: 1;
  margin-left: 232px;
  padding: 30px 34px 60px;
  min-width: 0;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.page-head h1 { margin: 0; }

/* ── Tarjetas y KPIs ───────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 18px;
}
.card-title {
  font-size: 13.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text3);
  margin-bottom: 14px;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.kpi-value { font-size: 26px; font-weight: 600; letter-spacing: -.01em; }
.kpi-label { font-size: 13px; color: var(--text3); text-transform: uppercase; letter-spacing: .06em; margin-top: 2px; }
.kpi-delta { font-size: 13.5px; margin-top: 4px; }

/* ── Tablas ────────────────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left;
  padding: 10px 12px;
  color: var(--text3);
  font-weight: 500;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--text2);
  vertical-align: middle;
}
tbody tr { transition: background .12s; }
tbody tr:hover { background: rgba(255, 255, 255, .025); }
tr.clickable { cursor: pointer; }
td strong, td b { color: var(--text); font-weight: 600; }

/* ── Formularios ───────────────────────────────────────────────────────────── */

input, select, textarea {
  background: var(--bg1);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 14.5px;
  padding: 9px 13px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--text3); }
input:focus, select:focus, textarea:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(119, 0, 244, .22);
}
select { cursor: pointer; }
select option { background: var(--bg1); color: var(--text); }
textarea { resize: vertical; min-height: 90px; width: 100%; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--purple); width: auto; padding: 0; cursor: pointer; }

label { font-size: 13.5px; color: var(--text3); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field input, .field select, .field textarea { width: 100%; }
.field-row { display: flex; gap: 12px; }
.field-row > .field { flex: 1; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.toolbar input[type="search"], .toolbar input[type="text"] { min-width: 220px; }

/* ── Botones ───────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--grad);
  border: none;
  border-radius: 999px;
  color: #fff;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 600;
  padding: 10px 24px;
  cursor: pointer;
  transition: filter .15s, transform .1s;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }

.btn-ghost, .btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--text2);
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 500;
  padding: 9px 22px;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.btn-ghost:hover, .btn-secondary:hover { color: var(--text); border-color: var(--cyan); background: rgba(8, 242, 207, .06); }

.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: transparent;
  border: 1px solid rgba(255, 92, 122, .45);
  border-radius: 999px;
  color: var(--neg);
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 500;
  padding: 9px 22px;
  cursor: pointer;
  transition: background .15s;
}
.btn-danger:hover { background: rgba(255, 92, 122, .1); }

.btn-sm, .btn-ghost.btn-sm, .btn-danger.btn-sm { padding: 6px 15px; font-size: 14px; }
.btn svg, .btn-ghost svg, .btn-danger svg { width: 15px; height: 15px; }

.icon-btn {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  padding: 5px;
  border-radius: 8px;
  display: inline-flex;
  transition: color .15s, background .15s;
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { color: var(--text); background: var(--hover); }
.icon-btn.danger:hover { color: var(--neg); background: rgba(255, 92, 122, .1); }

/* ── Badges de estado ──────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--line-strong);
  color: var(--text2);
  background: var(--hover);
  white-space: nowrap;
}
/* verde: vivo / completado */
.badge.active, .badge.sent, .badge.won, .badge.done, .badge.ok, .badge.green {
  color: var(--pos); border-color: rgba(46, 230,168, .35); background: rgba(46, 230, 168, .1);
}
/* rojo: fallo / rebote / perdido */
.badge.bounced, .badge.complained, .badge.failed, .badge.lost, .badge.suppressed, .badge.err, .badge.red {
  color: var(--neg); border-color: rgba(255, 92, 122, .35); background: rgba(255, 92, 122, .1);
}
/* cian: programado / en cola / esperando */
.badge.scheduled, .badge.queued, .badge.ab_wait, .badge.cyan {
  color: var(--cyan); border-color: rgba(8, 242, 207, .35); background: rgba(8, 242, 207, .08);
}
/* púrpura: en marcha */
.badge.sending, .badge.purple {
  color: #b57bff; border-color: rgba(119, 0, 244, .5); background: rgba(119, 0, 244, .14);
}
/* gris: borrador / pausado / baja */
.badge.draft, .badge.paused, .badge.cancelled, .badge.unsubscribed, .badge.inactive, .badge.gray {
  color: var(--text3); border-color: var(--line-strong); background: var(--hover);
}

/* ── Tabs ──────────────────────────────────────────────────────────────────── */

.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
  overflow-x: auto;
}
.tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 10px 16px;
  color: var(--text3);
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s;
}
.tab:hover { color: var(--text2); }
.tab.active {
  color: #fff;
  border-image: linear-gradient(90deg, #7700f4, #08f2cf) 1;
}

/* ── Modal ─────────────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 100;
  padding: 40px 24px;
  overflow-y: auto;
  animation: fadeIn .15s ease;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  padding: 26px 28px;
  width: 100%;
  max-width: 560px;
  box-shadow: 0 24px 70px var(--shadow);
  animation: popIn .18s ease;
}
.modal.modal-lg, .modal-overlay .modal-lg { max-width: 920px; }
.modal h3 { margin-top: 0; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }

/* ── Toasts ────────────────────────────────────────────────────────────────── */

#toasts {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--pos);
  border-radius: var(--radius);
  padding: 12px 18px;
  font-size: 14px;
  color: var(--text);
  box-shadow: 0 12px 34px var(--shadow);
  animation: toastIn .2s ease;
}
.toast.err { border-left-color: var(--neg); }
.toast.out { opacity: 0; transform: translateX(12px); transition: opacity .3s, transform .3s; }
@keyframes toastIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }

/* ── Kanban (ventas) ───────────────────────────────────────────────────────── */

.kanban {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  overflow-x: auto;
  padding-bottom: 12px;
}
.kanban-col {
  flex: 0 0 258px;
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  min-height: 220px;
  transition: border-color .15s, background .15s;
}
.kanban-col.drag-over { border-color: var(--cyan); background: rgba(8, 242, 207, .05); }
.kanban-col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 4px 10px;
  font-size: 13.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text3);
}
.kanban-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
  cursor: grab;
  transition: border-color .15s, transform .12s;
}
.kanban-card:hover { border-color: var(--line-strong); }
.kanban-card.dragging { opacity: .4; }
.kanban-card:active { cursor: grabbing; }

/* ── Utilidades varias ─────────────────────────────────────────────────────── */

.dragging { opacity: .4; }
.drop-target { outline: 2px dashed var(--cyan); outline-offset: 2px; }

.bar-track { background: var(--hover); border-radius: 999px; height: 8px; overflow: hidden; }
.bar { background: var(--grad); border-radius: 999px; height: 100%; }

.empty {
  text-align: center;
  color: var(--text3);
  padding: 44px 20px;
  font-size: 14.5px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
  font-size: 14px;
  color: var(--text3);
}

code, .code {
  font-family: ui-monospace, 'Cascadia Code', Consolas, monospace;
  font-size: 13.5px;
  background: var(--bg0);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 2px 7px;
  color: var(--cyan);
}
pre.code, .snippet {
  display: block;
  background: var(--bg0);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0 0 10px;
}

hr { border: none; border-top: 1px solid var(--line); margin: 18px 0; }

/* ── Responsive básico (crítico solo ≥1024) ────────────────────────────────── */

@media (max-width: 1023px) {
  .sidebar { width: 64px; padding: 18px 8px; }
  .sidebar-logo { width: 40px; margin: 0 4px 22px; }
  .nav-item span, .logout-btn span { display: none; }
  .nav-item, .logout-btn { justify-content: center; padding: 10px; }
  #view { margin-left: 64px; padding: 22px 18px 50px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .field-row { flex-direction: column; gap: 0; }
}

/* ════════════════════════════════════════════════════════════════════════════
   CAPA DE REFINAMIENTO — identidad, aire y movimiento
   Va al final a propósito: afina el sistema de arriba sin reescribirlo, y con
   el prefijo #view gana a los estilos que cada vista inyecta en runtime.

   Criterio: el degradado de marca es un acento, no un adorno. Solo lo llevan
   la acción principal de cada pantalla, el indicador de sección activa y los
   números que importan. Todo lo demás calla para que eso destaque.
   ════════════════════════════════════════════════════════════════════════════ */

:root {
  /* Fondo con una pizca de violeta: el negro puro apaga la marca */
  --bg0: #09060f;
  --bg1: #0f0b1a;
  --surface: #161124;
  --surface-2: #1d1730;

  --e1: 0 1px 2px rgba(0,0,0,.20);
  --e2: 0 6px 20px rgba(0,0,0,.28), 0 1px 3px rgba(0,0,0,.18);
  --e3: 0 24px 64px rgba(0,0,0,.50), 0 6px 16px rgba(0,0,0,.30);
  --ring: 0 0 0 3px rgba(119,0,244,.32);
  --ease: cubic-bezier(.4,0,.2,1);
  --t: .18s var(--ease);
  /* Luz cenital: un filo claro arriba de cada superficie */
  --sheen: inset 0 1px 0 rgba(255,255,255,.05);
  --glow: radial-gradient(120% 100% at 100% 0%, rgba(119,0,244,.10), transparent 60%);
}

[data-theme="light"] {
  --bg0: #f6f6fb;          /* blanco cálido, no gris clínico */
  --bg1: #ffffff;
  --surface: #ffffff;
  --surface-2: #f7f7fc;
  --e1: 0 1px 2px rgba(16,23,43,.05);
  --e2: 0 6px 22px rgba(16,23,43,.07), 0 1px 3px rgba(16,23,43,.05);
  --e3: 0 28px 70px rgba(16,23,43,.16), 0 6px 16px rgba(16,23,43,.07);
  --ring: 0 0 0 3px rgba(119,0,244,.15);
  --sheen: none;
  --glow: radial-gradient(120% 100% at 100% 0%, rgba(119,0,244,.045), transparent 60%);
}

body {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background-image: none;
  background: var(--bg0);
}

/* ── Tipografía: titulares con aplomo, cuerpo que respira ─────────────────── */
h1 { font-size: 30px; font-weight: 700; letter-spacing: -.028em; }
h2 { font-size: 20px; font-weight: 650; letter-spacing: -.018em; }
h3 { font-size: 16.5px; font-weight: 600; letter-spacing: -.012em; }
p, td, li { line-height: 1.62; }

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 10px; }

/* ── Barra lateral ─────────────────────────────────────────────────────────── */
.sidebar {
  width: 244px;
  background: var(--bg1);
  border-right: none;
  box-shadow: 1px 0 0 var(--line);
  padding: 30px 16px 20px;
}
/* Filo degradado en el borde: la firma de la casa, apenas visible */
.sidebar::after {
  content: "";
  position: absolute; top: 0; right: 0; bottom: 0; width: 1px;
  background: linear-gradient(180deg, rgba(119,0,244,.55), rgba(8,242,207,.30) 45%, transparent 85%);
  opacity: .8;
}
.sidebar-logo { width: 74px; margin: 0 10px 34px; transition: transform var(--t); }
.sidebar-logo:hover { transform: scale(1.05); }

#nav { gap: 3px; }
.nav-item {
  position: relative;
  padding: 11px 14px;
  border-radius: 11px;
  font-size: 14.5px;
  color: var(--text2);
  transition: background var(--t), color var(--t), transform var(--t);
}
.nav-item::before {
  content: "";
  position: absolute; left: 0; top: 50%;
  width: 3px; height: 0;
  background: var(--grad);
  border-radius: 0 3px 3px 0;
  transform: translateY(-50%);
  transition: height .22s var(--ease);
}
.nav-item:hover { color: var(--text); background: var(--hover); transform: translateX(2px); }
.nav-item.active {
  color: var(--text);
  font-weight: 600;
  background: linear-gradient(90deg, rgba(119,0,244,.16), rgba(8,242,207,.04) 70%, transparent);
  box-shadow: none;
}
.nav-item.active::before { height: 22px; }
[data-theme="light"] .nav-item.active { background: linear-gradient(90deg, rgba(119,0,244,.09), rgba(8,242,207,.03) 70%, transparent); }

.logout-btn { border-radius: 11px; font-size: 13.5px; }

/* ── Lienzo: mucho más aire ────────────────────────────────────────────────── */
#view { margin-left: 244px; padding: 42px 46px 90px; }
#view > * { max-width: 1340px; }

.page-head { margin-bottom: 30px; align-items: flex-start; }
.page-head h1 { margin: 0 0 4px; }

/* Entrada escalonada del contenido al cambiar de pantalla */
@keyframes surgir { from { opacity: 0; transform: translateY(10px); } }
#view.entrando > * { animation: surgir .42s var(--ease) both; }
#view.entrando > *:nth-child(1) { animation-delay: .02s; }
#view.entrando > *:nth-child(2) { animation-delay: .07s; }
#view.entrando > *:nth-child(3) { animation-delay: .12s; }
#view.entrando > *:nth-child(4) { animation-delay: .17s; }
#view.entrando > *:nth-child(n+5) { animation-delay: .21s; }

/* ── Tarjetas ──────────────────────────────────────────────────────────────── */
.card, #view .ctv-card, #view .cmp-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 26px 28px;
  margin-bottom: 20px;
  box-shadow: var(--e1), var(--sheen);
  transition: box-shadow var(--t), border-color var(--t);
}
.card:hover, #view .ctv-card:hover { border-color: var(--line-strong); }

.card-title, #view .ctv-lab, #view .cmp-lab {
  font-size: 11.5px;
  letter-spacing: .12em;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 16px;
}

/* ── Indicadores: el elemento con más presencia de la casa ─────────────────── */
.kpis { gap: 16px; margin-bottom: 24px; }
.kpi, #view .ctv-kpi, #view .cmp-kpi {
  position: relative;
  background: var(--surface);
  background-image: var(--glow);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px 22px 18px;
  overflow: hidden;
  box-shadow: var(--e1), var(--sheen);
  transition: transform var(--t), box-shadow var(--t), border-color var(--t);
}
/* Filo degradado que aparece al pasar por encima */
.kpi::before, #view .ctv-kpi::before {
  content: "";
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--grad);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .3s var(--ease);
}
.kpi:hover, #view .ctv-kpi:hover {
  transform: translateY(-3px);
  box-shadow: var(--e2), var(--sheen);
  border-color: var(--line-strong);
}
.kpi:hover::before, #view .ctv-kpi:hover::before { transform: scaleX(1); }

.kpi-label { font-size: 11.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--text3); margin: 0 0 6px; font-weight: 600; }
.kpi-value {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -.032em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.kpi-delta { font-size: 13px; margin-top: 6px; }

/* ── Tablas con acabado editorial ──────────────────────────────────────────── */
.table-wrap, #view .ctv-scroll, #view .cmp-tablewrap { border-radius: 12px; overflow: auto; }

#view table { font-size: 14.5px; }
#view table th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface);
  font-size: 11.5px;
  letter-spacing: .11em;
  font-weight: 600;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-strong);
}
#view table td {
  padding: 15px 14px;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
#view tbody tr { transition: background var(--t); }
#view tbody tr:hover { background: var(--hover); }
#view tbody tr:last-child td { border-bottom: none; }
#view tr.clickable { cursor: pointer; }
#view tr.clickable:hover { background: linear-gradient(90deg, rgba(119,0,244,.08), transparent 55%); }
#view td strong, #view td b { color: var(--text); font-weight: 600; }

/* ── Formularios ───────────────────────────────────────────────────────────── */
input, select, textarea,
#view .ctv-in, #view .ctv-sel, #view .ctv-ta, #view .cmp-in {
  border-radius: 11px;
  padding: 11px 14px;
  font-size: 14.5px;
  background: var(--bg1);
  transition: border-color var(--t), box-shadow var(--t), background var(--t);
}
[data-theme="light"] input, [data-theme="light"] select, [data-theme="light"] textarea { background: var(--surface-2); }
input:hover:not(:focus), select:hover:not(:focus), textarea:hover:not(:focus) { border-color: var(--text3); }
input:focus, select:focus, textarea:focus,
#view .ctv-in:focus, #view .ctv-sel:focus, #view .ctv-ta:focus, #view .cmp-in:focus {
  border-color: var(--purple);
  box-shadow: var(--ring);
  background: var(--surface);
}
label { font-weight: 500; font-size: 13.5px; }
.field { gap: 7px; margin-bottom: 16px; }

/* ── Botones: el degradado solo para la acción principal ───────────────────── */
.btn, #view .ctv-btn, #view .cmp-btn {
  padding: 11px 26px;
  font-size: 14.5px;
  font-weight: 600;
  border-radius: 999px;
  box-shadow: 0 2px 12px rgba(119,0,244,.30);
  transition: transform var(--t), box-shadow var(--t), filter var(--t);
}
.btn:hover, #view .ctv-btn:hover, #view .cmp-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(119,0,244,.40);
  filter: brightness(1.07);
}
.btn:active, #view .ctv-btn:active { transform: translateY(0) scale(.985); }
.btn:disabled { transform: none; box-shadow: none; opacity: .45; }

/* Secundario: relleno tenue en vez de contorno, que ensucia menos */
.btn-ghost, .btn-secondary, #view .ctv-btn2 {
  background: var(--hover);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 22px;
  font-weight: 500;
  color: var(--text2);
  transition: color var(--t), border-color var(--t), background var(--t), transform var(--t);
}
.btn-ghost:hover, #view .ctv-btn2:hover {
  color: var(--text);
  border-color: var(--line-strong);
  background: var(--surface-2);
  transform: translateY(-1px);
}
.btn-sm, .btn-ghost.btn-sm, .btn-danger.btn-sm { padding: 7px 16px; font-size: 13.5px; }

.icon-btn { border-radius: 9px; }

/* ── Distintivos de estado ─────────────────────────────────────────────────── */
.badge, #view .ctv-badge, #view .cmp-badge {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .02em;
  padding: 4px 12px;
  border-radius: 999px;
}

/* ── Pestañas ──────────────────────────────────────────────────────────────── */
#view .ctv-tabs, #view .cmp-tabs, .tabs { border-bottom: 1px solid var(--line); gap: 4px; margin-bottom: 24px; }
#view .ctv-tab, #view .cmp-tab, .tab {
  position: relative;
  padding: 11px 16px;
  border-radius: 10px 10px 0 0;
  font-size: 14.5px;
  transition: color var(--t), background var(--t);
}
#view .ctv-tab::after, #view .cmp-tab::after, .tab::after {
  content: "";
  position: absolute; left: 14px; right: 14px; bottom: -1px;
  height: 2px; border-radius: 2px;
  background: var(--grad);
  transform: scaleX(0);
  transition: transform .22s var(--ease);
}
#view .ctv-tab:hover, #view .cmp-tab:hover, .tab:hover { background: var(--hover); }
#view .ctv-tab.on::after, #view .cmp-tab.on::after, .tab.active::after { transform: scaleX(1); }

/* ── Diálogos ──────────────────────────────────────────────────────────────── */
.modal-overlay { background: var(--overlay); backdrop-filter: blur(6px) saturate(120%); animation: aparecer .18s var(--ease); }
.modal, #view .ctv-modal, #view .cmp-m {
  border-radius: 18px;
  padding: 28px 30px;
  box-shadow: var(--e3), var(--sheen);
  animation: emerger .24s var(--ease);
}
@keyframes aparecer { from { opacity: 0; } }
@keyframes emerger { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.modal-actions { margin-top: 22px; gap: 10px; }

/* ── Avisos flotantes ──────────────────────────────────────────────────────── */
.toast {
  border-radius: 12px;
  padding: 13px 18px;
  font-size: 14px;
  box-shadow: var(--e2);
  animation: entrarAviso .28s var(--ease);
}
@keyframes entrarAviso { from { opacity: 0; transform: translateY(-10px) scale(.96); } }

/* ── Carga: esqueletos en vez de la palabra «Cargando» ─────────────────────── */
.skeleton {
  border-radius: 8px;
  background: linear-gradient(90deg, var(--hover) 25%, var(--line-strong) 37%, var(--hover) 63%);
  background-size: 400% 100%;
  animation: brillo 1.4s ease-in-out infinite;
}
@keyframes brillo { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.skeleton-row { height: 15px; margin: 12px 0; }
.skeleton-row.w60 { width: 60%; }
.skeleton-row.w40 { width: 40%; }
.skeleton-row.w80 { width: 80%; }

/* ── Estados vacíos con intención ──────────────────────────────────────────── */
.empty, #view .ctv-empty, #view .cmp-empty {
  text-align: center;
  padding: 56px 24px;
  color: var(--text3);
  font-size: 15px;
  line-height: 1.7;
}

/* ── Entrada ───────────────────────────────────────────────────────────────── */
.login-screen::before {
  content: "";
  position: fixed; inset: -30%;
  background:
    radial-gradient(40% 40% at 32% 32%, rgba(119,0,244,.30), transparent 70%),
    radial-gradient(38% 38% at 68% 70%, rgba(8,242,207,.16), transparent 70%);
  animation: respirar 11s ease-in-out infinite alternate;
  pointer-events: none;
}
@keyframes respirar { to { transform: translate(2.5%, -2%) scale(1.08); } }
.login-card {
  position: relative;
  max-width: 380px;
  padding: 44px 38px;
  border-radius: 20px;
  box-shadow: var(--e3), var(--sheen);
}
.login-logo { width: 100px; }

/* ── Ventas ────────────────────────────────────────────────────────────────── */
.kanban-card { border-radius: 12px; box-shadow: var(--e1), var(--sheen); transition: transform var(--t), box-shadow var(--t); }
.kanban-card:hover { transform: translateY(-2px); box-shadow: var(--e2); }
.kanban-card.dragging { opacity: .5; transform: rotate(1.5deg) scale(.97); }
.kanban-col { border-radius: 14px; }
.kanban-col.drop-target { background: rgba(119,0,244,.08); border-color: var(--purple); }

.bar-track { border-radius: 999px; overflow: hidden; }
.bar { transition: width .7s var(--ease); }

/* ── Barras de desplazamiento ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border: 3px solid transparent; background-clip: content-box; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); background-clip: content-box; }

/* ── Pantallas estrechas ───────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  #view { padding: 32px 28px 72px; }
}
@media (max-width: 900px) {
  .sidebar { width: 70px; padding: 22px 9px 16px; }
  .sidebar-logo { width: 38px; margin: 0 auto 24px; }
  .nav-item span, .logout-btn span { display: none; }
  .nav-item, .logout-btn { justify-content: center; padding: 12px 0; }
  .nav-item::before { display: none; }
  #view { margin-left: 70px; padding: 24px 20px 60px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  h1 { font-size: 25px; }
  .kpi-value { font-size: 29px; }
}

/* ── Quien pide menos movimiento, recibe menos movimiento ──────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
