/* ============================================================
   zaso.studio CRM — Design System
   Tokens + light/dark + components. No build, no framework.
   ============================================================ */

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--primary-soft); }

/* ---------- Tokens: light ---------- */
:root {
  /* Fonts (brand: Schibsted display / Fraunces editorial+wordmark / Hanken UI) */
  --font-ui: 'Hanken Grotesk', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-display: 'Schibsted Grotesk', 'Arial Narrow', system-ui, sans-serif;
  --font-serif: 'Fraunces', Georgia, 'Times New Roman', serif;

  /* Brand palette — charcoal / cream / gold + peach·amber·sage·sky */
  --bg: #F4ECDE;            /* warm sand canvas */
  --surface: #FFFCF6;       /* cream-white card */
  --surface-2: #FBF4E9;
  --surface-3: #F2E9D9;     /* hover / soft accent */
  --surface-inset: #F6EEE0;
  --border: #E9DEC9;
  --border-strong: #DBCBAD;
  --text: #2C2C2C;          /* charcoal */
  --text-2: #615C56;        /* stone-600 */
  --text-3: #948D82;
  --on-primary: #2C2C2C;    /* text on gold = charcoal (brand rule) */

  --primary: #D89A2F;       /* gold — fills/graphics only on light */
  --primary-press: #C2871F;
  --primary-soft: rgba(216, 154, 47, 0.16);
  --primary-softer: rgba(216, 154, 47, 0.08);
  --primary-ink: #2C2C2C;   /* accent TEXT/ICON on light = charcoal (gold fails contrast) */

  --peach: #EEDBD3; --amber: #EEE4D3; --sage: #DFEAD2; --sky: #D2E1EA;

  /* Functional status — earthy, AA on cream */
  --success: #4E7A39; --success-soft: rgba(78, 122, 57, 0.16);
  --danger: #B23A26;  --danger-soft: rgba(178, 58, 38, 0.13);
  --warning: #BD7A12; --warning-soft: rgba(189, 122, 18, 0.15);
  --info: #3C6E8E;    --info-soft: rgba(60, 110, 142, 0.14);
  --hot: #C0431A;     --hot-soft: rgba(192, 67, 26, 0.13);

  --sidebar-bg: #FFFCF6;
  --sidebar-border: var(--border);

  --shadow-xs: 0 1px 2px rgba(20, 26, 35, 0.05);
  --shadow-sm: 0 1px 3px rgba(20, 26, 35, 0.08), 0 1px 2px rgba(20, 26, 35, 0.04);
  --shadow-md: 0 4px 12px rgba(20, 26, 35, 0.10), 0 2px 4px rgba(20, 26, 35, 0.05);
  --shadow-lg: 0 12px 32px rgba(20, 26, 35, 0.14), 0 4px 8px rgba(20, 26, 35, 0.06);
  --shadow-xl: 0 24px 60px rgba(20, 26, 35, 0.20);

  --r-xs: 5px; --r-sm: 7px; --r: 10px; --r-md: 12px; --r-lg: 16px; --r-xl: 22px; --r-pill: 999px;

  --dur-fast: 120ms; --dur: 200ms; --dur-slow: 320ms;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --ease-emph: cubic-bezier(0.2, 0, 0, 1.2);

  --sidebar-w: 250px;
  --sidebar-w-collapsed: 76px;
  --topbar-h: 60px;
  --font-num: var(--font-display);
}

/* ---------- Tokens: dark ---------- */
[data-theme="dark"] {
  --bg: #232220;            /* warm near-black */
  --surface: #2C2C2C;       /* charcoal */
  --surface-2: #34332F;
  --surface-3: #3D3B36;
  --surface-inset: #1F1E1C;
  --border: #403E39;
  --border-strong: #524E47;
  --text: #FFFAF3;          /* cream */
  --text-2: #ABA6A0;        /* stone-300 */
  --text-3: #807A72;
  --on-primary: #2C2C2C;

  --primary: #D89A2F;       /* gold — readable as text on charcoal */
  --primary-press: #E3A94A;
  --primary-soft: rgba(216, 154, 47, 0.20);
  --primary-softer: rgba(216, 154, 47, 0.10);
  --primary-ink: #E0A93F;   /* gold reads fine as text on dark */

  --peach: #4A3F3A; --amber: #46412F; --sage: #3A4534; --sky: #324049;

  --success: #7FB45E; --success-soft: rgba(127, 180, 94, 0.18);
  --danger: #E07A5F;  --danger-soft: rgba(224, 122, 95, 0.18);
  --warning: #E0A33C; --warning-soft: rgba(224, 163, 60, 0.18);
  --info: #6FA0C0;    --info-soft: rgba(111, 160, 192, 0.18);
  --hot: #E08050;     --hot-soft: rgba(224, 128, 80, 0.18);

  --sidebar-bg: #1F1E1C;
  --sidebar-border: #353330;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.6);
  --shadow-xl: 0 28px 70px rgba(0, 0, 0, 0.7);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ============================================================
   Boot / loading
   ============================================================ */
.app-loading { display: grid; place-items: center; height: 100vh; }
.boot { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.boot__logo {
  width: 56px; height: 56px; border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--primary), #9b7bff);
  color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 28px;
  box-shadow: var(--shadow-md);
}
.boot__spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--primary-ink);
  animation: spin 0.7s linear infinite;
}
.boot__text { color: var(--text-2); font-size: 13px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   App shell
   ============================================================ */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100vh; overflow: hidden; }
.app.is-collapsed { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--sidebar-bg); border-right: 1px solid var(--sidebar-border);
  display: flex; flex-direction: column; height: 100vh; overflow: hidden;
  transition: width var(--dur) var(--ease);
}
.sidebar__brand {
  display: flex; align-items: center; gap: 11px; padding: 16px 18px; height: var(--topbar-h);
  border-bottom: 1px solid var(--sidebar-border); flex-shrink: 0;
}
.sidebar__logo {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), #9b7bff);
  color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 19px;
  box-shadow: var(--shadow-sm);
}
.sidebar__name { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; white-space: nowrap; }
.sidebar__name span { color: var(--text-3); font-weight: 600; }
.sidebar__nav { flex: 1; overflow-y: auto; padding: 10px 12px; }
.sidebar__nav::-webkit-scrollbar { width: 8px; }
.sidebar__section-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--text-3); padding: 14px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 9px 11px; border-radius: var(--r); color: var(--text-2);
  font-weight: 500; font-size: 13.5px; position: relative;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.is-active { background: var(--primary-soft); color: var(--primary-ink); font-weight: 600; }
