/* ============================================================
   AdaBox — hoja de estilos (estilo Zenith: tokens OKLCh
   acromáticos + un solo acento; tema claro/oscuro por variables)
   ============================================================ */
:root {
  /* Base ZINC (neutro). El fondo es gris suave para que las tarjetas blancas resalten. */
  --bg: oklch(0.955 0 0);
  --surface: oklch(1 0 0);
  --surface-2: oklch(0.965 0 0);
  --border: oklch(0.912 0 0);
  --border-strong: oklch(0.84 0 0);
  --text: oklch(0.21 0 0);
  --text-soft: oklch(0.52 0 0);
  /* Acento único (lo pisa el color elegido en Configuración) */
  --primary: #4f46e5;
  --primary-dark: color-mix(in oklch, var(--primary) 82%, black);
  --primary-soft: color-mix(in oklch, var(--primary) 12%, var(--surface));
  --on-primary: #ffffff;
  --danger: oklch(0.577 0.215 27);
  --danger-soft: oklch(0.965 0.02 25);
  --success: oklch(0.587 0.15 152);
  --success-soft: oklch(0.965 0.03 152);
  --warning: oklch(0.646 0.15 75);
  --warning-soft: oklch(0.973 0.04 90);
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px oklch(0 0 0 / .05);
  --shadow-lg: 0 8px 28px oklch(0 0 0 / .12);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

[data-theme="dark"] {
  --bg: oklch(0.178 0 0);
  --surface: oklch(0.225 0 0);
  --surface-2: oklch(0.262 0 0);
  --border: oklch(0.32 0 0);
  --border-strong: oklch(0.42 0 0);
  --text: oklch(0.93 0 0);
  --text-soft: oklch(0.68 0 0);
  --primary: #7c83ff;
  --primary-dark: color-mix(in oklch, var(--primary) 80%, white);
  --primary-soft: color-mix(in oklch, var(--primary) 26%, var(--surface));
  --danger: oklch(0.7 0.17 25);
  --danger-soft: oklch(0.26 0.04 25);
  --success: oklch(0.74 0.14 152);
  --success-soft: oklch(0.26 0.04 152);
  --warning: oklch(0.78 0.13 85);
  --warning-soft: oklch(0.26 0.04 90);
  --shadow: 0 1px 2px oklch(0 0 0 / .4);
  --shadow-lg: 0 8px 28px oklch(0 0 0 / .55);
}

/* ===== Paleta base alternativa: SLATE (leve azulado, estilo shadcn) ===== */
[data-base="slate"] {
  --bg: oklch(0.955 0.006 255);
  --surface: oklch(1 0 0);
  --surface-2: oklch(0.968 0.006 255);
  --border: oklch(0.912 0.01 255);
  --border-strong: oklch(0.84 0.014 255);
  --text: oklch(0.23 0.03 260);
  --text-soft: oklch(0.52 0.02 260);
}
[data-base="slate"][data-theme="dark"] {
  --bg: oklch(0.21 0.02 260);
  --surface: oklch(0.26 0.02 260);
  --surface-2: oklch(0.3 0.02 260);
  --border: oklch(0.36 0.02 260);
  --border-strong: oklch(0.45 0.02 260);
  --text: oklch(0.94 0.01 260);
  --text-soft: oklch(0.7 0.015 260);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 15px; color: var(--text);
  background: var(--bg); line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Estructura: sidebar + main ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px; flex-shrink: 0; background: var(--bg); color: var(--text-soft);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
  transition: width .25s ease;
}
.sidebar-top { display: flex; align-items: center; border-bottom: 1px solid var(--border); }
.sidebar-brand {
  display: flex; align-items: center; gap: 11px; padding: 17px 16px; color: var(--text); flex: 1; min-width: 0;
}
.collapse-btn { background: none; border: none; color: var(--text-soft); cursor: pointer; padding: 8px 12px; }
.collapse-btn:hover { color: var(--text); }
.app-shell.nav-mini .collapse-btn svg { transform: rotate(180deg); }
.sidebar-brand .mark {
  background: var(--primary); color: #fff; font-weight: 800; font-size: 14px;
  width: 36px; height: 36px; border-radius: 9px; display: flex; align-items: center; justify-content: center;
  letter-spacing: .5px; flex-shrink: 0;
}
.sidebar-brand .txt b { display: block; font-size: 14px; line-height: 1.15; color: var(--text); }
.sidebar-brand .txt small { color: var(--text-soft); font-size: 10.5px; letter-spacing: .4px; }

.sidebar-nav { padding: 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
.sidebar-nav .group-label { color: var(--text); font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .6px; padding: 14px 12px 6px; font-weight: 800; opacity: 1; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 9px;
  color: var(--text-soft); font-weight: 500; font-size: 14px;
  position: relative; transition: background .15s ease, color .15s ease;
}
/* Hover suave: un velo tenue neutro (se adapta a claro/oscuro), que no moleste */
.nav-item:hover { background: color-mix(in oklch, var(--text) 6%, transparent); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
/* Barra de acento del item seleccionado (se adapta sola a claro/oscuro vía --primary) */
.nav-item.active::before {
  content: ""; position: absolute; left: 3px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: 0 3px 3px 0; background: var(--primary);
}
.app-shell.nav-mini .nav-item.active::before { left: 0; height: 16px; }
.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }
.nav-item .count { margin-left: auto; background: var(--surface-2); color: var(--text-soft);
  font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; }
.nav-item.active .count { background: var(--primary); color: #fff; }

.sidebar-foot { padding: 12px; border-top: 1px solid var(--border); }
.user-mini { display: flex; align-items: center; gap: 9px; padding: 6px 8px; }
.user-mini .avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--primary);
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
.user-mini .info { overflow: hidden; }
.user-mini .info b { display: block; font-size: 12.5px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-mini .info small { color: var(--text-soft); font-size: 11px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--surface); }

/* ---------- Topbar ---------- */
.topbar {
  height: 60px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px; padding: 0 22px; position: sticky; top: 0; z-index: 30;
}
.topbar .hamburger { display: none; background: none; border: none; cursor: pointer; color: var(--text); padding: 4px; }
.topbar .page-title { font-size: 16px; font-weight: 700; }
.topbar .grow { flex: 1; }
.icon-btn {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-soft);
  width: 38px; height: 38px; border-radius: 9px; cursor: pointer; display: inline-flex;
  align-items: center; justify-content: center;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.icon-btn svg { width: 18px; height: 18px; }

.container { max-width: 1560px; width: 100%; margin: 0 auto; padding: 22px 30px;
  transition: max-width .25s ease; }
/* Menú achicado: el contenido aprovecha todo el ancho */
.app-shell.nav-mini .container { max-width: 100%; }

.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 20px; margin: 0; }
.page-head .spacer { flex: 1; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  padding: 8px 14px; border-radius: 9px; font-size: 14px; font-weight: 600; cursor: pointer;
  text-decoration: none; transition: all .12s; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn svg { width: 16px; height: 16px; }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-dark); }

