/* ===========================================================
   main.css — base, layout, topbar, toolbars, buttons, toasts
   =========================================================== */

:root {
  /* ===== Sistema de diseño Altto (navy) + minimalismo Apple ===== */
  --navy:          #0b2340;
  --navy-deep:     #0f2a49;
  --azure:         #264a78;
  --azure-bright:  #345f95;
  --azure-tint:    #eef2f7;

  /* Modo claro atenuado (2026-07-29): el blanco puro + texto casi negro
     deslumbraba en jornadas largas. Papel frío en vez de #fff, tinta un punto
     más suave y acentos desaturados — el contraste sigue sobre AA. */
  --bg:            #f8f9fb;
  --bg-alt:        #f1f3f7;
  --bg-elev:       #ffffff;

  --fg:            #1e232b;
  --fg-muted:      #616b7a;
  --fg-subtle:     #949cab;

  --line:          #e6e9ee;
  --line-strong:   #d5dae2;
  --hover:         #edf0f5;
  --selected:      #e7edf6;

  /* Accent = azure Altto */
  --accent:        #2c527f;
  --accent-hover:  #1a3b60;
  --accent-soft:   #e9eff7;
  --accent-fg:     #ffffff;
  --warn:          #bf8a2c;
  --warn-soft:     #f8f1e0;
  --warn-fg:       #7a5715;
  --danger:        #ab3025;
  --danger-soft:   #f8ebe9;
  --danger-fg:     #85261d;
  --info:          #3a6396;

  /* UI — radios suaves Apple */
  --radius-sm:     8px;
  --radius:        12px;
  --radius-lg:     16px;
  --radius-xl:     22px;
  --shadow-sm:     0 1px 2px rgba(15,23,42,.035), 0 1px 1px rgba(15,23,42,.025);
  --shadow:        0 1px 2px rgba(15,23,42,.035), 0 12px 28px -16px rgba(15,23,42,.10);
  --shadow-lg:     0 1px 3px rgba(15,23,42,.05), 0 28px 56px -24px rgba(15,23,42,.18);

  --topbar-h:      60px;
  --toolbar-h:     auto;

  --ease:          cubic-bezier(.2,.8,.2,1);
  --ease-out:      cubic-bezier(.16,1,.3,1);

  --font-sans:     "Inter Tight", -apple-system, system-ui, "SF Pro Display", "Segoe UI", sans-serif;
  --font-mono:     "JetBrains Mono", "SF Mono", ui-monospace, monospace;

  --z-toast:       3000;
  --z-modal:       2000;
  --z-slide:       1800;
  --z-topbar:      100;

  color-scheme: light;
}

/* ===== Dark theme ===== */
[data-theme="dark"] {
  /* Elevación más marcada (2026-07-29): fondo, tarjeta y borde con más
     distancia entre sí — antes las fichas se fundían con la columna. */
  --bg:            #0c1726;
  --bg-alt:        #091220;
  --bg-elev:       #162943;

  --fg:            #eef2f7;
  --fg-muted:      #9aa7ba;
  --fg-subtle:     #64748b;

  --line:          #22344f;
  --line-strong:   #33496b;
  --hover:         #152439;
  --selected:      #18304f;

  --accent:        #4E86C9;
  --accent-hover:  #76A8E4;
  --accent-soft:   #13294a;
  --accent-fg:     #ffffff;
  --warn:          #e0a93c;
  --warn-soft:     #2e2410;
  --warn-fg:       #f3cf86;
  --danger:        #e5675c;
  --danger-soft:   #3a1714;
  --danger-fg:     #f5b4ad;
  --info:          #76A8E4;

  --shadow-sm:     0 1px 2px rgba(0,0,0,.4);
  --shadow:        0 1px 2px rgba(0,0,0,.4), 0 16px 36px -18px rgba(0,0,0,.7);
  --shadow-lg:     0 24px 60px -20px rgba(0,0,0,.75);

  color-scheme: dark;
}
[data-theme="dark"] .source-pill.sheet { color: var(--accent-hover); }
[data-theme="dark"] .user-role { color: var(--accent-hover); }
[data-theme="dark"] .stage-tab.active { background: var(--accent); color: #ffffff; border-color: var(--accent); }
[data-theme="dark"] .stage-tab.active .stage-tab-count { background: rgba(0,0,0,0.25); }

/* Theme toggle row in user dropdown */
.theme-toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; border-top: 1px solid var(--line);
  font-size: 13px; color: var(--fg);
}
.theme-switch {
  position: relative; width: 38px; height: 20px;
  border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--hover); cursor: pointer; transition: background 0.15s;
  flex-shrink: 0;
}
.theme-switch::after {
  content: ""; position: absolute; top: 1px; left: 1px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--fg-muted); transition: transform 0.15s, background 0.15s;
}
[data-theme="dark"] .theme-switch { background: var(--accent-soft); border-color: var(--accent); }
[data-theme="dark"] .theme-switch::after { transform: translateX(18px); background: var(--accent); }