.nav-item.is-active .nav-item__icon { color: var(--primary-ink); }
.nav-item__icon { width: 19px; height: 19px; flex-shrink: 0; color: var(--text-3); }
.nav-item:hover .nav-item__icon { color: var(--text); }
.nav-item__label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.nav-item__badge {
  font-size: 10.5px; font-weight: 700; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: var(--r-pill); display: grid; place-items: center;
  background: var(--primary); color: var(--on-primary);
}
.nav-item__badge.is-muted { background: var(--surface-3); color: var(--text-2); }
.nav-item__badge.is-danger { background: var(--danger); }
.sidebar__foot { padding: 12px; border-top: 1px solid var(--sidebar-border); flex-shrink: 0; }

/* Estado colapsado: solo en escritorio. En móvil el sidebar es drawer (ancho completo),
   así que el colapsado NO debe ocultar etiquetas ni la marca. */
@media (min-width: 921px) {
  .app.is-collapsed .sidebar__name,
  .app.is-collapsed .sidebar__section-label,
  .app.is-collapsed .nav-item__label,
  .app.is-collapsed .nav-item__badge,
  .app.is-collapsed .userchip__meta,
  .app.is-collapsed .brand-lockup { display: none; }
  .app.is-collapsed .nav-item { justify-content: center; }
  .app.is-collapsed .sidebar__brand { justify-content: center; padding: 16px 0; }
}

/* user chip in sidebar foot */
.userchip {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 8px; border-radius: var(--r);
  transition: background var(--dur-fast);
}
.userchip:hover { background: var(--surface-3); }
.userchip__meta { text-align: left; overflow: hidden; flex: 1; min-width: 0; }
.userchip__name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.userchip__role { font-size: 11px; color: var(--text-3); }

/* ---------- Main ---------- */
.main { display: flex; flex-direction: column; height: 100vh; overflow: hidden; min-width: 0; }
.topbar {
  height: var(--topbar-h); flex-shrink: 0; display: flex; align-items: center; gap: 12px;
  padding: 0 20px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.topbar__left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar__title { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; }
.topbar__crumb { color: var(--text-3); font-size: 13px; }
.topbar__search {
  flex: 1; max-width: 420px; display: flex; align-items: center; gap: 9px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r);
  padding: 8px 12px; color: var(--text-3); cursor: text; transition: border-color var(--dur-fast);
}
.topbar__search:hover { border-color: var(--border-strong); }
.topbar__search kbd {
  margin-left: auto; font-size: 10.5px; font-weight: 600; color: var(--text-3);
  background: var(--surface); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px;
}
.topbar__spacer { flex: 1; }
.topbar__actions { display: flex; align-items: center; gap: 6px; }
.iconbtn {
  width: 38px; height: 38px; border-radius: var(--r); display: grid; place-items: center;
  color: var(--text-2); position: relative; transition: background var(--dur-fast), color var(--dur-fast);
}
.iconbtn:hover { background: var(--surface-3); color: var(--text); }
.iconbtn svg { width: 19px; height: 19px; }
.iconbtn__dot {
  position: absolute; top: 7px; right: 8px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: var(--r-pill); background: var(--danger); color: #fff; font-size: 9.5px; font-weight: 700;
  display: grid; place-items: center; border: 2px solid var(--surface);
}
.content { flex: 1; overflow-y: auto; overflow-x: hidden; }
.content__inner { padding: 24px 28px 64px; max-width: 1320px; margin: 0 auto; }
.content__inner.is-wide { max-width: none; }

/* page header */
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head__text { min-width: 0; }
.page-head h1 { font-size: 22px; font-weight: 750; letter-spacing: -0.02em; }
.page-head p { color: var(--text-2); font-size: 13.5px; margin-top: 3px; }
.page-head__actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 15px; border-radius: var(--r); font-weight: 600; font-size: 13.5px;
  border: 1px solid transparent; white-space: nowrap;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast), transform var(--dur-fast), box-shadow var(--dur-fast);
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 17px; height: 17px; }
.btn--primary { background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-xs); }
.btn--primary:hover { background: var(--primary-press); box-shadow: var(--shadow-sm); }
.btn--ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn--ghost:hover { background: var(--surface-3); border-color: var(--border-strong); }
.btn--subtle { background: var(--surface-3); color: var(--text); }
.btn--subtle:hover { background: var(--border); }
.btn--soft { background: var(--primary-soft); color: var(--primary-ink); }
.btn--soft:hover { background: var(--primary-softer); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { filter: brightness(1.05); }
.btn--danger-soft { background: var(--danger-soft); color: var(--danger); }
.btn--success { background: var(--success); color: #fff; }
.btn--sm { height: 32px; padding: 0 11px; font-size: 12.5px; border-radius: var(--r-sm); }
.btn--sm svg { width: 15px; height: 15px; }
.btn--lg { height: 44px; padding: 0 20px; font-size: 15px; }
.btn--icon { width: 38px; padding: 0; }
.btn--icon.btn--sm { width: 32px; }
.btn--block { width: 100%; }
.btn:disabled { opacity: 0.5; pointer-events: none; }

/* ============================================================
   Cards & surfaces
   ============================================================ */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  box-shadow: var(--shadow-xs);
}
.card--pad { padding: 18px; }
.card__head {
  display: flex; align-items: center; gap: 10px; padding: 15px 18px; border-bottom: 1px solid var(--border);
}
.card__head h3 { font-size: 14.5px; font-weight: 700; letter-spacing: -0.01em; }
.card__head .sub { color: var(--text-3); font-size: 12px; font-weight: 500; }
.card__head .spacer { flex: 1; }
.card__body { padding: 18px; }

.section-title { font-size: 13px; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 12px; }

/* ============================================================
   KPI cards
   ============================================================ */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 16px 18px; box-shadow: var(--shadow-xs); position: relative; overflow: hidden;
  transition: box-shadow var(--dur), transform var(--dur), border-color var(--dur);
}
.kpi:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.kpi__top { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; }
.kpi__icon {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0;
  background: var(--primary-soft); color: var(--primary-ink);
}
.kpi__icon svg { width: 18px; height: 18px; }
.kpi__icon.is-success { background: var(--success-soft); color: var(--success); }
.kpi__icon.is-danger { background: var(--danger-soft); color: var(--danger); }
.kpi__icon.is-warning { background: var(--warning-soft); color: var(--warning); }
.kpi__icon.is-info { background: var(--info-soft); color: var(--info); }
.kpi__label { font-size: 12.5px; color: var(--text-2); font-weight: 600; }
.kpi__value { font-size: 27px; font-weight: 780; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi__foot { display: flex; align-items: center; gap: 6px; margin-top: 9px; font-size: 12px; color: var(--text-3); }
.kpi__delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; }
.kpi__delta.is-up { color: var(--success); }
.kpi__delta.is-down { color: var(--danger); }
.kpi__delta svg { width: 14px; height: 14px; }
.kpi__spark { position: absolute; right: 0; bottom: 0; width: 96px; height: 40px; opacity: 0.5; }

