/* Tipografía autoalojada (General Sans, Fontshare ITF FFL) */
@font-face { font-family: 'General Sans'; src: url('./fonts/general-sans-400.woff2') format('woff2'); font-weight: 400; font-display: swap; font-style: normal; }
@font-face { font-family: 'General Sans'; src: url('./fonts/general-sans-500.woff2') format('woff2'); font-weight: 500; font-display: swap; font-style: normal; }
@font-face { font-family: 'General Sans'; src: url('./fonts/general-sans-600.woff2') format('woff2'); font-weight: 600; font-display: swap; font-style: normal; }
:root {
  --banner: #1633FF;
  --banner-dark: #0F24C2;
  --banner-soft: #E8ECFF;
  --bg: #F5F6FA;
  --surface: #FFFFFF;
  --surface-2: #F0F2F7;
  --border: #E1E4EC;
  --text: #151A2D;
  --muted: #5D6479;
  --faint: #8A90A2;
  --ok: #178A4C;
  --warn: #B26A00;
  --bad: #C0392B;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 64, .06), 0 4px 14px rgba(16, 24, 64, .05);
  --st-interesado: #1633FF;
  --st-no_interesado: #7A8196;
  --st-negociando: #D98A00;
  --st-cerrado: #178A4C;
  --st-perdido: #C0392B;
  --font: 'General Sans', 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.tabular { font-variant-numeric: tabular-nums; }

/* Header / banner */
.topbar { background: var(--banner); color: #fff; position: sticky; top: 0; z-index: 20; }
.topbar-inner { display: flex; align-items: center; gap: 24px; padding: 0 24px; height: 60px; max-width: 1480px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 17px; letter-spacing: -.01em; white-space: nowrap; }
.brand svg, .brand-logo { width: 34px; height: 34px; flex: none; }
.brand-logo { border-radius: 50%; display: block; }
.login-side .brand-logo { width: 44px; height: 44px; }
.login-side .brand { font-size: 20px; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav button { background: transparent; border: 0; color: rgba(255,255,255,.78); padding: 8px 14px; border-radius: 8px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.nav button:hover { color: #fff; background: rgba(255,255,255,.12); }
.nav button.active { color: var(--banner); background: #fff; }
.userchip { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.userchip .who { text-align: right; line-height: 1.2; }
.userchip .who small { display: block; opacity: .8; font-size: 12px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,.2); display: grid; place-items: center; font-weight: 600; font-size: 13px; flex: none; }
.btn-ghost-light { background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.3); color: #fff; padding: 6px 12px; border-radius: 8px; cursor: pointer; }
.btn-ghost-light:hover { background: rgba(255,255,255,.24); }

/* Page banner */
.page-banner { background: var(--banner); color: #fff; border-top: 1px solid rgba(255,255,255,.14); }
.page-banner-inner { max-width: 1480px; margin: 0 auto; padding: 18px 24px 20px; display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-banner h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -.015em; }
.page-banner p { margin: 4px 0 0; opacity: .82; font-size: 13px; }
.banner-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

main { max-width: 1480px; margin: 0 auto; padding: 20px 24px 60px; }

/* Buttons & inputs */
.btn { border: 1px solid var(--border); background: var(--surface); padding: 8px 14px; border-radius: 8px; cursor: pointer; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; transition: background .15s, border-color .15s; }
.btn:hover { border-color: #C6CBD8; background: var(--surface-2); }
.btn-primary { background: var(--banner); border-color: var(--banner); color: #fff; }
.btn-primary:hover { background: var(--banner-dark); border-color: var(--banner-dark); }
.btn-white { background: #fff; color: var(--banner); border-color: #fff; }
.btn-white:hover { background: var(--banner-soft); border-color: var(--banner-soft); }
.btn-danger { color: var(--bad); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; font-weight: 500; color: var(--muted); }
.input, select.input, textarea.input { border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 8px 10px; width: 100%; outline: none; }
.input:focus { border-color: var(--banner); box-shadow: 0 0 0 3px rgba(22, 51, 255, .15); }
.banner-actions .input { background: #fff; color: var(--text); border-color: transparent; min-width: 150px; width: auto; }
.banner-actions input[type=date].input { min-width: 140px; }

/* Toolbar */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar .input { width: auto; min-width: 170px; }
.toolbar .spacer { flex: 1; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.card-h h3 { margin: 0; font-size: 15px; font-weight: 600; }
.card-b { padding: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .l { font-size: 12px; color: var(--muted); font-weight: 500; }
.kpi .v { font-size: 22px; font-weight: 600; margin-top: 4px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: 12px; color: var(--faint); margin-top: 2px; }

/* Kanban */
.board { display: grid; grid-template-columns: repeat(5, minmax(230px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 420px; }
.col-h { padding: 12px 12px 10px; border-top: 4px solid var(--c); border-radius: var(--radius) var(--radius) 0 0; background: var(--surface); border-bottom: 1px solid var(--border); }
.col-h .t { display: flex; justify-content: space-between; align-items: center; font-weight: 600; }
.col-h .count { background: var(--surface-2); border-radius: 999px; padding: 1px 9px; font-size: 12px; color: var(--muted); }
.col-h .sum { font-size: 12px; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
.col-b { padding: 10px; display: flex; flex-direction: column; gap: 8px; flex: 1; transition: background .15s; }
.col-b.over { background: var(--banner-soft); }
.lead-card { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--c); border-radius: 8px; padding: 10px 11px; cursor: grab; box-shadow: 0 1px 2px rgba(16,24,64,.05); }
.lead-card:hover { border-color: #C6CBD8; border-left-color: var(--c); }
.lead-card.dragging { opacity: .5; }
.lead-card .n { font-weight: 600; font-size: 13.5px; }
.lead-card .c { color: var(--muted); font-size: 12.5px; }
.lead-card .m { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: 12px; color: var(--muted); gap: 6px; }
.lead-card .amt { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.empty-col { color: var(--faint); font-size: 12.5px; text-align: center; padding: 20px 8px; border: 1px dashed var(--border); border-radius: 8px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); position: sticky; top: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: #FAFBFD; }
tr.clickable { cursor: pointer; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; background: color-mix(in srgb, var(--c) 12%, white); color: var(--c); }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--c); }
.role { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 500; background: var(--banner-soft); color: var(--banner-dark); }
.role.manager { background: #FFF1DB; color: #8A5200; }
.role.team_leader { background: #E3F5EA; color: #11653A; }
.role.admin { background: #1B1F33; color: #fff; }
.bar { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; min-width: 80px; }
.bar > i { display: block; height: 100%; background: var(--banner); border-radius: 999px; }
.bar.ok > i { background: var(--ok); }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* Segmented tabs */
.seg { display: inline-flex; background: rgba(255,255,255,.16); padding: 3px; border-radius: 9px; gap: 2px; }
.seg button { border: 0; background: transparent; color: #fff; padding: 6px 14px; border-radius: 7px; cursor: pointer; font-weight: 500; }
.seg button.active { background: #fff; color: var(--banner); }

/* Group cards */
.group-card .card-h { background: var(--banner); color: #fff; border-radius: var(--radius) var(--radius) 0 0; border-bottom: 0; }
.group-card .card-h h3 { color: #fff; }
.group-card .card-h .muted { color: rgba(255,255,255,.8); }
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.stat-row .l { font-size: 11.5px; color: var(--muted); }
.stat-row .v { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.member-list { display: flex; flex-direction: column; gap: 8px; }
.member { display: flex; align-items: center; gap: 10px; }
.member .avatar { background: var(--banner-soft); color: var(--banner-dark); width: 30px; height: 30px; font-size: 12px; }
.member .info { flex: 1; min-width: 0; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 20, 45, .45); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { background: var(--surface); border-radius: 14px; width: min(760px, 100%); max-height: 92vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-h { background: var(--banner); color: #fff; padding: 16px 20px; display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; z-index: 1; }
.modal-h h2 { margin: 0; font-size: 17px; font-weight: 600; }
.modal-h .x { background: transparent; border: 0; color: #fff; font-size: 22px; cursor: pointer; line-height: 1; }
.modal-b { padding: 20px; }
.modal-f { position: sticky; bottom: 0; background: var(--surface); padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; gap: 8px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.section-t { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--banner); margin: 18px 0 10px; }
.timeline { display: flex; flex-direction: column; gap: 10px; }
.timeline .ev { display: flex; gap: 10px; font-size: 13px; }
.timeline .dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; background: var(--c); flex: none; }
.checks { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; max-height: 220px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; padding: 10px; }
.checks label { display: flex; gap: 8px; align-items: center; font-size: 13px; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-side { background: var(--banner); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.login-side h1 { font-size: 40px; line-height: 1.08; letter-spacing: -.03em; margin: 0 0 14px; font-weight: 600; max-width: 13ch; }
.login-side p { opacity: .85; max-width: 44ch; font-size: 15px; }
.stage-strip { display: flex; gap: 8px; flex-wrap: wrap; }
.stage-strip span { border: 1px solid rgba(255,255,255,.35); border-radius: 999px; padding: 5px 12px; font-size: 13px; }
.login-form { display: grid; place-items: center; padding: 40px; }
.login-form form { width: min(360px, 100%); display: flex; flex-direction: column; gap: 14px; }
.login-form h2 { margin: 0 0 4px; font-size: 22px; }
.demo-users { font-size: 12.5px; color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.demo-users button { border: 0; background: none; color: var(--banner); cursor: pointer; padding: 0; font-weight: 500; }
.error { color: var(--bad); font-size: 13px; min-height: 18px; }
.toast { position: fixed; bottom: 20px; right: 20px; background: #151A2D; color: #fff; padding: 11px 16px; border-radius: 9px; z-index: 80; box-shadow: 0 8px 24px rgba(0,0,0,.2); font-size: 13.5px; }
.storage-badge { font-size: 11.5px; padding: 3px 8px; border-radius: 6px; background: rgba(255,255,255,.16); white-space: nowrap; }
.chart-box { position: relative; height: 300px; }

@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(3, 1fr); } .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 800px) {
  /* Menú en su propia fila (ancho completo, desplazable) para que todas las secciones sean alcanzables */
  .topbar-inner { padding: 8px 14px 0; gap: 8px 12px; height: auto; flex-wrap: wrap; }
  .brand { order: 1; flex: 1; }
  .userchip { order: 2; }
  .nav { order: 3; flex: 1 0 100%; margin: 0 -14px; padding: 0 14px 8px; gap: 2px; scroll-snap-type: x proximity; scroll-padding: 0 14px; }
  .nav button { padding: 8px 12px; font-size: 13.5px; scroll-snap-align: start; }
  .userchip .who, .storage-badge { display: none; }
  main, .page-banner-inner { padding-left: 14px; padding-right: 14px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-side { padding: 32px 24px; }
  .login-side h1 { font-size: 30px; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .brand span { display: none; }
}

.dup-alert { margin-top: 14px; padding: 11px 14px; border-radius: 8px; background: #FDECEA; border: 1px solid #F3B9B2; color: #8E2318; font-size: 13.5px; font-weight: 500; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---- Búsqueda global y alertas ---- */
.gsearch { display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.25); border-radius: 9px; padding: 0 10px; height: 36px; width: 230px; flex: none; color: rgba(255,255,255,.85); }
.gsearch:focus-within { background: #fff; color: var(--muted); border-color: #fff; }
.gsearch input { border: 0; outline: 0; background: transparent; color: #fff; width: 100%; font-size: 13.5px; }
.gsearch:focus-within input { color: var(--text); }
.gsearch input::placeholder { color: rgba(255,255,255,.75); }
.bell { position: relative; flex: none; width: 38px; height: 38px; border-radius: 9px; border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.14); color: #fff; display: grid; place-items: center; cursor: pointer; }
.bell:hover { background: rgba(255,255,255,.24); }
.bell-count { position: absolute; top: -6px; right: -6px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 999px; background: #FF3B30; color: #fff; font-size: 11px; font-weight: 600; display: grid; place-items: center; border: 2px solid var(--banner); }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 7px; }
.age, .lock { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; padding: 2px 7px; border-radius: 6px; background: var(--surface-2); color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.age.late { background: #FDECEA; color: #A8281B; }
.lock { background: #E8ECFF; color: var(--banner-dark); }
.lock.soon { background: #FFF1DB; color: #8A5200; }
.lock.expired { background: #FDECEA; color: #A8281B; }
.req-neg { font-weight: 400; color: var(--faint); margin-left: 4px; font-size: 11px; }
.req-neg.on { color: var(--bad); font-weight: 600; }
.lock-info { margin-top: 14px; padding: 10px 14px; border-radius: 8px; background: #E8ECFF; color: var(--banner-dark); font-size: 13.5px; display: flex; gap: 8px; align-items: center; }
.lock-info.expired { background: #FDECEA; color: #8E2318; }
.al-sec { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-top: 12px; border-left: 4px solid var(--banner); }
.al-sec.warn { border-left-color: #D98A00; }
.al-sec.bad { border-left-color: var(--bad); }
.al-sec p { margin: 2px 0 8px; }
.al-h { display: flex; align-items: center; justify-content: space-between; }
.al-h h3 { margin: 0; font-size: 14.5px; }
.al-n { background: var(--surface-2); border-radius: 999px; padding: 1px 9px; font-size: 12px; font-weight: 600; }
.al-list { display: flex; flex-direction: column; gap: 4px; }
.al-row { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 1px solid transparent; background: transparent; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.al-row:hover:not([disabled]) { background: var(--surface-2); border-color: var(--border); }
.al-row[disabled] { cursor: default; }
.al-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex: none; }
.al-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.al-extra { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.locked-row { background: #FAFBFD; }
.empty-search { text-align: center; padding: 26px 10px; border: 1px dashed var(--border); border-radius: 10px; }
@media (max-width: 1360px) { .storage-badge { display: none; } .gsearch { width: 190px; } }
@media (max-width: 1180px) { .userchip .who { display: none; } }
@media (max-width: 800px) { .gsearch { width: 40px; padding: 0 11px; } .gsearch:focus-within { width: 180px; } .gsearch input::placeholder { color: transparent; } }
.gsearch svg { flex: none; }
.gsearch input { min-width: 0; }
@media (max-width: 800px) { .gsearch { justify-content: center; } .gsearch:not(:focus-within) input { width: 0; } }

/* Metas */
.input.goal-in { width: 160px; max-width: 100%; }
/* Notas con marca de tiempo y autor */
.notes { display: flex; flex-direction: column; gap: 8px; max-height: 240px; overflow-y: auto; }
.note { border: 1px solid var(--border); border-left: 3px solid var(--banner); border-radius: 8px; padding: 8px 10px; background: var(--surface-2); }
.note-h { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 13px; margin-bottom: 3px; }
.note-t { font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }

/* Filtro de fechas (Pipeline / Leads) */
.date-range { display: inline-flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 2px 6px 2px 10px; }
.date-range .dr-l, .date-range .dr-sep { font-size: 12.5px; color: var(--faint); white-space: nowrap; }
.toolbar .date-range .input { min-width: 0; width: 132px; border: 0; padding: 6px 4px; box-shadow: none; }
.date-range .dr-x { border: 0; background: transparent; color: var(--faint); font-size: 18px; line-height: 1; cursor: pointer; padding: 0 4px; }
.date-range .dr-x:hover { color: var(--bad); }