/* ===== Reset / base ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
/* El atributo [hidden] debe ganar siempre a un display:flex/grid explícito
   (si no, navs/legends toggleados por JS quedan visibles — bug toolbar calendario). */
[hidden] { display: none !important; }
*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
html, body { height: 100%; }
body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--fg);
  background: var(--bg-alt);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--fg-muted); }
.subtle { color: var(--fg-subtle); }

/* ===== App shell ===== */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--bg-alt);
}
.app-main {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ===== Topbar ===== */
.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
}
.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 20px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.01em;
}
.brand-mark {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  display: inline-block;
  position: relative;
}
.brand-mark::after {
  content: "";
  position: absolute; inset: 6px;
  border-radius: 3px;
  background: var(--bg);
}
.brand-text {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.brand-text small {
  font-size: 11px;
  font-weight: 500;
  color: var(--fg-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.view-tabs {
  display: flex;
  gap: 2px;
  align-items: center;
  /* 8 pestañas no caben en laptop angosta: se desliza en vez de romper la
     topbar en dos filas. */
  overflow-x: auto;
  scrollbar-width: none;
  min-width: 0;
}
.view-tabs::-webkit-scrollbar { display: none; }
.view-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
  color: var(--fg-muted);
  border-radius: var(--radius-sm);
  transition: background 0.1s, color 0.1s;
}
.view-tab:hover { background: var(--hover); color: var(--fg); }
/* La pestaña activa cambia SOLO color y fondo — no el peso: subir a 600 en el
   activo ensanchaba el texto y empujaba las pestañas vecinas al navegar. */
.view-tab.active {
  background: var(--accent-soft);
  color: var(--accent-hover);
}
[data-theme="dark"] .view-tab.active { color: var(--accent); }

/* sync status + source pill */
.sync-status {
  font-size: 11px;
  color: var(--fg-subtle);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-variant-numeric: tabular-nums;
}
.sync-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--fg-subtle);
}
.sync-status.live .sync-dot {
  background: var(--accent);
  animation: pulse 2s infinite;
}
.sync-status.loading .sync-dot {
  background: var(--warn);
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.source-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.source-pill.local {
  background: var(--warn-soft);
  border-color: var(--warn);
  color: var(--warn-fg);
}
.source-pill.sheet {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: #6b21a8;
}
.source-pill .dot {
  width: 6px; height: 6px; border-radius: 50%;
  display: inline-block;
}
.source-pill.local .dot { background: var(--warn); }
.source-pill.sheet .dot { background: var(--accent); }

/* User menu */
.user-menu { position: relative; }
.user-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 4px 4px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  color: var(--fg);
  font-size: 13px;
}
.user-btn:hover { background: var(--hover); }
.user-btn[aria-expanded="true"] { background: var(--hover); border-color: var(--line); }
.user-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}
.user-name {
  font-weight: 500;
  font-size: 13px;
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.caret { color: var(--fg-muted); font-size: 10px; }

.user-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-width: 260px;
  box-shadow: var(--shadow);
  z-index: var(--z-topbar);
  overflow: hidden;
}
.user-dropdown-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.user-fullname { font-weight: 600; font-size: 14px; }
.user-email   { font-size: 12px; color: var(--fg-muted); margin-top: 2px; }
.user-role    {
  display: inline-block;
  margin-top: 8px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--accent-soft);
  color: var(--accent-hover);
  padding: 2px 8px;
  border-radius: 999px;
}
.user-dropdown-item {
  width: 100%;
  background: none;
  border: 0;
  text-align: left;
  padding: 10px 16px;
  font-size: 13px;
  color: var(--fg);
  cursor: pointer;
}
.user-dropdown-item:hover { background: var(--hover); }