/* ============================================================
   Badges, chips, tags, pills
   ============================================================ */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px;
  border-radius: var(--r-pill); font-size: 11.5px; font-weight: 600; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2);
}
.badge svg { width: 13px; height: 13px; }
.badge--success { background: var(--success-soft); color: var(--success); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--warning { background: var(--warning-soft); color: var(--warning); }
.badge--info { background: var(--info-soft); color: var(--info); }
.badge--primary { background: var(--primary-soft); color: var(--primary-ink); }
.badge--hot { background: var(--hot-soft); color: var(--hot); }
.badge--dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--outline { background: transparent; border: 1px solid var(--border-strong); color: var(--text-2); }

.tag {
  display: inline-flex; align-items: center; gap: 5px; height: 23px; padding: 0 9px;
  border-radius: var(--r-sm); font-size: 11.5px; font-weight: 600; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2); border: 1px solid transparent;
}
.tag__x { color: var(--text-3); width: 13px; height: 13px; cursor: pointer; }
.tag__x:hover { color: var(--danger); }

/* lead score badge */
.score {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px;
  border-radius: var(--r-pill); font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.score--hot { background: var(--hot-soft); color: var(--hot); }
.score--warm { background: var(--warning-soft); color: var(--warning); }
.score--cold { background: var(--info-soft); color: var(--info); }

/* health dot */
.health { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; }
.health__dot { width: 9px; height: 9px; border-radius: 50%; }
.health--good .health__dot { background: var(--success); }
.health--warn .health__dot { background: var(--warning); }
.health--bad .health__dot { background: var(--danger); }
.health--good { color: var(--success); }
.health--warn { color: var(--warning); }
.health--bad { color: var(--danger); }

/* priority flag */
.flag { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 700; }
.flag--urgent { color: var(--hot); }
.flag--attention { color: var(--warning); }
.flag svg { width: 14px; height: 14px; }

/* ============================================================
   Avatars
   ============================================================ */
.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  font-weight: 700; font-size: 13px; color: #fff; letter-spacing: 0.02em; position: relative;
}
.avatar--sm { width: 28px; height: 28px; font-size: 11px; }
.avatar--lg { width: 56px; height: 56px; font-size: 20px; }
.avatar--xl { width: 72px; height: 72px; font-size: 26px; }
.avatar__status {
  position: absolute; bottom: -1px; right: -1px; width: 11px; height: 11px; border-radius: 50%;
  border: 2px solid var(--surface); background: var(--success);
}
.avatar-stack { display: flex; }
.avatar-stack .avatar { border: 2px solid var(--surface); margin-left: -9px; }
.avatar-stack .avatar:first-child { margin-left: 0; }

/* ============================================================
   Inputs / forms
   ============================================================ */
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field__hint { font-size: 11.5px; color: var(--text-3); }
.input, .select, .textarea {
  width: 100%; height: 38px; padding: 0 12px; border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.textarea { height: auto; min-height: 92px; padding: 10px 12px; resize: vertical; line-height: 1.55; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--primary-ink); box-shadow: 0 0 0 3px var(--primary-soft);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2398a0ad' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; padding-right: 32px; }
.input--sm { height: 32px; font-size: 13px; }
.input-inline {
  border: 1px solid transparent; background: transparent; border-radius: var(--r-sm); padding: 4px 8px; width: 100%;
}
.input-inline:hover { background: var(--surface-3); }
.input-inline:focus { background: var(--surface); border-color: var(--primary-ink); box-shadow: 0 0 0 3px var(--primary-soft); outline: none; }

/* toggle switch */
.switch { position: relative; display: inline-flex; align-items: center; gap: 9px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch__track {
  width: 38px; height: 22px; border-radius: var(--r-pill); background: var(--border-strong);
  transition: background var(--dur) var(--ease); flex-shrink: 0; position: relative;
}
.switch__track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow-sm); transition: transform var(--dur) var(--ease);
}
.switch input:checked + .switch__track { background: var(--primary); }
.switch input:checked + .switch__track::after { transform: translateX(16px); }
.switch__label { font-size: 13px; font-weight: 500; }

/* segmented control */
.segment { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); padding: 3px; gap: 2px; }
.segment button {
  height: 30px; padding: 0 13px; border-radius: var(--r-sm); font-size: 12.5px; font-weight: 600; color: var(--text-2);
  transition: background var(--dur-fast), color var(--dur-fast);
}
.segment button:hover { color: var(--text); }
.segment button.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); }

/* checkbox */
.checkbox { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13px; }
.checkbox input { width: 18px; height: 18px; accent-color: var(--primary-ink); cursor: pointer; }

/* ============================================================
   Tables
   ============================================================ */
.table-wrap { overflow-x: auto; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl thead th {
  text-align: left; font-weight: 600; font-size: 11.5px; color: var(--text-3); text-transform: uppercase;
  letter-spacing: 0.04em; padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap;
  background: var(--surface-2); position: sticky; top: 0; z-index: 1;
}
.tbl tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tbody tr { transition: background var(--dur-fast); cursor: pointer; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl .cell-main { font-weight: 600; color: var(--text); }
.tbl .cell-sub { color: var(--text-3); font-size: 12px; }
.tbl .cell-num { font-variant-numeric: tabular-nums; text-align: right; }
.tbl--compact tbody td { padding: 7px 14px; }
.cell-person { display: flex; align-items: center; gap: 10px; }

/* ============================================================
   Tabs
   ============================================================ */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); }
.tab {
  padding: 10px 14px; font-size: 13.5px; font-weight: 600; color: var(--text-2); position: relative;
  transition: color var(--dur-fast); white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--primary-ink); }
.tab.is-active::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; background: var(--primary); border-radius: 2px; }
.tab__count { font-size: 11px; color: var(--text-3); margin-left: 5px; }

/* ============================================================
   Timeline / activity feed
   ============================================================ */
