:root {
  color-scheme: dark;
  /* superficies (negro cálido en capas) */
  --bg: #0A0A08; --bg-alt: #111009; --card: #171511; --surface-2: #1C1A16;
  /* texto (crema con jerarquía por opacidad) */
  --text: #F0ECE4; --text-2: rgba(240,236,228,.70); --text-3: rgba(240,236,228,.45);
  --faint: rgba(240,236,228,.12);
  /* bordes */
  --border: rgba(240,236,228,.10); --border-strong: rgba(240,236,228,.18);
  /* acento azul */
  --accent: #0071e3; --accent-hover: #2F8AFF; --accent-text: #FFFFFF;
  --accent-glow: rgba(0,113,227,.14);
  /* estados (legibles sobre fondo oscuro) */
  --danger: #E5827B; --attn: #E3B15A; --info: #6FAAF5; --ok: #52C99A; --focus: #7DB3FF;
  --radius-sm: 8px; --radius-md: 12px; --radius-lg: 16px; --radius-xl: 20px;
  --shadow-xs: 0 2px 8px rgba(0,0,0,.35);
  --shadow-sm: 0 10px 28px rgba(0,0,0,.45);
  --shadow-lg: 0 -12px 36px rgba(0,0,0,.5);
  --shadow-cta: 0 10px 28px rgba(0,113,227,.28);
  --ease: cubic-bezier(.16,1,.3,1);
  --spring: cubic-bezier(.34,1.56,.64,1);
  --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-serif: 'Satoshi', -apple-system, BlinkMacSystemFont, "SF Pro Display", sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
html { height: 100%; }
body {
  font-family: var(--font-sans); background: var(--bg); color: var(--text);
  line-height: 1.5; font-size: 14px; -webkit-font-smoothing: antialiased;
  min-height: 100dvh; overscroll-behavior-y: none;
}
a { color: inherit; }
h1, h2, h3 { font-family: var(--font-serif); font-weight: 700; letter-spacing: -.01em; }
.icon { width: 15px; height: 15px; flex: none; display: block; }
b, strong, .tabular { font-variant-numeric: tabular-nums; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; top: -48px; left: 8px; z-index: 100; background: var(--text);
  color: var(--bg); padding: 10px 16px; border-radius: var(--radius-sm); font-weight: 650;
  font-size: .82rem; transition: top .15s var(--ease);
}
.skip-link:focus { top: 8px; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---- app shell / login gate ---- */
#appShell[hidden], #loginScreen[hidden] { display: none !important; }
.login-screen {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 24px; padding-top: calc(24px + var(--safe-t)); padding-bottom: calc(24px + var(--safe-b));
}
.login-card { width: 100%; max-width: 360px; }
.login-brand { display: flex; align-items: baseline; gap: 9px; justify-content: center; margin-bottom: 28px; }
.login-brand .brand-mark { font-family: var(--font-serif); font-size: 1.6rem; letter-spacing: -.02em; }
.login-brand .brand-sep { color: var(--text-3); }
.login-brand .brand-title { font-size: .95rem; font-weight: 600; color: var(--text-2); }
.login-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.login-field label { font-size: .74rem; font-weight: 650; color: var(--text-2); }
.login-field input {
  width: 100%; padding: 11px 13px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--card); color: var(--text); font: inherit; font-size: .92rem;
}
.login-error {
  display: none; background: color-mix(in srgb, var(--danger) 12%, var(--card));
  color: color-mix(in srgb, var(--danger) 80%, var(--text)); border-radius: var(--radius-sm);
  padding: 10px 12px; font-size: .8rem; font-weight: 550; margin-bottom: 14px;
}
.login-error.show { display: block; }
.login-submit {
  width: 100%; padding: 13px; border-radius: var(--radius-sm); border: none;
  background: var(--accent); color: var(--accent-text); font: inherit; font-size: .9rem;
  font-weight: 650; cursor: pointer; box-shadow: var(--shadow-cta);
  transition: background-color .2s var(--ease), transform .15s var(--spring), opacity .15s var(--ease);
}
.login-submit:hover { background: var(--accent-hover); }
.login-submit:active { transform: scale(.98); }
.login-submit:disabled { opacity: .55; pointer-events: none; }

/* ---- header ---- */
.app-header {
  position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(24px) saturate(1.8); -webkit-backdrop-filter: blur(24px) saturate(1.8);
  border-bottom: 1px solid var(--border);
}
.row { max-width: 1400px; margin: 0 auto; padding-left: 28px; padding-right: 28px; }
.brand-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding-top: calc(18px + var(--safe-t)); padding-bottom: 14px; }
.brand { display: flex; align-items: baseline; gap: 9px; }
.brand-mark { font-family: var(--font-serif); font-size: 1.4rem; letter-spacing: -.02em; }
.brand-sep { color: var(--text-3); }
.brand-title { font-size: .92rem; font-weight: 600; color: var(--text-2); }
.header-actions { display: flex; align-items: center; gap: 10px; }
.sync-indicator { display: inline-flex; align-items: center; gap: 6px; font-size: .72rem; font-weight: 600; color: var(--text-2); white-space: nowrap; }
.sync-indicator .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); flex: none; }
.sync-indicator.pending .dot { background: var(--attn); }
.sync-indicator.offline .dot { background: var(--text-3); }
.sync-indicator.error .dot { background: var(--danger); }
.command-row { display: flex; flex-wrap: wrap; align-items: center; gap: 22px; padding-bottom: 16px; }
.goal { display: flex; flex-direction: column; gap: 6px; }
.goal-label { font-size: .72rem; color: var(--text-2); }
.goal-label b { color: var(--text); font-variant-numeric: tabular-nums; }
.goal-bar { height: 6px; width: 200px; border-radius: 99px; background: var(--bg-alt); overflow: hidden; }
.goal-bar-fill { height: 100%; border-radius: 99px; background: var(--text); transition: width .3s var(--ease); }
.stat-strip { display: flex; gap: 22px; padding-left: 22px; border-left: 1px solid var(--border); }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat b { font-size: 1.1rem; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat span { font-size: .68rem; color: var(--text-2); }
.spacer { flex: 1 1 auto; }
.pendientes-btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--card); font: inherit; font-size: .8rem;
  font-weight: 650; color: var(--text); cursor: pointer; transition: background-color .15s var(--ease), color .15s var(--ease);
}
.pendientes-btn:hover { background: var(--bg-alt); }
.pendientes-btn .count {
  background: var(--attn); color: #fff; border-radius: 999px; min-width: 20px; height: 20px;
  display: inline-flex; align-items: center; justify-content: center; font-size: .7rem; padding: 0 5px;
  font-variant-numeric: tabular-nums;
}
.pendientes-btn.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.pendientes-btn.active .count { background: var(--bg); color: var(--text); }