/* ===== Views ===== */
.view {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-alt);
}
.view[hidden] { display: none !important; }
.view-toolbar {
  flex-shrink: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding: 12px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.view-body {
  flex: 1;
  overflow: auto;
  padding: 20px 24px;
}
/* El kanban gestiona su propio scroll (columnas independientes): el contenedor
   no debe scrollear en vertical o volvemos a arrastrar toda la pantalla. */
.view-body-kanban { padding: 16px 24px; overflow: hidden; }

.toolbar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.toolbar-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

/* search */
.search-wrap {
  position: relative;
  flex: 1;
  max-width: 420px;
}
.search-input {
  width: 100%;
  font-family: inherit;
  font-size: 13px;
  padding: 8px 36px 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--fg);
  outline: none;
  transition: border-color 0.1s, box-shadow 0.1s;
}
.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(157, 0, 255, 0.12);
}
.search-kbd {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--hover);
  border: 1px solid var(--line);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  color: var(--fg-muted);
  pointer-events: none;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 7px 14px;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  color: var(--fg);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
  white-space: nowrap;
}
.btn:hover { background: var(--hover); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.btn-ghost { border-color: transparent; background: transparent; }
.btn.btn-ghost:hover { background: var(--hover); }
/* Variante compacta: era clase marcadora sin definición — inbox y flujo la
   usan para acciones dentro de tarjetas (Reanudar Claudia, etc.). */
.btn.btn-sm { font-size: 12px; padding: 4px 10px; border-radius: var(--radius-sm); }
.btn.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}
.btn.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn.btn-danger:hover { background: #dc2626; border-color: #dc2626; }
.btn.icon-only { padding: 7px 10px; }
.btn-block { width: 100%; justify-content: center; }

/* primary submit (login + forms) */
.btn-primary.btn-block {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent);
  border: 1px solid var(--accent);
  color: var(--accent-fg);
  font-weight: 600;
  padding: 10px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  width: 100%;
}
.btn-primary.btn-block:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

/* ===== Badges / tags ===== */
.tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--selected);
  color: var(--fg);
  letter-spacing: 0.01em;
}
.tag.tag-outline { background: transparent; border: 1px solid var(--line-strong); }
.tag.tag-accent  { background: var(--accent-soft); color: var(--accent-hover); }
.tag.tag-warn    { background: var(--warn-soft);   color: var(--warn-fg); }
.tag.tag-danger  { background: var(--danger-soft); color: var(--danger-fg); }

/* ===== Empty state ===== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 24px;
  color: var(--fg-muted);
  gap: 12px;
}
.empty-state .empty-icon {
  font-size: 32px;
  color: var(--fg-subtle);
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px dashed var(--line-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.empty-state h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--fg);
}
.empty-state p { max-width: 360px; font-size: 13px; }
.empty-state .btn { margin-top: 6px; }

/* ===== Skeletons ===== */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--hover) 0%,
    var(--bg) 50%,
    var(--hover) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.6s linear infinite;
  border-radius: var(--radius-sm);
  display: block;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-line {
  height: 12px;
  margin-bottom: 8px;
}
.skeleton-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 8px;
}

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: var(--z-toast);
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: var(--bg);
  border: 1px solid var(--line);
  border-left: 4px solid var(--info);
  border-radius: var(--radius);
  padding: 12px 36px 12px 14px;
  font-size: 13px;
  max-width: 380px;
  box-shadow: var(--shadow);
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: toast-in 0.18s ease-out;
}
.toast.toast-success { border-left-color: var(--accent); }
.toast.toast-error   { border-left-color: var(--danger); }
.toast.toast-info    { border-left-color: var(--info); }
.toast.toast-warn    { border-left-color: var(--warn); }
.toast .toast-msg {
  flex: 1;
  white-space: pre-wrap;
  line-height: 1.4;
}
.toast .toast-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: 0;
  color: var(--fg-muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}