.timeline { position: relative; padding-left: 8px; }
.tl-day { font-size: 11.5px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; margin: 16px 0 10px; padding-left: 30px; }
.tl-item { position: relative; padding: 0 0 16px 36px; }
.tl-item::before { content: ""; position: absolute; left: 13px; top: 26px; bottom: -4px; width: 2px; background: var(--border); }
.tl-item:last-child::before { display: none; }
.tl-item__icon {
  position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); border: 2px solid var(--surface); z-index: 1;
}
.tl-item__icon svg { width: 14px; height: 14px; }
.tl-item__icon.is-email { background: var(--info-soft); color: var(--info); }
.tl-item__icon.is-call { background: var(--success-soft); color: var(--success); }
.tl-item__icon.is-whatsapp { background: var(--success-soft); color: #25d366; }
.tl-item__icon.is-meeting { background: var(--primary-soft); color: var(--primary-ink); }
.tl-item__icon.is-stage { background: var(--warning-soft); color: var(--warning); }
.tl-item__icon.is-note { background: var(--surface-3); color: var(--text-2); }
.tl-item__icon.is-file { background: var(--info-soft); color: var(--info); }
.tl-item__icon.is-system { background: var(--surface-3); color: var(--text-3); }
.tl-item__body { padding-top: 3px; }
.tl-item__title { font-size: 13.5px; }
.tl-item__title b { font-weight: 700; }
.tl-item__meta { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.tl-item__note { margin-top: 7px; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); font-size: 13px; color: var(--text); }

/* ============================================================
   Kanban
   ============================================================ */
.kanban { display: flex; gap: 14px; align-items: flex-start; overflow-x: auto; padding-bottom: 12px; min-height: 60vh; }
.kanban-col { width: 290px; flex-shrink: 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); display: flex; flex-direction: column; max-height: calc(100vh - 220px); }
.kanban-col.is-dragover { border-color: var(--primary-ink); box-shadow: 0 0 0 3px var(--primary-soft); }
.kanban-col__head { padding: 12px 14px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--border); position: sticky; top: 0; }
.kanban-col__dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.kanban-col__name { font-weight: 700; font-size: 13px; }
.kanban-col__count { font-size: 11px; color: var(--text-3); background: var(--surface-3); border-radius: var(--r-pill); padding: 1px 7px; font-weight: 600; }
.kanban-col__sum { margin-left: auto; font-size: 12px; font-weight: 700; color: var(--text-2); font-variant-numeric: tabular-nums; }
.kanban-col__body { padding: 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 9px; flex: 1; }
.deal-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 12px;
  box-shadow: var(--shadow-xs); cursor: grab; position: relative; transition: box-shadow var(--dur-fast), transform var(--dur-fast), border-color var(--dur-fast);
  border-left: 3px solid transparent;
}
.deal-card:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.deal-card.is-dragging { opacity: 0.5; box-shadow: var(--shadow-lg); transform: rotate(1.5deg); cursor: grabbing; }
.deal-card.is-stale { border-left-color: var(--warning); }
.deal-card.is-rotten { border-left-color: var(--danger); }
.deal-card__top { display: flex; align-items: flex-start; gap: 8px; }
.deal-card__title { font-weight: 700; font-size: 13.5px; line-height: 1.3; flex: 1; }
.deal-card__company { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.deal-card__value { font-weight: 750; font-size: 14px; font-variant-numeric: tabular-nums; margin-top: 9px; }
.deal-card__foot { display: flex; align-items: center; gap: 7px; margin-top: 10px; flex-wrap: wrap; }
.deal-card__age { font-size: 11px; color: var(--text-3); display: inline-flex; align-items: center; gap: 3px; margin-left: auto; }
.deal-card__age.is-stale { color: var(--warning); font-weight: 600; }
.deal-card__age.is-rotten { color: var(--danger); font-weight: 700; }

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(10, 12, 18, 0.5); backdrop-filter: blur(3px); z-index: 200;
  display: grid; place-items: center; padding: 24px; opacity: 0; animation: fadeIn var(--dur) var(--ease) forwards;
}
[data-theme="dark"] .modal-overlay { background: rgba(0, 0, 0, 0.6); }
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-xl);
  width: 100%; max-width: 560px; max-height: 88vh; display: flex; flex-direction: column; overflow: hidden;
  transform: translateY(8px) scale(0.98); animation: modalIn var(--dur-slow) var(--ease) forwards;
}
.modal--lg { max-width: 760px; }
.modal--xl { max-width: 1040px; }
.modal--sm { max-width: 420px; }
.modal__head { display: flex; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.modal__head h2 { font-size: 16.5px; font-weight: 700; letter-spacing: -0.01em; }
.modal__head p { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.modal__close { margin-left: auto; }
.modal__body { padding: 20px; overflow-y: auto; flex: 1; min-height: 0; }
.modal__foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 9px; justify-content: flex-end; flex-shrink: 0; background: var(--surface-2); }
@keyframes fadeIn { to { opacity: 1; } }
@keyframes modalIn { to { transform: translateY(0) scale(1); } }

/* form grid in modals */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .col-span-2 { grid-column: span 2; }

/* ============================================================
   Toasts
   ============================================================ */
#toast-root { position: fixed; top: 16px; right: 16px; z-index: 400; display: flex; flex-direction: column; gap: 10px; width: 360px; max-width: calc(100vw - 32px); }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-lg);
  padding: 13px 14px; display: flex; gap: 11px; align-items: flex-start;
  transform: translateX(120%); animation: toastIn var(--dur-slow) var(--ease) forwards;
  border-left: 3px solid var(--primary);
}
.toast.is-success { border-left-color: var(--success); }
.toast.is-error { border-left-color: var(--danger); }
.toast.is-warning { border-left-color: var(--warning); }
.toast.is-info { border-left-color: var(--info); }
.toast.is-leaving { animation: toastOut var(--dur) var(--ease) forwards; }
.toast__icon { width: 20px; height: 20px; flex-shrink: 0; color: var(--primary-ink); margin-top: 1px; }
.toast.is-success .toast__icon { color: var(--success); }
.toast.is-error .toast__icon { color: var(--danger); }
.toast.is-warning .toast__icon { color: var(--warning); }
.toast__body { flex: 1; min-width: 0; }
.toast__title { font-weight: 650; font-size: 13.5px; }
.toast__msg { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }
.toast__actions { display: flex; gap: 6px; margin-top: 9px; }
.toast__action { font-size: 12.5px; font-weight: 700; color: var(--primary-ink); padding: 3px 0; }
.toast__action:hover { text-decoration: underline; }
.toast__close { color: var(--text-3); flex-shrink: 0; width: 18px; height: 18px; }
.toast__close:hover { color: var(--text); }
@keyframes toastIn { to { transform: translateX(0); } }
@keyframes toastOut { to { transform: translateX(120%); opacity: 0; } }

/* ============================================================
   Command palette
   ============================================================ */
.cmdk-overlay { position: fixed; inset: 0; background: rgba(10, 12, 18, 0.4); backdrop-filter: blur(3px); z-index: 350; display: grid; place-items: start center; padding-top: 12vh; opacity: 0; animation: fadeIn var(--dur) var(--ease) forwards; }
.cmdk { width: 100%; max-width: 600px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-xl); overflow: hidden; transform: translateY(-8px); animation: modalIn var(--dur) var(--ease) forwards; }
.cmdk__input-row { display: flex; align-items: center; gap: 11px; padding: 15px 18px; border-bottom: 1px solid var(--border); }
.cmdk__input-row svg { width: 19px; height: 19px; color: var(--text-3); }
.cmdk__input { flex: 1; border: none; outline: none; background: none; font-size: 15.5px; }
.cmdk__list { max-height: 52vh; overflow-y: auto; padding: 8px; }
.cmdk__group { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); padding: 10px 10px 5px; }
.cmdk__item { display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: var(--r); cursor: pointer; }
.cmdk__item.is-active { background: var(--primary-soft); }
.cmdk__item svg { width: 17px; height: 17px; color: var(--text-2); }
.cmdk__item.is-active svg { color: var(--primary-ink); }
.cmdk__item-label { font-size: 13.5px; font-weight: 500; flex: 1; }
.cmdk__item-hint { font-size: 11px; color: var(--text-3); }
.cmdk__empty { padding: 30px; text-align: center; color: var(--text-3); font-size: 13px; }