/* Muestras de temas prearmados */
.tema-swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--border); cursor: pointer; padding: 0; }
.tema-swatch:hover { transform: scale(1.1); border-color: var(--text-soft); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.92); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-soft); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

/* ---------- Filtros ---------- */
.filtros { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 18px; }
.filtros .campo { display: flex; flex-direction: column; gap: 4px; }
.filtros label { font-size: 12px; color: var(--text-soft); font-weight: 600; }
.filtros .grow { flex: 0 1 360px; min-width: 200px; }
.check-inline { flex-direction: row !important; align-items: center; gap: 6px; height: 38px; }

/* ---------- Inputs ---------- */
.input, select.input, textarea.input {
  width: 100%; padding: 9px 11px; font-size: 14px; font-family: var(--font);
  border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface); color: var(--text);
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea.input { resize: vertical; }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; }

/* ---------- Tabla / Grilla ---------- */
.tabla-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
table.grilla { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grilla thead th {
  text-align: left; background: var(--surface-2); color: var(--text-soft); font-weight: 700;
  font-size: 11px; text-transform: uppercase; letter-spacing: .4px; padding: 11px 14px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.grilla tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.grilla tbody tr:hover { background: var(--primary-soft); cursor: pointer; }
table.grilla tbody tr:last-child td { border-bottom: none; }
.carpeta-num { font-weight: 700; color: var(--primary); }
.muted { color: var(--text-soft); }
.tabla-vacia { padding: 44px; text-align: center; color: var(--text-soft); }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px;
  font-weight: 600; background: var(--surface-2); color: var(--text-soft); white-space: nowrap; border: 1px solid var(--border); }
.badge-alarm { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge-ok { background: var(--success-soft); color: var(--success); border-color: transparent; }

/* ---------- Formularios ---------- */
.form-section { margin-bottom: 20px; }
.form-section > h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-soft);
  margin: 0 0 12px; padding-bottom: 7px; border-bottom: 1px solid var(--border); font-weight: 700; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 13px 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 13px 16px; }
.field { display: flex; flex-direction: column; gap: 5px; position: relative; }
.field label { font-size: 12px; font-weight: 600; color: var(--text-soft); }
.field .errorlist { color: var(--danger); font-size: 12px; margin: 2px 0 0; padding-left: 16px; }
.field .helptext { font-size: 11px; color: var(--text-soft); }