.toast .toast-close:hover { color: var(--fg); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== Stage tabs (filter strip) ===== */
/* Vendedores | Compradores segmented toggle (Leads toolbar) */
.lead-type-toggle {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.lead-type-tab {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-muted);
  background: transparent;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.1s, color 0.1s;
}
.lead-type-tab:hover { color: var(--fg); }
.lead-type-tab.active {
  background: var(--fg);
  color: var(--bg);
}

.stage-tabs-scroll {
  overflow-x: auto;
  margin: 0 -24px;
  padding: 0 24px;
  scrollbar-width: thin;
}
.stage-tabs {
  display: inline-flex;
  gap: 4px;
  padding-bottom: 4px;
}
.stage-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-muted);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}
.stage-tab:hover { background: var(--hover); color: var(--fg); }
.stage-tab.active {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}
.stage-tab .stage-tab-count {
  display: inline-block;
  background: rgba(0, 0, 0, 0.06);
  padding: 1px 6px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  font-weight: 500;
}
.stage-tab.active .stage-tab-count {
  background: rgba(255, 255, 255, 0.18);
}
.stage-tab .stage-tab-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--fg-subtle);
}

/* ===== Calendar legend ===== */
.cal-legend {
  display: flex;
  gap: 12px;
  margin-left: auto;
  font-size: 12px;
  color: var(--fg-muted);
  align-items: center;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.legend-swatch {
  width: 12px; height: 12px;
  border-radius: 3px;
  background: var(--line);
  display: inline-block;
}
.legend-swatch.visit-day {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
}

/* ===== Calendar nav ===== */
.cal-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}
.cal-title {
  font-size: 16px;
  font-weight: 600;
  text-transform: capitalize;
  min-width: 180px;
  text-align: center;
  margin: 0 4px;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar-left, .topbar-right { gap: 10px; }
  .view-tabs { gap: 0; }
  .view-tab { padding: 6px 8px; font-size: 12px; }
  .user-name { display: none; }
  .view-toolbar { padding: 10px 12px; }
  .view-body { padding: 12px; }
  .stage-tabs-scroll { margin: 0 -12px; padding: 0 12px; }
}