/* ============================================================
   Dropdown menu
   ============================================================ */
.menu {
  position: absolute; z-index: 300; min-width: 200px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--shadow-lg); padding: 6px; transform-origin: top right;
  animation: menuIn var(--dur-fast) var(--ease);
}
@keyframes menuIn { from { opacity: 0; transform: scale(0.96) translateY(-4px); } }
.menu__item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm); font-size: 13px; font-weight: 500; width: 100%; color: var(--text); transition: background var(--dur-fast); }
.menu__item:hover { background: var(--surface-3); }
.menu__item svg { width: 16px; height: 16px; color: var(--text-3); }
.menu__item.is-danger { color: var(--danger); }
.menu__item.is-danger svg { color: var(--danger); }
.menu__item.is-active { color: var(--primary-ink); }
.menu__sep { height: 1px; background: var(--border); margin: 5px 0; }
.menu__label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-3); padding: 8px 10px 4px; }

/* ============================================================
   Progress / rings / bars
   ============================================================ */
.bar { height: 8px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.bar__fill { height: 100%; border-radius: var(--r-pill); background: var(--primary); transition: width var(--dur-slow) var(--ease); }
.bar__fill.is-success { background: var(--success); }
.bar__fill.is-warning { background: var(--warning); }
.bar__fill.is-danger { background: var(--danger); }
.meter { display: flex; align-items: center; gap: 10px; }
.meter .bar { flex: 1; }
.meter__val { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 36px; text-align: right; }

/* ============================================================
   Empty states
   ============================================================ */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 54px 24px; }
.empty__icon { width: 56px; height: 56px; border-radius: var(--r-lg); background: var(--surface-3); color: var(--text-3); display: grid; place-items: center; margin-bottom: 16px; }
.empty__icon svg { width: 26px; height: 26px; }
.empty h3 { font-size: 16px; font-weight: 700; }
.empty p { color: var(--text-2); font-size: 13.5px; margin: 6px 0 18px; max-width: 360px; }

/* ============================================================
   Utilities
   ============================================================ */
.row { display: flex; align-items: center; gap: 10px; }
.row--wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; }
.spacer { flex: 1; }
.stack-8 > * + * { margin-top: 8px; }
.stack-12 > * + * { margin-top: 12px; }
.stack-16 > * + * { margin-top: 16px; }
.stack-20 > * + * { margin-top: 20px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.muted { color: var(--text-2); }
.subtle { color: var(--text-3); }
.t-xs { font-size: 11.5px; } .t-sm { font-size: 12.5px; } .t-lg { font-size: 16px; }
.fw-6 { font-weight: 600; } .fw-7 { font-weight: 700; }
.num { font-variant-numeric: tabular-nums; }
.text-success { color: var(--success); } .text-danger { color: var(--danger); } .text-warning { color: var(--warning); } .text-primary { color: var(--primary-ink); }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; } .mb-20 { margin-bottom: 20px; }
.hide { display: none !important; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.clickable { cursor: pointer; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scroll-x { overflow-x: auto; }
.dot-sep::before { content: "·"; margin: 0 6px; color: var(--text-3); }

/* scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }
::-webkit-scrollbar-track { background: transparent; }

/* confetti canvas */
#confetti-canvas { position: fixed; inset: 0; pointer-events: none; z-index: 500; display: none; }
#confetti-canvas.is-active { display: block; }

/* mobile sidebar toggle */
.sidebar-scrim { display: none; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 920px) {
  .app, .app.is-collapsed { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar-w); z-index: 250;
    transform: translateX(-100%); transition: transform var(--dur) var(--ease); box-shadow: var(--shadow-xl);
  }
  .app.is-mobile-open .sidebar { transform: translateX(0); }
  .app.is-mobile-open .sidebar-scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 240; }
  .topbar__search { display: none; }
  .sidebar__collapse { display: none; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .content__inner { padding: 18px 16px 56px; }
}
@media (max-width: 560px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .col-span-2 { grid-column: span 1; }
}

/* ============================================================
   Brand layer — ZASO (typography, logo lockup, accents)
   ============================================================ */
.page-head h1, .topbar__title, .modal__head h2, .kpi__value { font-family: var(--font-display); }
.page-head h1 { font-weight: 600; letter-spacing: -0.025em; }
.topbar__title { font-weight: 600; letter-spacing: -0.015em; }
.modal__head h2 { font-weight: 600; letter-spacing: -0.012em; }
.kpi__value { font-weight: 600; letter-spacing: -0.02em; }
.empty h3 { font-family: var(--font-serif); font-style: italic; font-weight: 500; }

/* splash */
.boot__mark { color: var(--primary); display: grid; place-items: center; }
.boot__mark svg { width: 60px; height: 60px; }
.boot__word { font-family: var(--font-serif); font-style: italic; font-weight: 500; font-size: 22px; color: var(--text); letter-spacing: -0.01em; }

/* sidebar brand — bisagra lockup: zaso ◆ studio */
.brand-lockup { display: flex; align-items: center; gap: 3px; flex: 1; min-width: 0; }
.brand-word { font-family: var(--font-serif); font-style: italic; font-weight: 500; font-size: 19px; color: var(--text); letter-spacing: -0.01em; white-space: nowrap; }
.brand-mark { color: var(--primary); display: flex; flex-shrink: 0; }
.brand-mark svg { width: 23px; height: 23px; }
/* toggle colapsar/expandir — vive DENTRO del sidebar (reemplaza el botón duplicado de la topbar) */
.sidebar__collapse { width: 32px; height: 32px; flex-shrink: 0; color: var(--text-3); }
.sidebar__collapse svg { transition: transform var(--dur-fast); }
.app.is-collapsed .sidebar__collapse svg { transform: rotate(180deg); }

/* gold accent bar on active nav item */
.nav-item.is-active::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--primary); }

/* the agent's answer reads editorial (Fraunces) */
.agent-answer { font-family: var(--font-serif); }

/* ============================================================
   Tablero personalizable del Dashboard (reordenar + redimensionar)
   ============================================================ */
