:root {
  --ground: #f9fafb;
  --panel: #ffffff;
  --sunken: #f3f4f6;
  --ink: #101828;
  --ink-2: #4a5565;
  --ink-3: #5f6673;
  --line: #e5e7eb;
  --line-strong: #d1d5dc;
  --field-line: #838a96;
  --action: #bb4d00;
  --action-hover: #973c00;
  --action-soft: #fffbeb;
  --action-line: #fee685;
  --accent: #e17100;
  --on-action: #ffffff;
  --failed: #dc2626;
  --failed-ink: #b91c1c;
  --failed-soft: #fef2f2;
  --delayed-ink: #973c00;
  --delayed-soft: #fef3c6;
  --ok: #16a34a;
  --ok-ink: #15803d;
  --ok-soft: #f0fdf4;
  --neutral-ink: #475569;
  --neutral-soft: #f1f5f9;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --touch: 44px;
  --c-pendiente: #94a3b8;
  --c-visitado: #475569;
  --c-interesado: #16a34a;
  --c-volver: #e17100;
  --c-no_interesa: #dc2626;
  --c-firmado: #bb4d00;
  --c-descartado: #101828;
  --font: "Outfit Variable", Outfit, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font: 400 16px/1.5 var(--font);
  background: var(--ground);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}
body.locked { overflow: hidden; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.25; letter-spacing: -0.02em; }
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 700; }
h3 { font-size: 0.78rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); margin-top: 28px; }
p { margin: 0 0 8px; }
a { color: var(--action); }
.muted { color: var(--ink-3); }
.small { font-size: 0.85rem; }
.error { color: var(--failed-ink); min-height: 1.3em; margin: 8px 0 0; font-weight: 500; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--touch); min-width: var(--touch); padding: 0 18px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-md);
  background: var(--panel); color: var(--ink); font: 600 1rem/1.2 var(--font);
  text-decoration: none; cursor: pointer; touch-action: manipulation;
}
.btn:hover { background: var(--sunken); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--action); color: var(--on-action); border-color: var(--action); }
.btn.primary:hover { background: var(--action-hover); border-color: var(--action-hover); }
.btn.big { min-height: 60px; font-size: 1.1rem; border-radius: var(--radius-lg); padding: 0 24px; }
.btn.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.signed { background: var(--ok-ink); color: #fff; border-color: var(--ok-ink); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
input, select, textarea {
  width: 100%; min-height: var(--touch); padding: 10px 14px;
  border: 1px solid var(--field-line); border-radius: var(--radius-md);
  font: 400 1rem/1.4 var(--font); background: var(--panel); color: var(--ink);
}
textarea { resize: vertical; }
input[aria-invalid="true"] { border-color: var(--failed); }
label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--ink-2); margin: 14px 0 0; }
label input, label select, label textarea { margin-top: 6px; font-weight: 400; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(400px, 100%); background: var(--panel); padding: 32px 28px; border-radius: var(--radius-xl); border: 1px solid var(--line); }
.login-card .btn { width: 100%; margin-top: 16px; }

.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top));
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.02em; display: inline-flex; align-items: center; gap: 10px; }
.brand::before { content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); }
.spacer { flex: 1; }
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; z-index: 30;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: 0 12px 32px rgba(16, 24, 40, 0.16); overflow: hidden;
}
.menu button, .menu a {
  display: flex; align-items: center; width: 100%; min-height: 52px; padding: 0 18px;
  background: none; border: 0; border-bottom: 1px solid var(--line); font: 600 1rem var(--font);
  color: var(--ink); text-decoration: none; text-align: left; cursor: pointer;
}
.menu button:hover, .menu a:hover { background: var(--action-soft); }
.menu > :last-child { border-bottom: 0; }