/* ---- insights (collapsible) ---- */
.insights { border-top: 1px solid var(--border); }
.insights > summary {
  list-style: none; cursor: pointer; padding: 10px 28px; max-width: 1400px; margin: 0 auto;
  display: flex; align-items: center; gap: 7px; font-size: .78rem; font-weight: 600; color: var(--text-2);
}
.insights > summary::-webkit-details-marker { display: none; }
.insights > summary .icon { width: 13px; height: 13px; transition: transform .18s var(--ease); }
.insights[open] > summary .icon { transform: rotate(180deg); }
.insights-body {
  padding: 4px 28px 22px; max-width: 1400px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 26px;
}
.leader-table { display: flex; flex-direction: column; gap: 2px; }
.leader-table h3 { font-size: .78rem; font-weight: 650; margin: 0 0 6px; color: var(--text); }
.leader-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; font-size: .78rem; padding: 7px 0; border-bottom: 1px solid var(--border); }
.leader-row:last-child { border-bottom: none; }
.leader-name { color: var(--text); font-weight: 500; display: flex; align-items: center; gap: 6px; min-width: 0; }
.leader-name .status-dot { width: 6px; height: 6px; }
.leader-rate { font-variant-numeric: tabular-nums; font-weight: 650; white-space: nowrap; }
.leader-n { color: var(--text-3); font-size: .7rem; white-space: nowrap; }
.leader-empty { color: var(--text-3); font-size: .78rem; padding: 8px 0; }