/* by altto wordmark (rebrand 2026-06-20) */
.brand-text small { text-transform: none; letter-spacing: .01em; font-weight: 500; color: var(--fg-subtle, #94a3b8); }

/* ===========================================================
   Altto refinement — navy + minimalismo Apple (rebrand 2026-06-20)
   token swap recolorea todo; aquí pulimos componentes clave.
   =========================================================== */
body {
  font-feature-settings: "tnum" 0;
  letter-spacing: -0.006em;
  background:
    radial-gradient(1200px 600px at 100% -10%, rgba(38,74,120,.05), transparent 60%),
    var(--bg-alt);
}
::selection { background: rgba(38,74,120,.16); }
h1,h2,h3 { letter-spacing: -0.02em; }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 999px; border: 3px solid transparent; background-clip: padding-box; }

/* Topbar vidrio + brand wordmark "Jatto panel · by altto" (sin recuadro) */
.topbar {
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  padding: 0 28px;
}
.brand { font-family: var(--font-sans); font-weight: 700; letter-spacing: -0.02em; }
.brand-text { align-items: baseline; gap: 7px; }
.brand-text small {
  color: var(--fg-subtle); font-weight: 500; font-size: 11px;
  text-transform: none; letter-spacing: .01em;
}

/* Tabs: control segmentado */
.view-tabs { gap: 2px; background: var(--bg-alt); padding: 3px; border-radius: 999px; border: 1px solid var(--line); }
.view-tab { padding: 7px 15px; font-size: 13px; font-weight: 500; border-radius: 999px; color: var(--fg-muted); transition: background .18s var(--ease), color .18s var(--ease); }
.view-tab:hover { background: transparent; color: var(--fg); }
/* Sin font-weight: el activo ya se distingue por fondo + color + sombra, y
   cambiar el peso movía de sitio a las pestañas vecinas en cada navegación. */
.view-tab.active { background: var(--bg-elev); color: var(--navy); box-shadow: 0 1px 2px rgba(15,23,42,.08), 0 0 0 1px var(--line); }
[data-theme="dark"] .view-tab.active { background: var(--bg-elev); color: var(--accent-hover); box-shadow: 0 1px 2px rgba(0,0,0,.5); }

/* Avatar + dropdown navy */
.user-avatar { background: linear-gradient(150deg, var(--azure-bright), var(--navy)); }
.user-role { background: var(--azure-tint); color: var(--azure); }
[data-theme="dark"] .user-role { background: var(--accent-soft); color: var(--accent-hover); }
.user-dropdown { border-radius: var(--radius); box-shadow: var(--shadow-lg); }

/* Inputs foco azure */
.search-input:focus, input:focus, select:focus, textarea:focus { border-color: var(--azure); box-shadow: 0 0 0 3px rgba(38,74,120,.14); }
.source-pill.sheet { background: var(--azure-tint); border-color: var(--azure); color: var(--azure); }

/* Botones tacto Apple */
.btn { border-radius: var(--radius); transition: background .16s var(--ease), border-color .16s var(--ease), box-shadow .16s var(--ease), transform .12s var(--ease); }
.btn:active { transform: translateY(.5px) scale(.99); }
.btn.btn-primary {
  background: linear-gradient(180deg, var(--azure), var(--navy));
  border-color: var(--navy);
  box-shadow: 0 1px 2px rgba(11,35,64,.25), 0 8px 18px -10px rgba(11,35,64,.5);
}
.btn.btn-primary:hover { filter: brightness(1.06); }

/* Cards KPI / reportes */
.kpi-card { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); transition: transform .2s var(--ease), box-shadow .2s var(--ease); }
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

/* Aire + modales */
.view-toolbar { padding: 14px 28px; }
.view-body { padding: 22px 28px; }
.modal-content { border-radius: var(--radius-lg) !important; box-shadow: var(--shadow-lg) !important; }
.toast { border-radius: var(--radius); box-shadow: var(--shadow); }

/* ===========================================================
   Sofia widget — FAB robot de contacto directo (bottom-right)
   =========================================================== */