.screen { max-width: 860px; margin: 0 auto; background: var(--panel); min-height: calc(100vh - 62px); }
.list-screen { max-width: 1400px; margin: 0 auto; display: flex; flex-direction: column; background: var(--panel); min-height: calc(100vh - 62px); }
.map-col { height: 240px; position: relative; border-bottom: 1px solid var(--line); }
#map { position: absolute; inset: 0; background: var(--sunken); }
.list-col { flex: 1; min-width: 0; }
.filters { padding: 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
.filter-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.filter-row:last-of-type { grid-template-columns: auto auto 1fr; }
.filter-row .btn { white-space: nowrap; }
.filters p { margin: 12px 0 0; }

.list { list-style: none; margin: 0; padding: 0; }
.row {
  display: flex; gap: 14px; align-items: flex-start; width: 100%; text-align: left; background: none; border: 0;
  border-bottom: 1px solid var(--line); padding: 16px; min-height: 68px; font: inherit; color: inherit; cursor: pointer;
}
.row:hover { background: var(--action-soft); }
.row-main { flex: 1; min-width: 0; display: block; }
.row-main > span { display: flex; }
.row-top { justify-content: space-between; gap: 12px; align-items: flex-start; }
.row-name { font-weight: 600; font-size: 1.02rem; }
.row-meta { display: block !important; color: var(--ink-3); font-size: 0.9rem; margin-top: 2px; }
.row-num {
  flex: none; min-width: 34px; height: 34px; border-radius: 999px; background: var(--ink); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.9rem;
}
.row-num.none { background: transparent; }
.badges { flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.badge {
  display: inline-block; padding: 3px 12px; border-radius: 999px; font-size: 0.78rem; font-weight: 600;
  background: var(--neutral-soft); color: var(--neutral-ink); white-space: nowrap;
}
.badge.warn { background: var(--delayed-soft); color: var(--delayed-ink); }
.badge.demo { background: var(--action-soft); color: var(--action); border: 1px solid var(--action-line); }
.badge.estado { color: #fff; }
.badge.estado.pendiente { background: var(--c-pendiente); color: var(--ink); }
.badge.estado.visitado { background: var(--c-visitado); }
.badge.estado.interesado { background: var(--c-interesado); }
.badge.estado.volver { background: var(--c-volver); color: var(--ink); }
.badge.estado.no_interesa { background: var(--c-no_interesa); }
.badge.estado.firmado { background: var(--c-firmado); }
.badge.estado.descartado { background: var(--c-descartado); }

.profile-bar { padding: 12px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 62px; background: var(--panel); z-index: 10; }
.profile { padding: 24px 20px 64px; }
.profile h1 { margin-bottom: 8px; }
.profile-sub { color: var(--ink-3); display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.cta { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 24px 0 16px; }
.actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.chip {
  min-height: var(--touch); padding: 0 18px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--panel); font: 600 0.95rem var(--font); color: var(--ink); cursor: pointer; touch-action: manipulation;
}
.chip.on { color: #fff; border-color: transparent; }
.chip.on.pendiente { background: var(--c-pendiente); color: var(--ink); }
.chip.on.visitado { background: var(--c-visitado); }
.chip.on.interesado { background: var(--c-interesado); }
.chip.on.volver { background: var(--c-volver); color: var(--ink); }
.chip.on.no_interesa { background: var(--c-no_interesa); }
.chip.on.firmado { background: var(--c-firmado); }
.chip.on.descartado { background: var(--c-descartado); }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 10px 16px; margin: 12px 0 0; }
.kv dt { color: var(--ink-3); font-size: 0.9rem; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.box { background: var(--sunken); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px; margin-top: 12px; }
.box a { overflow-wrap: anywhere; }
.box p { margin: 8px 0 0; }
.timeline { list-style: none; margin: 16px 0 0; padding: 0; }
.timeline li { border-left: 3px solid var(--line-strong); padding: 2px 0 16px 16px; margin-left: 4px; }
.timeline li.estado, .timeline li.contrato { border-color: var(--accent); }
.timeline .who { color: var(--ink-3); font-size: 0.82rem; }
.timeline .txt { white-space: pre-wrap; overflow-wrap: anywhere; }
.add-note { display: flex; gap: 12px; align-items: flex-end; margin-top: 12px; }
.add-note textarea { flex: 1; }

.overlay { position: fixed; inset: 0; z-index: 1000; background: var(--panel); display: flex; flex-direction: column; }
.overlay-bar {
  flex: none; display: flex; align-items: center; gap: 12px; background: var(--ink); color: #fff;
  padding: 6px 12px; padding-top: max(6px, env(safe-area-inset-top));
}
.overlay-bar .btn { min-height: 40px; background: #1d2939; color: #fff; border-color: #344054; padding: 0 16px; }
.overlay-bar .btn:hover { background: #344054; }
.overlay-title { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.demo-stage { flex: 1; min-height: 0; display: flex; justify-content: center; background: #0c0d10; }
#demo-frame { width: 100%; height: 100%; border: 0; background: #fff; }
.seg { display: inline-flex; border: 1px solid #344054; border-radius: var(--radius-md); overflow: hidden; }
.seg button {
  min-height: 40px; padding: 0 16px; border: 0; background: #1d2939; color: #fff;
  font: 600 0.95rem var(--font); cursor: pointer; touch-action: manipulation;
}
.seg button[aria-pressed="true"] { background: #fff; color: var(--ink); }
.sign-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; background: var(--ground); }
.sign-form { max-width: 760px; margin: 0 auto; padding: 24px 20px 48px; background: var(--panel); min-height: 100%; }
.sign-done { max-width: 600px; margin: 0 auto; padding: 40px 20px; text-align: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid2 .wide { grid-column: 1 / -1; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }
.form-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 24px; flex-wrap: wrap; }
.steps { display: flex; gap: 8px; list-style: none; padding: 0; margin: 0 0 24px; }
.steps li { flex: 1; text-align: center; padding: 10px 8px; border-radius: 999px; background: var(--sunken); color: var(--ink-3); font-weight: 600; font-size: 0.85rem; }
.steps li.on { background: var(--action); color: var(--on-action); }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin: 16px 0; }
.plan-card {
  display: flex; flex-direction: column; gap: 6px; text-align: left; padding: 16px; min-height: 160px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-lg); background: var(--panel); color: var(--ink);
  font: inherit; cursor: pointer; touch-action: manipulation;
}
.plan-card:hover { background: var(--action-soft); }
.plan-card.sel { border: 2px solid var(--action); background: var(--action-soft); padding: 15px; }
.plan-card strong { font-size: 1.08rem; }
.plan-card .price { font-weight: 700; color: var(--action); }
.plan-card .inc { margin-top: auto; padding-top: 8px; font-size: 0.85rem; font-weight: 600; color: var(--ok-ink); }
.field-error { display: block; min-height: 1.2em; color: var(--failed-ink); font-weight: 500; font-size: 0.82rem; margin-top: 4px; }
.sign-cta { display: flex; flex-direction: column; gap: 12px; align-items: stretch; margin-top: 24px; }
.sign-cta .btn { width: 100%; }
.pin-wrap { background: none; border: 0; }
.pin {
  display: flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 999px;
  border: 2px solid #fff; color: #fff; font: 700 13px/1 var(--font); box-shadow: 0 1px 4px rgba(16, 24, 40, 0.5);
}
.pin.small { width: 14px; height: 14px; }

dialog { border: 0; border-radius: var(--radius-xl); padding: 0; width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 24px); color: var(--ink); }
dialog::backdrop { background: rgba(16, 24, 40, 0.55); }
.dlg-body { padding: 24px; }
.dlg-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 20px; }

.toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 14px 20px; border-radius: var(--radius-md); z-index: 3000;
  max-width: calc(100vw - 32px);
}
.toast.err { background: var(--failed-ink); }

@media (min-width: 601px) {
  .demo-stage { padding: 16px 0; }
  #demo-frame { width: 390px; max-width: 100%; border-radius: 28px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55); }
}
@media (min-width: 900px) {
  .list-screen { flex-direction: row-reverse; align-items: flex-start; }
  .map-col { position: sticky; top: 62px; flex: 1 1 52%; height: calc(100vh - 62px); border-bottom: 0; border-left: 1px solid var(--line); }
  .list-col { flex: 0 0 48%; max-width: 640px; }
  .filters { position: sticky; top: 62px; z-index: 10; }
}
@media (max-width: 640px) {
  .filter-row:last-of-type { grid-template-columns: 1fr 1fr; }
  .filter-row:last-of-type a { grid-column: 1 / -1; }
  .cta { grid-template-columns: 1fr; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 100px 1fr; }
  .profile h1 { font-size: 1.45rem; }
  .overlay-bar { flex-wrap: wrap; }
}