/* ---- toolbar / filters (desktop inline; ver .sheet para móvil) ---- */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding-top: 12px; padding-bottom: 12px; border-top: 1px solid var(--border); }
.search-field { position: relative; flex: 1 1 220px; min-width: 180px; }
.search-field .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: var(--text-3); }
.search-field input { width: 100%; padding: 8px 10px 8px 32px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--card); color: var(--text); font: inherit; font-size: .83rem; }
select {
  background: var(--card); border: 1px solid var(--border-strong); color: var(--text);
  border-radius: 8px; padding: 7px 10px; font: inherit; font-size: .82rem;
}
.view-toggle { display: flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.view-toggle button { background: var(--card); border: none; color: var(--text-2); padding: 7px 14px; font-size: .8rem; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 6px; }
.view-toggle button.active { background: var(--text); color: var(--bg); }
.filter-row { display: flex; flex-wrap: wrap; gap: 18px; align-items: center; padding-bottom: 14px; }
.chip-group { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: var(--card); border: 1px solid var(--border-strong); color: var(--text-2);
  border-radius: 999px; padding: 5px 11px; font-size: .75rem; font-weight: 550; cursor: pointer;
  user-select: none; white-space: nowrap; transition: background-color .15s var(--ease), color .15s var(--ease);
}
.chip:hover { background: var(--bg-alt); }
.chip.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip[data-estado].active { color: #fff; }
.mobile-filter-btn { display: none; position: relative; }
.mobile-filter-btn .badge {
  position: absolute; top: -5px; right: -5px; background: var(--attn); color: #fff; border-radius: 999px;
  min-width: 16px; height: 16px; font-size: .6rem; display: flex; align-items: center; justify-content: center;
  font-weight: 700; padding: 0 3px;
}

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: .82rem; font-weight: 600;
  padding: 7px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--card); color: var(--text); cursor: pointer; white-space: nowrap;
  transition: transform .15s var(--ease), background-color .15s var(--ease);
}
.btn:hover { background: var(--bg-alt); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); box-shadow: var(--shadow-cta); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border-strong)); }
.btn:disabled, .btn.disabled { opacity: .4; pointer-events: none; }
#importInput { display: none; }

main { padding: 20px 28px 64px; max-width: 1400px; margin: 0 auto; }
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 76px 20px; color: var(--text-2); text-align: center; }
.empty-state .icon { width: 30px; height: 30px; color: var(--text-3); }
.empty-state h3 { margin: 0; font-size: .95rem; color: var(--text); }
.empty-state p { margin: 0; font-size: .82rem; max-width: 340px; }
.empty-state.error .icon { color: var(--danger); }

/* ---- skeleton loading ---- */
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
.skeleton {
  background: linear-gradient(90deg, var(--bg-alt) 25%, var(--border) 37%, var(--bg-alt) 63%);
  background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: var(--radius-sm);
}
.skeleton-card { height: 92px; border-radius: var(--radius-md); margin-bottom: 10px; }
.skeleton-stat { width: 48px; height: 26px; }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; opacity: .6; } }

/* ---- status pill ---- */
.status-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border-radius: 999px;
  font-size: .72rem; font-weight: 650; white-space: nowrap;
  background: color-mix(in srgb, var(--dot) 15%, var(--card));
  color: color-mix(in srgb, var(--dot) 45%, var(--text));
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dot); flex: none; }
.status-pill-tap {
  border: none; cursor: pointer; font: inherit; -webkit-tap-highlight-color: transparent;
  transition: transform .15s var(--spring), filter .15s var(--ease);
}
.status-pill-tap:hover { filter: brightness(1.12); }
.status-pill-tap:active { transform: scale(.95); }
.status-picker-list { display: flex; flex-direction: column; gap: 4px; padding-bottom: 4px; }
.status-picker-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: none;
  background: none; color: var(--text); font: inherit; font-size: .88rem; font-weight: 600;
  padding: 13px 6px; border-radius: var(--radius-sm); cursor: pointer; min-height: 44px;
  transition: background-color .15s var(--ease);
}
.status-picker-item:hover { background: var(--bg-alt); }
.status-picker-item .status-dot { width: 9px; height: 9px; }
.status-picker-item.current { background: var(--accent-glow); color: var(--accent-hover); font-weight: 700; }
.due-flag {
  display: inline-flex; align-items: center; gap: 5px; font: inherit; font-size: .72rem; font-weight: 650;
  color: color-mix(in srgb, var(--attn) 75%, var(--text));
  background: color-mix(in srgb, var(--attn) 14%, var(--card));
  padding: 3px 9px 3px 8px; border-radius: 999px; white-space: nowrap;
  border: none; cursor: pointer; transition: filter .15s var(--ease);
}
.due-flag:hover { filter: brightness(.92); }
.due-flag .icon { width: 11px; height: 11px; }
.verif-flag {
  display: inline-flex; align-items: center; gap: 5px; font-size: .72rem; font-weight: 650;
  padding: 3px 9px 3px 8px; border-radius: 999px; white-space: nowrap; text-decoration: none;
}
.verif-flag.warn {
  color: color-mix(in srgb, var(--danger) 75%, var(--text));
  background: color-mix(in srgb, var(--danger) 14%, var(--card));
}
.verif-flag.info {
  color: color-mix(in srgb, var(--info) 75%, var(--text));
  background: color-mix(in srgb, var(--info) 14%, var(--card));
}
a.verif-flag:hover { filter: brightness(.94); }
.verif-flag .icon { width: 11px; height: 11px; }
.act-btn.tentative, .icon-btn.tentative {
  border-style: dashed;
  color: color-mix(in srgb, var(--info) 80%, var(--text));
}