.checklist { display: grid; grid-template-columns: repeat(5, 1fr); gap: 9px 12px; }
.checklist label { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 500; color: var(--text); cursor: pointer; }
.checklist input { width: 16px; height: 16px; accent-color: var(--primary); }

.form-actions { display: flex; gap: 10px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }
.form-actions .spacer { flex: 1; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tabs button { background: none; border: none; padding: 11px 16px; font-size: 14px; font-weight: 600;
  color: var(--text-soft); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- Detalle ---------- */
.dl { display: grid; grid-template-columns: 170px 1fr; gap: 7px 14px; }
.dl dt { color: var(--text-soft); font-weight: 600; font-size: 13px; }
.dl dd { margin: 0; }
.doc-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.doc-chip { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); color: var(--text-soft); border: 1px solid var(--border); }
.doc-chip.on { background: var(--success-soft); color: var(--success); border-color: transparent; }

/* ---------- Movimientos / listas ---------- */
.lista-mov { width: 100%; border-collapse: collapse; font-size: 13px; }
.lista-mov th { text-align: left; color: var(--text-soft); font-size: 12px; text-transform: uppercase; padding: 9px 8px; border-bottom: 1px solid var(--border); }
.lista-mov td { padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }

/* ---------- Galería de imágenes + lightbox ---------- */
.galeria { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.galeria .thumb { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface-2); cursor: pointer; position: relative; }
.galeria .thumb img { width: 100%; height: 130px; object-fit: cover; display: block; transition: transform .2s; }
.galeria .thumb:hover img { transform: scale(1.04); }
.galeria .thumb .cap { padding: 7px 9px; font-size: 12px; color: var(--text-soft); }
.galeria .thumb .cap b { color: var(--text); display: block; word-break: break-all; font-weight: 600; }
/* Documentación por ítem */
.docs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.doc-item { border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: var(--surface); }
.doc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 9px; }
.doc-name { font-weight: 600; font-size: 13.5px; }
.doc-files { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; margin-bottom: 9px; }
.doc-thumb { width: 54px; height: 54px; object-fit: cover; border-radius: 7px; cursor: pointer; border: 1px solid var(--border); }
.doc-file { font-size: 12px; word-break: break-all; }
.doc-del { color: var(--danger); font-size: 13px; text-decoration: none; font-weight: 700; }
.doc-upload { display: flex; gap: 6px; align-items: center; }
.doc-upload input[type=file] { font-size: 12px; padding: 5px 7px; flex: 1; min-width: 0; }

.doc-list { display: flex; flex-direction: column; gap: 8px; }
.doc-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); }
.doc-row .ico { font-size: 20px; }

.lightbox { position: fixed; inset: 0; background: rgba(5,8,18,.88); z-index: 100; display: none;
  align-items: center; justify-content: center; padding: 30px; }