.dash-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; align-items: start; }
.dash-widget { position: relative; min-width: 0; }
.dash-widget > .card { height: 100%; }

/* señalador de 6 puntitos (grip) reutilizable */
.grip {
  display: inline-block; width: 10px; height: 16px;
  background-image: radial-gradient(currentColor 1.1px, transparent 1.4px);
  background-size: 5px 5px; background-position: center; color: var(--text-3);
}
.dash-grip {
  position: absolute; top: 50%; left: -8px; transform: translateY(-50%);
  display: flex; align-items: center; justify-content: center;
  width: 18px; height: 36px; border-radius: 7px;
  background: var(--surface-2); border: 1px solid var(--border);
  box-shadow: var(--shadow-xs); cursor: grab; opacity: 0;
  transition: opacity var(--dur-fast); z-index: 5;
}
.dash-widget:hover .dash-grip { opacity: 1; }
.dash-grip:active { cursor: grabbing; }
.dash-resize {
  position: absolute; right: 3px; bottom: 3px; width: 20px; height: 20px;
  cursor: nwse-resize; opacity: 0; transition: opacity var(--dur-fast); z-index: 5; touch-action: none;
  background:
    linear-gradient(135deg, transparent 0 40%, var(--text-2) 40% 50%, transparent 50% 100%),
    linear-gradient(135deg, transparent 0 64%, var(--text-2) 64% 74%, transparent 74% 100%);
}
.dash-widget:hover .dash-resize { opacity: .5; }
.dash-resize:hover { opacity: 1; }
.dash-widget.is-dragging { opacity: .45; outline: 2px dashed var(--primary); outline-offset: 3px; border-radius: var(--r-md); }
.dash-widget.is-resizing { outline: 2px solid var(--primary); outline-offset: 3px; border-radius: var(--r-md); }

/* grip indicator on draggable pipeline deal cards */
.deal-card__grip {
  position: absolute; top: 8px; right: 8px; opacity: 0;
  transition: opacity var(--dur-fast); pointer-events: none;
}
.deal-card:hover .deal-card__grip { opacity: .5; }

@media (max-width: 820px) {
  .dash-grid { grid-template-columns: 1fr; }
  .dash-widget { grid-column: span 1 !important; }
  .dash-resize { display: none; }
  .dash-grip { left: 2px; }
}

/* ============================================================
   Estudio de Contenido (canvas tipo Higgsfield)
   ============================================================ */
.studio-credits { display:inline-flex; align-items:center; gap:6px; padding:6px 12px; border-radius:var(--r-pill); background:var(--surface-2); border:1px solid var(--border); font-size:12.5px; color:var(--text-2); }
.studio-credits b { color:var(--text); }
.studio-powered { font-size:11.5px; color:var(--text-3); margin-left:10px; align-self:center; }
.studio-powered b { color:var(--primary-ink); }

.studio-bar { display:flex; gap:10px; overflow-x:auto; padding:4px 2px 14px; }
.studio-preset { display:flex; align-items:center; gap:9px; padding:8px 12px 8px 9px; border-radius:var(--r); border:1px solid var(--border); background:var(--surface); cursor:pointer; white-space:nowrap; transition:border-color var(--dur-fast), background var(--dur-fast); }
.studio-preset:hover { border-color:var(--border-strong); }
.studio-preset.is-active { border-color:var(--primary); background:var(--primary-soft); }
.studio-preset__frame { width:26px; max-height:34px; border-radius:4px; background:var(--surface-3); border:1px solid var(--border-strong); flex-shrink:0; }
.studio-preset__t { display:flex; flex-direction:column; line-height:1.25; text-align:left; }

.studio-main { display:grid; grid-template-columns:1.55fr 1fr; gap:18px; align-items:start; }
@media (max-width:980px) { .studio-main { grid-template-columns:1fr; } }

.studio-canvas { background:var(--surface); border:1px solid var(--border); border-radius:var(--r-md); padding:18px; background-image:radial-gradient(var(--border) 1px, transparent 1px); background-size:22px 22px; }
.studio-pipe { display:flex; align-items:center; gap:4px; flex-wrap:wrap; margin-bottom:16px; }
.studio-conn { color:var(--text-3); display:flex; }
.studio-node { display:flex; align-items:center; gap:9px; padding:9px 11px; border-radius:10px; border:1px solid var(--border); background:var(--surface-2); cursor:pointer; min-width:0; transition:border-color var(--dur-fast), box-shadow var(--dur-fast); }
.studio-node:hover { border-color:var(--border-strong); }
.studio-node.is-selected { border-color:var(--primary); box-shadow:0 0 0 3px var(--primary-soft); }
.studio-node--out { background:var(--surface); }
.studio-node__icon { width:28px; height:28px; border-radius:7px; background:var(--primary-soft); color:var(--primary-ink); display:grid; place-items:center; flex-shrink:0; }
.studio-node__t { min-width:0; }
.studio-node__title { font-weight:650; font-size:12.5px; }
.studio-node__sub { font-size:11px; color:var(--text-3); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:120px; }