/* ---- list view ---- */
@keyframes reveal { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.lead-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 14px 16px; margin-bottom: 10px; box-shadow: var(--shadow-xs);
  animation: reveal .28s var(--ease) both;
  transition: box-shadow .18s var(--ease), transform .18s var(--ease);
}
.lead-card:hover { box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.lead-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.lead-id-block { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.lead-badges { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lead-name { font-weight: 650; font-size: .96rem; letter-spacing: -.01em; }
.lead-meta { color: var(--text-2); font-size: .78rem; }
.lead-meta span + span::before { content: "·"; margin: 0 6px; color: var(--text-3); }
.lead-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.act-btn {
  display: inline-flex; align-items: center; gap: 5px; border-radius: 7px; padding: 6px 10px;
  font-size: .76rem; font-weight: 650; border: 1px solid var(--border-strong); background: var(--card);
  color: var(--text); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform .15s var(--ease), background-color .15s var(--ease);
}
.act-btn:hover { background: var(--bg-alt); }
.act-btn:active { transform: scale(.96); }
.act-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); box-shadow: var(--shadow-cta); }
.act-btn.primary:hover { background: var(--accent-hover); }
.act-btn.disabled { opacity: .35; pointer-events: none; }
.act-btn .icon { width: 14px; height: 14px; }
.lead-edit { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: .66rem; color: var(--text-2); text-transform: uppercase; letter-spacing: .05em; }
.field select, .field input[type=date] { background: var(--bg); border: 1px solid var(--border-strong); color: var(--text); border-radius: 7px; padding: 6px 9px; font: inherit; font-size: .8rem; }
.field.grow { flex: 1 1 220px; }
.field textarea { width: 100%; min-height: 34px; max-height: 140px; resize: vertical; background: var(--bg); border: 1px solid var(--border-strong); color: var(--text); border-radius: 7px; padding: 6px 9px; font: inherit; font-size: .8rem; }
details.msg-toggle { margin-top: 10px; }
details.msg-toggle summary { cursor: pointer; font-size: .76rem; font-weight: 650; color: var(--text-2); list-style: none; display: inline-flex; align-items: center; gap: 5px; }
details.msg-toggle summary::-webkit-details-marker { display: none; }
details.msg-toggle summary .icon { width: 12px; height: 12px; transition: transform .18s var(--ease); }
details.msg-toggle[open] summary .icon { transform: rotate(180deg); }
.tag-label { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); margin: 10px 0 4px; }
.tag-label:first-child { margin-top: 0; }
.msg-box { margin: 0; font-size: .83rem; line-height: 1.55; background: var(--bg); border-radius: 9px; padding: 11px 13px; white-space: pre-wrap; border: 1px solid var(--border); }