.lightbox.open { display: flex; }
.lightbox img { max-width: 92vw; max-height: 88vh; border-radius: 8px; box-shadow: var(--shadow-lg); }
.lightbox .close { position: absolute; top: 18px; right: 22px; color: #fff; font-size: 30px; cursor: pointer; background: none; border: none; }

/* ---------- Alertas ---------- */
.alertas { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.alerta { display: flex; align-items: center; gap: 11px; padding: 11px 15px; border-radius: 10px;
  font-size: 14px; text-decoration: none; border: 1px solid transparent; }
.alerta:hover { text-decoration: none; filter: brightness(.98); }
.alerta b { font-weight: 700; }
.alerta .ai { width: 26px; height: 26px; border-radius: 7px; display: flex; align-items: center;
  justify-content: center; font-weight: 800; flex-shrink: 0; }
.alerta.warn { background: var(--warning-soft); color: var(--warning); }
.alerta.warn .ai { background: var(--warning); color: #fff; }
.alerta.danger { background: var(--danger-soft); color: var(--danger); }
.alerta.danger .ai { background: var(--danger); color: #fff; }

/* ---------- Dashboard ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); display: block; }
.stat:hover { text-decoration: none; border-color: var(--primary); }
.stat .num { font-size: 28px; font-weight: 800; color: var(--text); line-height: 1; }
.stat .lbl { color: var(--text-soft); font-size: 13px; margin-top: 6px; }
.stat.accent .num { color: var(--primary); }
.stat.danger .num { color: var(--danger); }
.estado-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.estado-pill { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 15px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); }
.estado-pill:hover { border-color: var(--primary); text-decoration: none; }
.estado-pill .e { font-weight: 600; color: var(--text); font-size: 13.5px; }
.estado-pill .n { font-weight: 800; color: var(--primary); font-size: 17px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-soft); font-weight: 700; margin: 4px 0 12px; }

/* ---------- Autocomplete ---------- */
.ac-box { position: absolute; top: 100%; left: 0; right: 0; z-index: 50; background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 9px; box-shadow: var(--shadow-lg); margin-top: 3px; max-height: 260px; overflow-y: auto; }
.ac-item { padding: 9px 11px; cursor: pointer; display: flex; flex-direction: column; gap: 1px; }
.ac-item:hover { background: var(--primary-soft); }
.ac-nombre { font-weight: 600; font-size: 13px; }
.ac-sub { font-size: 12px; color: var(--text-soft); }

/* ---------- Alerts ---------- */
.messages { margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
.alert { padding: 11px 15px; border-radius: 9px; font-size: 14px; border: 1px solid transparent; }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-error, .alert-danger { background: var(--danger-soft); color: var(--danger); }
.alert-warning { background: var(--warning-soft); color: var(--warning); }
.alert-info { background: var(--primary-soft); color: var(--primary); }

/* ---------- Atajos (ayuda) ---------- */
kbd { background: var(--surface-2); border: 1px solid var(--border-strong); border-bottom-width: 2px;
  border-radius: 5px; padding: 1px 6px; font-size: 12px; font-family: var(--font); color: var(--text); }

/* ---------- Login ---------- */

/* ---------- Manual de uso ---------- */
.manual { max-width: 860px; }
.manual h2 { font-size: 19px; margin: 28px 0 10px; padding-top: 14px; border-top: 1px solid var(--border); }
.manual h2.first { border-top: none; padding-top: 0; }
.manual h3 { font-size: 15px; margin: 18px 0 8px; }
.manual p { margin: 8px 0; }
.manual ol, .manual ul { margin: 8px 0 8px 4px; padding-left: 22px; }
.manual li { margin: 5px 0; }
.manual .tip { background: var(--primary-soft); color: var(--primary); border-radius: 9px; padding: 11px 14px; margin: 12px 0; font-size: 13.5px; }
.manual .toc { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; margin: 14px 0 8px; }
.manual .toc a { padding: 9px 12px; border: 1px solid var(--border); border-radius: 9px; font-size: 13.5px; color: var(--text); }
.manual .toc a:hover { border-color: var(--primary); text-decoration: none; }

@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .app-shell, .main { display: block; }
  .container { max-width: none; padding: 0; }
  .manual h2 { break-after: avoid; }
  body { background: #fff; }
}

/* ---------- Menú colapsado (solo iconos) — solo en desktop ---------- */
@media (min-width: 901px) {
  .app-shell.nav-mini .sidebar { width: 66px; }
  .app-shell.nav-mini .sidebar-brand .txt,
  .app-shell.nav-mini .sidebar-nav .group-label,
  .app-shell.nav-mini .nav-item .count,
  .app-shell.nav-mini .user-mini .info { display: none; }
  .app-shell.nav-mini .sidebar-top { flex-direction: column; gap: 2px; }
  .app-shell.nav-mini .sidebar-brand { justify-content: center; padding: 14px 0 2px; }
  .app-shell.nav-mini .collapse-btn { padding: 2px 0 10px; }
  .app-shell.nav-mini .nav-item { justify-content: center; gap: 0; font-size: 0; }
  .app-shell.nav-mini .nav-item svg { font-size: initial; }
  .app-shell.nav-mini .user-mini { justify-content: center; }
  .app-shell.nav-mini .sidebar-foot form .btn { font-size: 0; padding: 8px 0; }
}

/* ---------- Tour guiado ---------- */
.tour-backdrop { position: fixed; inset: 0; background: rgba(10,14,26,.6); z-index: 200; }
.tour-highlight { position: relative; z-index: 201; box-shadow: 0 0 0 4px var(--primary); border-radius: 8px; }
.tour-pop { position: fixed; z-index: 202; background: var(--surface); color: var(--text); border: 1px solid var(--border-strong);
  border-radius: 12px; box-shadow: var(--shadow-lg); padding: 16px; width: 290px; max-width: 92vw; }
.tour-pop h4 { margin: 0 0 6px; font-size: 15px; }
.tour-pop p { margin: 0 0 12px; font-size: 13.5px; color: var(--text-soft); }
.tour-pop .row { display: flex; align-items: center; gap: 8px; }
.tour-pop .row .spacer { flex: 1; }
.tour-pop .paso { font-size: 12px; color: var(--text-soft); }

.no-mobile { display: inline-flex; }

/* ---------- Mobile drawer ---------- */
.backdrop { display: none; position: fixed; inset: 0; background: rgba(5,8,18,.5); z-index: 40; }

@media (max-width: 900px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .checklist { grid-template-columns: repeat(2, 1fr); }
  .dl { grid-template-columns: 1fr; gap: 2px; }
  .dl dt { margin-top: 8px; }

  .no-mobile { display: none; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%); transition: transform .22s; }
  .app-shell.nav-open .sidebar { transform: translateX(0); }
  .app-shell.nav-open .backdrop { display: block; }
  .topbar .hamburger { display: inline-flex; }

  table.grilla thead { display: none; }
  table.grilla, table.grilla tbody, table.grilla tr, table.grilla td { display: block; width: 100%; }
  table.grilla tr { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; padding: 11px 13px; background: var(--surface); }
  table.grilla tbody td { border: none; padding: 3px 0; }
  table.grilla tbody td.col-opt { display: none; }
  table.grilla tbody td::before { content: attr(data-label) ": "; font-weight: 600; color: var(--text-soft); }
  table.grilla tbody td.col-cliente { font-size: 15px; font-weight: 700; padding-bottom: 6px; }
  table.grilla tbody td.col-cliente::before { content: ""; }
}

/* ===== AdaBox: CRM pipeline ===== */
.pipeline { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 10px; align-items: flex-start; }
.pipe-col { background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius);
            min-width: 230px; flex: 1 0 230px; padding: 10px; }
.pipe-head { font-weight: 700; font-size: 13px; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.pipe-head .n { background: var(--surface); border: 1px solid var(--border); border-radius: 99px;
                padding: 0 8px; font-size: 12px; color: var(--text-soft); }
.pipe-col.ganado .pipe-head { color: var(--success); }
.pipe-col.perdido .pipe-head { color: var(--text-soft); }
.pipe-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
             padding: 10px; margin-bottom: 8px; box-shadow: var(--shadow); }
.pipe-card .nombre { font-weight: 600; }
.input-sm { padding: 4px 8px; font-size: 12px; }

/* ===== AdaBox: chat (WhatsApp / asistente IA) ===== */
.chat-card { display: flex; flex-direction: column; max-width: 760px; }
.chat-scroll { padding: 14px; overflow-y: auto; max-height: 55vh; min-height: 220px;
               display: flex; flex-direction: column; gap: 8px; }
.msg { display: flex; }
.msg.out { justify-content: flex-end; }
.msg .burbuja { max-width: 78%; padding: 8px 12px; border-radius: 12px; font-size: 14px;
                background: var(--bg-soft); border: 1px solid var(--border); white-space: pre-wrap; }
.msg.out .burbuja { background: var(--primary-soft); border-color: transparent; }
.msg .meta { font-size: 11px; color: var(--text-soft); margin-top: 4px; }
.chat-input { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); }
.chat-input .input { flex: 1; }

/* ===== AdaBox: simulador de teléfono ===== */
.telefono { overflow: hidden; }
.telefono-top { background: #075e54; color: #fff; padding: 10px 14px; font-weight: 600;
                border-radius: var(--radius) var(--radius) 0 0; }
[data-theme="dark"] .telefono-top { background: #0b3d36; }

/* ===== Kanban drag & drop ===== */
.pipe-card[draggable="true"] { cursor: grab; }
.pipe-card[draggable="true"]:active { cursor: grabbing; }
.pipe-col.drop-hover { outline: 2px dashed var(--primary); outline-offset: -2px; background: var(--primary-soft); }
.solo-mobile { display: none; }
@media (max-width: 760px) { .solo-mobile { display: block; } .no-mobile { display: none; } }


/* ===== Pulido estilo Zenith ===== */
table.grilla thead th { background: var(--surface-2); }
.input:focus, select.input:focus, textarea.input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--primary) 18%, transparent);
}
.card { border: 1px solid var(--border); }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.nav-item [data-lucide], .nav-item svg { width: 19px; height: 19px; }
.icon-btn [data-lucide], .icon-btn svg { width: 18px; height: 18px; }