#sofia-widget { position: fixed; right: 24px; bottom: 24px; z-index: var(--z-toast, 3000); }
.sofia-fab {
  width: 58px; height: 58px; border-radius: 50%; border: none; cursor: pointer;
  background: linear-gradient(150deg, var(--azure-bright, #345f95), var(--navy, #0b2340));
  color: #fff; display: grid; place-items: center; position: relative;
  box-shadow: 0 10px 26px -8px rgba(11,35,64,.6), 0 2px 6px rgba(11,35,64,.3);
  transition: transform .2s var(--ease, ease), box-shadow .2s var(--ease, ease), filter .15s var(--ease, ease);
  animation: sofia-pop-in .45s var(--ease-out, ease) both;
}
.sofia-fab:hover { transform: translateY(-2px) scale(1.04); filter: brightness(1.07); }
.sofia-fab:active { transform: scale(.96); }
.sofia-fab.open { filter: brightness(1.05); }
.sofia-fab-dot {
  position: absolute; top: 5px; right: 6px; width: 11px; height: 11px; border-radius: 50%;
  background: #2fcc71; border: 2px solid var(--navy, #0b2340);
  box-shadow: 0 0 0 0 rgba(47,204,113,.6); animation: sofia-pulse 2.4s var(--ease, ease) infinite;
}
@keyframes sofia-pulse { 0%{box-shadow:0 0 0 0 rgba(47,204,113,.5);} 70%{box-shadow:0 0 0 8px rgba(47,204,113,0);} 100%{box-shadow:0 0 0 0 rgba(47,204,113,0);} }
@keyframes sofia-pop-in { from{opacity:0;transform:translateY(14px) scale(.85);} to{opacity:1;transform:none;} }

/* Ventana de chat */
.sofia-chat {
  position: absolute; right: 0; bottom: 70px; width: 360px; max-width: calc(100vw - 28px);
  height: 480px; max-height: calc(100vh - 110px); display: flex; flex-direction: column;
  background: var(--bg, #fff); border: 1px solid var(--line); border-radius: var(--radius-lg, 16px);
  box-shadow: var(--shadow-lg); overflow: hidden; transform-origin: bottom right;
  opacity: 0; transform: translateY(10px) scale(.96); transition: opacity .22s var(--ease-out), transform .22s var(--ease-out);
}
.sofia-chat.show { opacity: 1; transform: none; }
.sofia-chat-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  background: linear-gradient(180deg, var(--azure, #264a78), var(--navy, #0b2340)); color: #fff;
}
.sofia-chat-head .sofia-ava { background: rgba(255,255,255,.16); }
.sofia-htext { line-height: 1.2; }
.sofia-ava { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0;
  background: linear-gradient(150deg, var(--azure-bright, #345f95), var(--navy, #0b2340)); color: #fff; }
.sofia-ava svg { width: 22px; height: 22px; }
.sofia-name { font-weight: 700; font-size: 15px; letter-spacing: -.01em; }
.sofia-on { font-size: 10px; font-weight: 600; color: #6ee7a8; margin-left: 4px; }
.sofia-role { font-size: 12px; color: rgba(255,255,255,.75); }
.sofia-chat-head .sofia-role { color: rgba(255,255,255,.75); }
.sofia-x { margin-left: auto; background: none; border: none; color: rgba(255,255,255,.8); cursor: pointer; font-size: 14px; }
.sofia-x:hover { color: #fff; }

.sofia-msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: var(--bg-alt); }
.sofia-msg { display: flex; }
.sofia-msg.me { justify-content: flex-end; }
.sofia-bubble {
  max-width: 82%; padding: 9px 13px; border-radius: 16px; font-size: 13.5px; line-height: 1.5;
  white-space: pre-wrap; word-wrap: break-word; box-shadow: var(--shadow-sm);
}
.sofia-msg.sofia .sofia-bubble { background: var(--bg); border: 1px solid var(--line); border-bottom-left-radius: 5px; color: var(--fg); }
.sofia-msg.me .sofia-bubble { background: linear-gradient(180deg, var(--azure, #264a78), var(--navy, #0b2340)); color: #fff; border-bottom-right-radius: 5px; }
.sofia-dots { display: inline-flex; gap: 4px; align-items: center; }
.sofia-dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--fg-subtle); animation: sofia-bounce 1.2s var(--ease) infinite; }
.sofia-dots span:nth-child(2) { animation-delay: .15s; }
.sofia-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes sofia-bounce { 0%,60%,100%{ transform: translateY(0); opacity:.4 } 30%{ transform: translateY(-4px); opacity:1 } }

.sofia-input { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); background: var(--bg); }
.sofia-input input {
  flex: 1; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 999px;
  font: inherit; font-size: 13.5px; background: var(--bg); color: var(--fg); outline: none;
}
.sofia-input input:focus { border-color: var(--azure); box-shadow: 0 0 0 3px rgba(38,74,120,.14); }
.sofia-send {
  width: 38px; height: 38px; flex-shrink: 0; border: none; border-radius: 50%; cursor: pointer; font-size: 15px;
  background: linear-gradient(150deg, var(--azure, #264a78), var(--navy, #0b2340)); color: #fff;
  transition: filter .14s var(--ease), transform .1s var(--ease);
}
.sofia-send:hover { filter: brightness(1.08); }
.sofia-send:active { transform: scale(.94); }
.sofia-foot { text-align: center; font-size: 11px; color: var(--fg-subtle); padding: 6px 10px 10px; background: var(--bg); }
.sofia-foot a { color: var(--azure, #264a78); font-weight: 600; }

@media (max-width: 768px) { #sofia-widget { right: 14px; bottom: 14px; } .sofia-chat { width: calc(100vw - 28px); height: 70vh; } }
@media (prefers-reduced-motion: reduce) { .sofia-fab, .sofia-fab-dot, .sofia-dots span { animation: none; } }