/* ---- pipeline / kanban view ---- */
.board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 22px; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
.column {
  background: var(--bg-alt); border-radius: var(--radius-lg); min-width: 264px; max-width: 280px; flex: 0 0 auto;
  display: flex; flex-direction: column; max-height: calc(100dvh - 260px); scroll-snap-align: start;
}
.column-head { padding: 12px 14px; font-size: .8rem; font-weight: 650; display: flex; align-items: center; gap: 8px; justify-content: space-between; position: sticky; top: 0; background: var(--bg-alt); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.column-head-label { display: flex; align-items: center; gap: 7px; }
.column-count { color: var(--text-2); font-weight: 600; font-variant-numeric: tabular-nums; }
.column-body { padding: 0 8px 8px; overflow-y: auto; flex: 1 1 auto; display: flex; flex-direction: column; gap: 8px; }
.column.drag-over { outline: 2px dashed var(--text-3); outline-offset: -4px; }
.column-empty { color: var(--text-2); font-size: .72rem; padding: 18px 6px; text-align: center; }
.kcard { background: var(--card); border: 1px solid var(--border); border-radius: 9px; padding: 9px 10px; cursor: grab; box-shadow: var(--shadow-xs); display: flex; flex-direction: column; gap: 6px; animation: reveal .28s var(--ease) both; }
.kcard:active { cursor: grabbing; }
.kcard-top { display: flex; align-items: flex-start; gap: 6px; justify-content: space-between; }
.kcard .lead-name { font-size: .83rem; }
.kcard .lead-meta { font-size: .7rem; }
.kcard-actions { display: flex; gap: 4px; }
.drag-handle { color: var(--text-3); flex: none; margin-top: 2px; }
.icon-btn {
  width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px; border: 1px solid var(--border-strong); background: var(--card); color: var(--text);
  cursor: pointer; text-decoration: none; transition: background-color .15s var(--ease), transform .15s var(--ease);
}
.icon-btn:hover { background: var(--bg-alt); }
.icon-btn:active { transform: scale(.93); }
.icon-btn .icon { width: 13px; height: 13px; }
.icon-btn.disabled { opacity: .3; pointer-events: none; }
.icon-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

/* ---- modal ---- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,16,18,.5); z-index: 60; display: flex; align-items: flex-start; justify-content: center; padding: 48px 16px; }
.modal-backdrop[hidden] { display: none; }
.modal { background: var(--card); border-radius: var(--radius-lg); max-width: 760px; width: 100%; max-height: calc(100dvh - 96px); overflow-y: auto; padding: 28px 30px; position: relative; box-shadow: var(--shadow-sm); }
.modal-close { position: absolute; top: 16px; right: 16px; }
.modal h2 { margin: 0 0 4px; font-size: 1.15rem; }
.modal .lede { color: var(--text-2); font-size: .85rem; margin: 0 0 18px; }
.modal .branch { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 16px; scroll-margin-top: 20px; }
.modal .branch:first-of-type { border-top: none; margin-top: 8px; padding-top: 0; }
.modal .branch h3 { font-size: 1rem; margin: 0 0 3px; }
.modal .branch .lede { margin: 0 0 10px; }

/* ---- bottom sheet (filtros / "más" en móvil) ---- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(15,16,18,.5); z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop[hidden] { display: none; }
.sheet {
  background: var(--card); border-radius: var(--radius-xl) var(--radius-xl) 0 0; width: 100%; max-width: 560px;
  max-height: min(78dvh, 640px); overflow-y: auto; box-shadow: var(--shadow-lg);
  padding: 10px 20px calc(20px + var(--safe-b));
  animation: sheet-up .22s var(--ease) both;
}
@keyframes sheet-up { from { transform: translateY(16px); opacity: .6; } to { transform: translateY(0); opacity: 1; } }
.sheet-handle { width: 36px; height: 4px; border-radius: 99px; background: var(--border-strong); margin: 4px auto 14px; }
.sheet h2 { font-size: 1rem; margin: 0; }
.sheet-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.sheet-clear-btn {
  background: none; border: none; font: inherit; font-size: .78rem; font-weight: 650;
  color: var(--accent-hover); cursor: pointer; padding: 4px 2px;
}
.active-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.active-chips:empty { display: none; }
.active-filter-chip {
  display: inline-flex; align-items: center; gap: 5px; background: var(--accent-glow);
  color: var(--accent-hover); border-color: transparent;
}
.active-filter-chip button {
  background: none; border: none; color: inherit; font-size: .95rem; line-height: 1; cursor: pointer;
  padding: 0; display: inline-flex; opacity: .75;
}
.active-filter-chip button:hover { opacity: 1; }
.sheet-section { margin-bottom: 20px; }
.sheet-section:last-child { margin-bottom: 4px; }
.sheet-section-label { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); margin-bottom: 8px; }
.sheet-row { display: flex; flex-direction: column; gap: 10px; }
.sheet .chip-group { gap: 8px; }
.sheet .chip { padding: 8px 14px; font-size: .8rem; }
.sheet select { width: 100%; padding: 10px 12px; font-size: .86rem; }
.sheet-menu-item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 13px 4px;
  background: none; border: none; border-bottom: 1px solid var(--border); font: inherit; font-size: .88rem;
  font-weight: 600; color: var(--text); cursor: pointer;
}
.sheet-menu-item:last-child { border-bottom: none; }
.sheet-menu-item .icon { width: 17px; height: 17px; color: var(--text-2); }
.sheet-menu-item.danger { color: var(--danger); }
.sheet-menu-item.danger .icon { color: var(--danger); }

/* ---- bottom nav (móvil) ---- */
.bottom-nav {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: var(--card); border-top: 1px solid var(--border);
  padding: 6px 4px calc(6px + var(--safe-b));
}
.bottom-nav-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; }
.bottom-nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 2px;
  background: none; border: none; color: var(--text-2); font: inherit; font-size: .62rem; font-weight: 650;
  cursor: pointer; border-radius: var(--radius-sm); position: relative; min-height: 44px;
}
.bottom-nav-item .icon { width: 20px; height: 20px; }
.bottom-nav-item.active { color: var(--text); }
.bottom-nav-item .badge {
  position: absolute; top: 2px; right: calc(50% - 18px); background: var(--attn); color: #fff; border-radius: 999px;
  min-width: 15px; height: 15px; font-size: .58rem; display: flex; align-items: center; justify-content: center;
  font-weight: 700; padding: 0 3px;
}