/* ===== Tablas ordenables ===== */
table.grilla thead th { cursor: pointer; user-select: none; white-space: nowrap; }
table.grilla thead th:hover { color: var(--text); }
table.grilla thead th .flecha { opacity: .35; font-size: 9px; margin-left: 5px; }
table.grilla thead th.orden-asc .flecha, table.grilla thead th.orden-desc .flecha { opacity: 1; color: var(--primary); }

/* ===== Menú de usuario (topbar) ===== */
.user-menu { position: relative; }
.avatar-btn { width: 38px; height: 38px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--primary); color: var(--on-primary, #fff); font-weight: 700; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center; }
.avatar-btn:hover { filter: brightness(1.08); }
.user-pop { position: absolute; right: 0; top: 46px; width: 230px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 6px; z-index: 60; }
.user-pop .up-head { padding: 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.user-pop .up-head b { display: block; font-size: 13.5px; }
.user-pop .up-head small { color: var(--text-soft); font-size: 11.5px; }
.user-pop a, .user-pop button { display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 12px; border: none; background: none; border-radius: var(--radius-sm);
  color: var(--text); font-size: 13.5px; cursor: pointer; text-align: left; font-family: inherit; }
.user-pop a:hover, .user-pop button:hover { background: var(--surface-2); text-decoration: none; }
.user-pop .salir { color: var(--danger); }
.user-pop [data-lucide], .user-pop svg { width: 16px; height: 16px; }

/* ===== Chat IA flotante ===== */
.ia-widget { position: fixed; right: 22px; bottom: 22px; z-index: 80; }
.ia-burbuja { width: 52px; height: 52px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--primary); color: var(--on-primary, #fff); box-shadow: var(--shadow-lg);
  display: flex; align-items: center; justify-content: center; transition: transform .15s ease; }
.ia-burbuja:hover { transform: scale(1.07); }
.ia-burbuja [data-lucide], .ia-burbuja svg { width: 24px; height: 24px; }
.ia-panel { position: absolute; right: 0; bottom: 64px; width: 360px; max-width: calc(100vw - 44px);
  display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow-lg); }
.ia-panel .chat-scroll { max-height: 46vh; min-height: 180px; }
.ia-panel-head { display: flex; align-items: center; gap: 6px; padding: 10px 12px;
  border-bottom: 1px solid var(--border); font-weight: 700; font-size: 14px; }
@media (max-width: 760px) {
  .ia-widget { right: 14px; bottom: 14px; }
  .ia-panel { width: calc(100vw - 28px); }
  .ia-panel .chat-scroll { max-height: 55vh; }
}

/* ===== Burbuja IA: look 3D + animaciones (sigue el color de acento) ===== */
.ia-burbuja {
  background: radial-gradient(circle at 30% 25%,
              color-mix(in oklch, var(--primary) 55%, white) 0%,
              var(--primary) 45%,
              color-mix(in oklch, var(--primary) 75%, black) 100%);
  box-shadow:
    inset 0 2px 4px color-mix(in oklch, white 45%, transparent),
    inset 0 -3px 5px color-mix(in oklch, black 28%, transparent),
    0 6px 16px color-mix(in oklch, var(--primary) 45%, transparent),
    0 2px 4px oklch(0 0 0 / .2);
  animation: ia-flotar 3.2s ease-in-out infinite;
  position: relative;
}
.ia-burbuja::after { /* anillo de pulso */
  content: ""; position: absolute; inset: -4px; border-radius: 50%;
  border: 2px solid color-mix(in oklch, var(--primary) 60%, transparent);
  animation: ia-pulso 3.2s ease-out infinite;
  pointer-events: none;
}
.ia-burbuja:hover { transform: scale(1.12) rotate(-6deg); animation-play-state: paused; }
.ia-burbuja:hover::after { animation-play-state: paused; opacity: 0; }
.ia-burbuja:active { transform: scale(.96); }
@keyframes ia-flotar {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}
@keyframes ia-pulso {
  0% { transform: scale(.85); opacity: .9; }
  70%, 100% { transform: scale(1.45); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .ia-burbuja, .ia-burbuja::after { animation: none; }
}

/* ===== Selector de columnas ===== */
.cols-ctl { position: relative; display: flex; justify-content: flex-end; margin-bottom: 6px; }
.cols-menu { display: none; position: absolute; right: 0; top: 34px; z-index: 50; min-width: 190px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 8px; }
.cols-menu.open { display: block; }
.cols-menu label { display: flex; align-items: center; gap: 8px; padding: 5px 8px;
  font-size: 13px; border-radius: var(--radius-sm); cursor: pointer; }
.cols-menu label:hover { background: var(--surface-2); }

/* ===== Panel de control con navegación lateral ===== */
.config-layout { display: flex; gap: 18px; align-items: flex-start; }
.config-nav { width: 230px; flex-shrink: 0; padding: 10px; position: sticky; top: 80px;
  display: flex; flex-direction: column; gap: 2px; }
.config-nav .cfg-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--text-soft); font-weight: 700; padding: 12px 10px 4px; }
.config-nav button, .config-nav a { display: flex; align-items: center; gap: 9px; width: 100%;
  text-align: left; border: none; background: none; padding: 8px 10px;
  border-radius: var(--radius-sm); font-size: 13.5px; color: var(--text); cursor: pointer;
  font-family: inherit; text-decoration: none; }