.studio-stage { display:flex; justify-content:center; padding:8px; }
.studio-frame { position:relative; height:300px; width:auto; max-width:100%; border-radius:12px; overflow:hidden; border:1px solid var(--border); background:var(--surface-2); display:flex; align-items:center; justify-content:center; box-shadow:var(--shadow-sm); }
.studio-frame__empty, .studio-frame__loading { display:flex; flex-direction:column; align-items:center; color:var(--text-3); text-align:center; padding:16px; }
.studio-frame__loading { color:var(--text-2); position:relative; z-index:2; }
.studio-frame__badge { position:absolute; top:9px; left:9px; background:rgba(0,0,0,.5); color:#fff; font-size:10.5px; font-weight:600; padding:3px 8px; border-radius:var(--r-pill); z-index:2; }
.studio-frame__cap { position:absolute; left:0; right:0; bottom:0; padding:20px 12px 10px; color:#fff; font-size:11.5px; line-height:1.35; background:linear-gradient(transparent, rgba(0,0,0,.62)); z-index:2; }
.studio-frame__play { position:absolute; top:50%; left:50%; transform:translate(-50%,-50%); width:46px; height:46px; border-radius:50%; background:rgba(255,255,255,.92); color:#111; display:grid; place-items:center; z-index:2; }
.studio-progress { width:140px; height:5px; border-radius:3px; background:var(--surface-3); overflow:hidden; margin-top:12px; }
.studio-progress span { display:block; height:100%; width:30%; background:var(--primary); border-radius:3px; animation:stProg 2.2s ease-in-out forwards; }
@keyframes stProg { 0%{width:6%} 60%{width:78%} 100%{width:100%} }
.studio-shimmer { position:absolute; inset:0; z-index:1; background:linear-gradient(110deg, transparent 20%, var(--surface-3) 40%, transparent 60%); background-size:200% 100%; animation:stShimmer 1.3s linear infinite; }
@keyframes stShimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

.studio-config { background:var(--surface); border:1px solid var(--border); border-radius:var(--r-md); padding:16px; position:sticky; top:8px; }
.studio-config__head { display:flex; align-items:center; gap:9px; padding-bottom:12px; margin-bottom:14px; border-bottom:1px solid var(--border); font-size:14px; }
.studio-range { width:100%; accent-color:var(--primary); }
.studio-drop { display:flex; align-items:center; gap:11px; padding:14px; border:1.5px dashed var(--border-strong); border-radius:10px; cursor:pointer; color:var(--text-3); transition:border-color var(--dur-fast); }
.studio-drop:hover { border-color:var(--primary); }
.studio-drop__thumb { width:42px; height:42px; border-radius:8px; flex-shrink:0; }
.studio-models { display:flex; flex-direction:column; gap:7px; }
.studio-model { display:grid; grid-template-columns:auto 1fr auto; grid-template-rows:auto auto; gap:1px 9px; align-items:center; text-align:left; padding:9px 11px; border-radius:9px; border:1px solid var(--border); background:var(--surface); cursor:pointer; }
.studio-model:hover { border-color:var(--border-strong); }
.studio-model.is-active { border-color:var(--primary); background:var(--primary-soft); }
.studio-model__k { grid-row:span 2; align-self:center; }
.studio-model b { font-size:12.5px; }
.studio-model .subtle { grid-column:2; }
.studio-model__cost { grid-row:span 2; align-self:center; display:inline-flex; align-items:center; gap:3px; color:var(--text-2); font-weight:600; }
.studio-spec { background:var(--surface-2); border-radius:9px; padding:10px 12px; display:flex; flex-direction:column; gap:5px; }
.studio-gen { margin-top:16px; padding-top:14px; border-top:1px solid var(--border); }
.btn--block { width:100%; justify-content:center; }
.studio-gen__cost { display:inline-flex; align-items:center; gap:3px; margin-left:8px; opacity:.85; font-size:12px; }

.studio-templates { display:grid; grid-template-columns:repeat(4,1fr); gap:10px; }
@media (max-width:820px){ .studio-templates { grid-template-columns:repeat(2,1fr); } }
.studio-tpl { display:flex; align-items:center; gap:10px; padding:11px; border-radius:10px; border:1px solid var(--border); background:var(--surface); cursor:pointer; text-align:left; transition:border-color var(--dur-fast); }
.studio-tpl:hover { border-color:var(--primary); }

.studio-gallery { display:grid; grid-template-columns:repeat(auto-fill, minmax(150px,1fr)); gap:14px; }
.studio-gcard { border:1px solid var(--border); border-radius:12px; overflow:hidden; background:var(--surface); position:relative; }
.studio-gcard .studio-frame { border:none; border-radius:0; height:auto; width:100%; max-height:240px; box-shadow:none; }
.studio-gcard__meta { padding:8px 10px; }
.studio-gcard__act { position:absolute; top:7px; right:7px; display:flex; gap:4px; opacity:0; transition:opacity var(--dur-fast); }
.studio-gcard:hover .studio-gcard__act { opacity:1; }
.studio-gcard__act .iconbtn { background:rgba(0,0,0,.45); color:#fff; }

/* ============================================================
   Workflow Builder (automatizaciones)
   ============================================================ */
.wf-layout { display:grid; grid-template-columns:280px 1fr; gap:18px; align-items:start; }
@media (max-width:900px){ .wf-layout { grid-template-columns:1fr; } }
.wf-list { display:flex; flex-direction:column; gap:9px; }
.wf-card { text-align:left; padding:12px; border-radius:var(--r); border:1px solid var(--border); background:var(--surface); cursor:pointer; transition:border-color var(--dur-fast); }
.wf-card:hover { border-color:var(--border-strong); }
.wf-card.is-active { border-color:var(--primary); box-shadow:0 0 0 3px var(--primary-soft); }
.wf-dot { width:8px; height:8px; border-radius:50%; background:var(--text-3); flex-shrink:0; }
.wf-dot.is-on { background:var(--success); box-shadow:0 0 0 3px var(--success-soft); }
.wf-builder { background:var(--surface); border:1px solid var(--border); border-radius:var(--r-md); padding:18px; }
.wf-builder__head { display:flex; align-items:center; gap:10px; margin-bottom:18px; flex-wrap:wrap; }
.wf-name { font-size:16px; font-weight:700; border:1px solid transparent; background:transparent; border-radius:8px; padding:4px 8px; color:var(--text); min-width:140px; flex:0 1 auto; }
.wf-name:hover { border-color:var(--border); }
.wf-name:focus { border-color:var(--primary-ink); outline:none; background:var(--surface-2); }
.wf-toggle { display:inline-flex; align-items:center; gap:7px; cursor:pointer; position:relative; }
.wf-toggle input { position:absolute; opacity:0; }
.wf-toggle__t { width:34px; height:20px; border-radius:var(--r-pill); background:var(--surface-3); position:relative; transition:background var(--dur-fast); flex-shrink:0; }
.wf-toggle__t::after { content:""; position:absolute; top:2px; left:2px; width:16px; height:16px; border-radius:50%; background:#fff; transition:transform var(--dur-fast); box-shadow:var(--shadow-xs); }
.wf-toggle input:checked + .wf-toggle__t { background:var(--success); }
.wf-toggle input:checked + .wf-toggle__t::after { transform:translateX(14px); }
.wf-flow { display:flex; flex-direction:column; align-items:stretch; max-width:540px; }
.wf-node { display:flex; align-items:center; gap:11px; padding:12px 14px; border-radius:12px; border:1px solid var(--border); background:var(--surface-2); }
.wf-node--trigger { background:var(--primary-soft); border-color:var(--primary); }
.wf-node__icon { width:34px; height:34px; border-radius:9px; background:var(--surface); border:1px solid var(--border); display:grid; place-items:center; color:var(--primary-ink); flex-shrink:0; }
.wf-node__icon--act { color:var(--text-2); }
.wf-node__t { flex:1; min-width:0; }
.wf-node__kicker { font-size:9.5px; font-weight:800; letter-spacing:.08em; color:var(--text-3); }
.wf-node__title { font-size:13px; font-weight:600; }
.wf-conn { width:2px; height:18px; background:var(--border-strong); margin-left:31px; }
.wf-add { display:flex; align-items:center; gap:7px; padding:11px 14px; border-radius:12px; border:1.5px dashed var(--border-strong); background:transparent; color:var(--text-2); cursor:pointer; font-weight:600; font-size:13px; transition:border-color var(--dur-fast), color var(--dur-fast); }
.wf-add:hover { border-color:var(--primary); color:var(--primary-ink); }
.wf-stats { margin-top:16px; padding-top:12px; border-top:1px solid var(--border); }
.wf-sim { display:flex; flex-direction:column; gap:8px; }
.wf-sim__row { display:flex; align-items:center; gap:11px; padding:10px 12px; border-radius:10px; background:var(--surface-2); border:1px solid var(--border); opacity:.5; transition:opacity var(--dur), background var(--dur); }
.wf-sim__row.is-done { opacity:1; background:var(--success-soft); border-color:transparent; }
.wf-sim__ic { color:var(--text-2); display:flex; }
.wf-sim__lbl { flex:1; font-size:13px; }
.wf-sim__st { color:var(--text-3); display:flex; }
.wf-sim__row.is-done .wf-sim__st { color:var(--success); }

/* ============================================================
   Multitenancy — módulos y plantillas por industria
   ============================================================ */
.snap-grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(240px,1fr)); gap:10px; }
.snap-card { display:flex; align-items:flex-start; gap:11px; padding:13px; border-radius:12px; border:1px solid var(--border); background:var(--surface); cursor:pointer; text-align:left; transition:border-color var(--dur-fast); }
.snap-card:hover { border-color:var(--border-strong); }
.snap-card.is-active { border-color:var(--primary); box-shadow:0 0 0 3px var(--primary-soft); }
.snap-card__icon { width:36px; height:36px; border-radius:9px; background:var(--primary-soft); color:var(--primary-ink); display:grid; place-items:center; flex-shrink:0; }
.snap-card .badge { margin-left:auto; align-self:center; }
.mod-list { display:flex; flex-direction:column; }
.mod-row { display:flex; align-items:center; justify-content:space-between; gap:10px; padding:9px 2px; border-bottom:1px solid var(--border); }
.mod-row:last-child { border-bottom:none; }
.mod-row__t { min-width:0; }

/* ============================================================
   Vista ejecutiva (KPI builder multi-módulo)
   ============================================================ */
.exec-grid { display:grid; grid-template-columns:repeat(4,1fr); gap:14px; }
@media (max-width:1100px){ .exec-grid { grid-template-columns:repeat(2,1fr); } }
@media (max-width:600px){ .exec-grid { grid-template-columns:1fr; } }
.exec-kpi { position:relative; }
.exec-kpi__rm { position:absolute; top:8px; right:8px; z-index:3; width:22px; height:22px; border-radius:50%; border:1px solid var(--border); background:var(--surface); color:var(--text-3); display:grid; place-items:center; cursor:pointer; opacity:0; transition:opacity var(--dur-fast); }
.exec-kpi:hover .exec-kpi__rm { opacity:1; }
.exec-kpi__rm:hover { color:var(--danger); border-color:var(--danger); }
.exec-add { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:6px; border:1.5px dashed var(--border-strong); border-radius:var(--r-md); background:transparent; color:var(--text-2); cursor:pointer; font-weight:600; font-size:13px; min-height:118px; transition:border-color var(--dur-fast), color var(--dur-fast); }
.exec-add:hover { border-color:var(--primary); color:var(--primary-ink); }
.exec-cards { display:grid; grid-template-columns:repeat(3,1fr); gap:16px; align-items:start; }
@media (max-width:1000px){ .exec-cards { grid-template-columns:1fr; } }

/* ============================================================
   Lead scoring (reglas + ranking)
   ============================================================ */
.score-kpis { display:grid; grid-template-columns:repeat(4,1fr); gap:14px; }
@media (max-width:1100px){ .score-kpis { grid-template-columns:repeat(2,1fr); } }
@media (max-width:600px){ .score-kpis { grid-template-columns:1fr; } }
.score-layout { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1.12fr); gap:16px; align-items:start; }
@media (max-width:1000px){ .score-layout { grid-template-columns:1fr; } }
.score-col { display:flex; flex-direction:column; gap:16px; }
.score-rules { display:flex; flex-direction:column; }
.score-rule { display:flex; align-items:center; gap:11px; padding:10px 2px; border-bottom:1px solid var(--border); }
.score-rule:last-child { border-bottom:none; }
.score-rule.is-off { opacity:.5; }
.score-rule__body { flex:1; min-width:0; }
.score-rule__pts { display:inline-flex; align-items:center; gap:2px; font-weight:700; color:var(--primary-ink); font-variant-numeric:tabular-nums; }
.score-rule__pts input { text-align:center; }

/* ============================================================
   Optimización móvil (celular ~360–430px) — auditoría 2026-06-24
   Nota: varios layouts se definen con estilos inline en las vistas;
   por eso aquí se usa !important para que el responsive gane al inline.
   ============================================================ */
/* 1) Ficha de contacto: 3 columnas (270px 1fr 310px) → 1 columna (la central colapsaba a 0px) */
@media (max-width: 920px) {
  .detail-grid { grid-template-columns: minmax(0, 1fr) !important; }
  .detail-grid .grid-2 { grid-template-columns: minmax(0, 1fr) !important; }
}
/* 2) Grids inline de 2 columnas con track fijo (su panel flexible colapsaba a ~0px) → 1 columna.
   minmax(0,1fr) (no 1fr a secas) evita que el track se estire al max-content si el contenido es ancho. */
@media (max-width: 720px) {
  .email-grid, .cal-grid, .conv-grid { grid-template-columns: minmax(0, 1fr) !important; }
}
/* 3) KPI grids con override inline repeat(3/4,1fr): que respeten el colapso responsive */
@media (max-width: 1100px) { .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; } }
@media (max-width: 560px)  { .kpi-grid { grid-template-columns: minmax(0, 1fr) !important; } }
/* 3b) score-layout: el 1fr existente (línea ~958) se estiraba por la tabla de ranking → ceñir al contenedor */
.score-col { min-width: 0; }
@media (max-width: 1000px) { .score-layout { grid-template-columns: minmax(0, 1fr) !important; } }
/* 4) Filas de tabs: scroll horizontal en vez de desbordar/recortar (contact-detail, settings) */
@media (max-width: 720px) {
  .tabs { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { white-space: nowrap; flex-shrink: 0; }
}
/* 5) Kanban en celular: una columna ≈ ancho de pantalla (swipe horizontal); sin grips táctiles */
@media (max-width: 560px) {
  .kanban-col { width: 84vw; max-width: 320px; }
  .deal-card__grip, .dash-grip { display: none !important; }
}
/* 6) Ergonomía táctil + anti auto-zoom de iOS (inputs ≥16px evitan el zoom al enfocar) */
@media (max-width: 560px) {
  .input, .select, .textarea, .input--sm { font-size: 16px; }
  .input--sm { height: 40px; }
  .btn--sm { height: 44px; }
  .iconbtn { width: 44px; height: 44px; }
  .modal-overlay { padding: 14px; }
}