/* ---- toast ---- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 8px);
  background: var(--text); color: var(--bg); padding: 9px 18px; border-radius: 999px;
  font-size: .82rem; font-weight: 650; z-index: 70; opacity: 0; pointer-events: none;
  transition: opacity .2s var(--ease), transform .2s var(--ease); max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #fff; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* ---- mobile-first: nav + toolbar + tarjetas ---- */
@media (max-width: 760px) {
  .row, .toolbar, .filter-row, main { padding-left: 16px; padding-right: 16px; }
  .insights > summary, .insights-body { padding-left: 16px; padding-right: 16px; }
  .command-row { gap: 14px; }
  .stat-strip { padding-left: 0; border-left: none; gap: 16px; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
  .stat { flex: 0 0 auto; }
  .goal, .goal-bar { min-width: 0; width: 100%; }
  .goal-bar { width: auto; }

  .view-toggle { display: none; }
  .pendientes-btn span:not(.count) { display: none; }
  .pendientes-btn { padding: 8px 10px; }

  /* toolbar: search + botón filtros; el resto de controles se van al sheet */
  .toolbar { gap: 8px; }
  .toolbar #nicheFilter, .toolbar #comunaFilter, .toolbar #sortSelect,
  .toolbar #guideBtn, .toolbar #exportCsvBtn, .toolbar #exportJsonBtn, .toolbar #importJsonBtn { display: none; }
  .mobile-filter-btn { display: inline-flex; }
  .filter-row { display: none; } /* se reemplaza por el sheet de filtros */

  main { padding-top: 16px; padding-bottom: calc(84px + var(--safe-b)); }
  .lead-card { padding: 13px 14px; }
  .lead-actions { width: 100%; }
  .act-btn { flex: 1 1 auto; justify-content: center; padding: 10px 8px; min-height: 44px; }
  .act-btn.primary { flex: 1 1 100%; order: -1; }
  .lead-edit { gap: 12px; }
  .field.grow { flex: 1 1 100%; }
  .field select, .field input[type=date], .field textarea { min-height: 40px; font-size: .86rem; }

  .board { gap: 10px; }
  .column { min-width: 82vw; max-width: 86vw; max-height: none; }
  .column-body { max-height: 52vh; }

  .bottom-nav { display: block; }
  #guideModal .modal, #genericModal .modal { padding: 22px 18px; max-height: calc(100dvh - 64px); }
}

/* pantallas muy angostas (iPhone SE) -- un poco más de aire en los targets táctiles */
@media (max-width: 380px) {
  .bottom-nav-item { font-size: .58rem; }
  .stat b { font-size: 1rem; }
}