.config-nav [data-lucide], .config-nav svg { width: 16px; height: 16px; flex-shrink: 0;
  color: var(--text-soft); }
.config-nav button.active [data-lucide], .config-nav button.active svg { color: var(--primary); }
.config-nav button:hover, .config-nav a:hover { background: var(--surface-2); }
.config-nav button.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.config-body { flex: 1; min-width: 0; }
.cfg-titulo { font-size: 16px; margin: 0 0 4px; }
.cfg-head { display: flex; align-items: center; gap: 12px; }
.cfg-head .cfg-titulo { flex: 1; }
@media (max-width: 860px) {
  .config-layout { flex-direction: column; }
  .config-nav { width: 100%; position: static; flex-direction: row; flex-wrap: wrap; }
  .config-nav .cfg-label { width: 100%; padding-top: 6px; }
  .config-nav button, .config-nav a { width: auto; }
}

/* Menú de columnas: fila con flechas de orden */
.cols-item { display: flex; align-items: center; gap: 6px; }
.cols-item label { flex: 1; display: flex; align-items: center; gap: 8px; padding: 5px 8px;
  font-size: 13px; border-radius: var(--radius-sm); cursor: pointer; }
.cols-item label:hover { background: var(--surface-2); }
.cols-flechas button { border: 1px solid var(--border); background: var(--surface);
  border-radius: 6px; width: 22px; height: 22px; cursor: pointer; color: var(--text-soft);
  font-size: 11px; line-height: 1; }
.cols-flechas button:hover:not(:disabled) { color: var(--primary); border-color: var(--primary); }
.cols-flechas button:disabled { opacity: .3; cursor: default; }

/* Contador de chats esperando (menú WhatsApp) */
.badge-alerta { margin-left: auto; background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; }

/* Icono de mensajes en la topbar: globito rojo arriba a la derecha */
.icon-btn-mensajes { position: relative; }
.icon-btn-mensajes .badge-alerta { position: absolute; top: -6px; right: -6px; margin: 0;
  min-width: 18px; height: 18px; display: flex; align-items: center; justify-content: center;
  padding: 0 5px; border: 2px solid var(--surface); }


/* ===== Login a dos columnas ===== */
.login-body { margin: 0; }
.login-split { display: flex; min-height: 100vh; }
.login-hero { width: 44%; max-width: 560px; padding: 40px; color: #fff;
  display: flex; flex-direction: column; justify-content: space-between;
  background: linear-gradient(150deg,
    color-mix(in oklch, var(--primary) 88%, black) 0%,
    var(--primary) 55%,
    color-mix(in oklch, var(--primary) 70%, white) 130%); }
.login-hero-top { display: flex; align-items: center; gap: 12px; font-size: 18px; font-weight: 700; }
.login-logo { background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.25);
  width: 42px; height: 42px; border-radius: 11px; display: inline-flex; align-items: center;
  justify-content: center; font-weight: 800; letter-spacing: .5px; }
.login-hero-mid h2 { font-size: 30px; line-height: 1.2; margin: 0 0 12px; letter-spacing: -.5px; }
.login-hero-mid p { font-size: 16px; opacity: .9; max-width: 380px; line-height: 1.6; }
.login-hero-foot { font-size: 12px; opacity: .7; }
.login-form-side { flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 30px; background: var(--bg); }
.login-form-box { width: 100%; max-width: 380px; }
.login-form-head { margin-bottom: 22px; }
.login-form-head .login-logo { background: var(--primary); color: var(--on-primary, #fff);
  border: none; margin-bottom: 14px; }
.login-form-box { font-size: 16px; }
.login-form-head h1 { font-size: 30px; margin: 0 0 6px; color: var(--text); }
.login-form-head .muted { font-size: 15px; }
.login-form-box .field label { font-size: 15px; margin-bottom: 4px; }
.login-form-box .input { padding: 14px 15px; font-size: 16px; }
.login-form-box .btn { padding: 13px; font-size: 16px; }
.login-form-box a { font-size: 15px; }
.solo-mobile { display: none; }
@media (max-width: 820px) {
  .login-hero { display: none; }
  .solo-mobile { display: inline-flex; }
}
/* ===== Manual ===== */
.manual-layout { display: flex; gap: 18px; align-items: flex-start; }
.manual-nav { width: 220px; flex-shrink: 0; padding: 12px; position: sticky; top: 80px;
  display: flex; flex-direction: column; gap: 1px; }
.manual-nav a { padding: 7px 10px; border-radius: var(--radius-sm); font-size: 13px;
  color: var(--text-soft); text-decoration: none; }
.manual-nav a:hover { background: var(--surface-2); color: var(--text); }
.manual-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.manual-body .m-titulo { font-size: 17px; margin: 0 0 10px; color: var(--text); }
.manual-body p { line-height: 1.65; }
.manual-body section { scroll-margin-top: 76px; }
/* Diagrama del circuito */
.flujo { display: flex; align-items: stretch; gap: 8px; flex-wrap: wrap; }
.flujo-paso { flex: 1; min-width: 150px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.flujo-paso .n { width: 24px; height: 24px; border-radius: 50%; background: var(--primary);
  color: var(--on-primary, #fff); font-weight: 700; font-size: 13px; display: flex;
  align-items: center; justify-content: center; }
.flujo-paso b { font-size: 14px; } .flujo-paso small { color: var(--text-soft); font-size: 12px; line-height: 1.4; }
.flujo-paso.ganado { border-color: var(--success); }
.flujo-paso.ganado .n { background: var(--success); }
.flujo-flecha { align-self: center; color: var(--text-soft); font-size: 20px; }
@media (max-width: 820px) {
  .manual-nav { display: none; }
  .flujo-flecha { display: none; }
}


/* Modo claro estilo Finder: sidebar gris, contenido y tarjetas blancas (separadas por borde) */
:root table.grilla thead th { background: var(--surface-2); }

/* Manual: pasos y botones por sección */
.m-shot { display: block; width: 100%; max-width: 760px; margin: 12px 0; border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow); }
.m-sub { font-size: 15px; font-weight: 700; margin: 22px 0 4px; color: var(--text); }
.m-pasos { margin: 6px 0 4px; padding-left: 20px; line-height: 1.7; }
.m-pasos li { margin-bottom: 4px; }
.m-botones { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.m-boton { display: flex; gap: 11px; align-items: flex-start; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 12px; font-size: 14px; }
.m-boton .bi { flex-shrink: 0; width: 30px; height: 30px; border-radius: 8px; background: var(--primary-soft);
  color: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 700; }
.m-boton .bi svg, .m-boton .bi [data-lucide] { width: 17px; height: 17px; }
.m-boton b { color: var(--text); }


/* ===== UX tablas y buscadores ===== */
table.grilla tbody tr { transition: background .1s; }
[x-cloak] { display: none !important; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.form-grid label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--text-soft); }
.agenda-h { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-soft);
  margin: 18px 0 8px; }
.agenda-h.agenda-vencidas { color: var(--danger, #c0392b); }
/* Calendario mensual de la agenda */
.cal { overflow: hidden; }
.cal-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.cal-titulo { font-size: 16px; min-width: 170px; text-align: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-dow { background: var(--surface-2); border-bottom: 1px solid var(--border); }
.cal-dow-cell { padding: 8px; text-align: center; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .4px; color: var(--text-soft); }
.cal-cell { min-height: 104px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  padding: 6px 7px; display: flex; flex-direction: column; gap: 3px; transition: background .12s ease; }
.cal-cell:nth-child(7n) { border-right: none; }
.cal-cell[data-dia]:hover { background: var(--surface-2); }   /* solo días del mes (arrastrables) */
.cal-out { background: var(--surface-2); }
.cal-out .cal-num { opacity: .4; }
.cal-num { font-size: 12px; font-weight: 600; color: var(--text-soft); align-self: flex-start; }
.cal-today { background: color-mix(in oklch, var(--primary) 7%, var(--surface)); }
.cal-today .cal-num { background: var(--primary); color: var(--on-primary, #fff); border-radius: 50%;
  width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; }
.cal-chip { display: block; font-size: 11px; line-height: 1.3; padding: 3px 7px; border-radius: 7px;
  background: var(--primary-soft); color: var(--primary); white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; border-left: 3px solid var(--primary); cursor: grab; }
.cal-chip:hover { filter: brightness(.97); }
.cal-chip:active { cursor: grabbing; }
.cal-chip.dragging { opacity: .45; }
.cal-chip.venc { background: #fde8e8; color: #b42318; border-left-color: #b42318; }
.cal-chip .cal-hora { font-weight: 700; }
/* Día resaltado mientras arrastrás un recontacto encima */
.cal-cell.cal-drop { background: var(--primary-soft); box-shadow: inset 0 0 0 2px var(--primary); }
.sync-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
@media (max-width: 720px) {
  .cal-cell { min-height: 64px; }
  .cal-chip { font-size: 10px; }
  .sync-grid { grid-template-columns: 1fr; gap: 16px; }
}
.burbuja .autor { font-size: 11px; font-weight: 700; color: var(--primary); margin-bottom: 2px; }
.filtros .campo.grow .input[type="search"] {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238b93a7' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='M15 15l-4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 11px center; padding-left: 34px;
}

/* Iconos en línea (dentro de texto, badges o tablas) */
.ico-inline { display:inline-flex; align-items:center; vertical-align:middle; }
.ico-inline svg { width:15px; height:15px; }
