/* Housia.ar — estilos compartidos (tema + componentes + responsive) */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Dark theme (default) — un poco más aclarado que antes para sacarle el peso visual */
:root {
  --midnight: #0F1B2F;
  --navy:     #1A2B47;
  --navy-l:   #233B5D;
  --teal:     #2A7F7F;
  --teal-l:   #3AADAD;
  --teal-dim: rgba(42,127,127,0.15);
  --sand:     #C8A96E;
  --sand-dim: rgba(200,169,110,0.15);
  --cream:    #F5F0E8;
  --green:    #27AE60;
  --green-dim:rgba(39,174,96,0.15);
  --red:      #E5695D;
  --red-dim:  rgba(229,105,93,0.15);
  --purple:   #8B5CF6;
  --purple-dim:rgba(139,92,246,0.15);
  --text:     rgba(255,255,255,0.92);
  --muted:    rgba(255,255,255,0.55);
  --dim:      rgba(255,255,255,0.35);
  --border:   rgba(255,255,255,0.10);
  --card:     rgba(255,255,255,0.05);
  --card-h:   rgba(255,255,255,0.09);
  --input-bg: rgba(255,255,255,0.04);
  --shadow-card: 0 10px 24px rgba(0,0,0,0.35);
  --hover-tint: rgba(255,255,255,0.06);
  --pill-grey-bg: rgba(255,255,255,0.08);

  /* ── Glass (macOS Sonoma-like) ── */
  --glass-bg:         rgba(255,255,255,0.05);
  --glass-bg-strong:  rgba(255,255,255,0.09);
  --glass-bg-elev:    rgba(20,32,55,0.55);
  --glass-border:     rgba(255,255,255,0.12);
  --glass-highlight:  rgba(255,255,255,0.10);
  --glass-blur:       22px;
  --glass-sat:        180%;
  --glass-shadow:     0 10px 32px rgba(0,0,0,0.42), inset 0 1px 0 var(--glass-highlight);
  --glass-shadow-lg:  0 28px 64px rgba(0,0,0,0.55), inset 0 1px 0 var(--glass-highlight);
  --orb-1:            rgba(58,173,173,0.38);
  --orb-2:            rgba(200,169,110,0.30);
  --orb-3:            rgba(139,92,246,0.28);

  --sidebar-w: 210px;
}

/* Light theme — paleta cream/navy. Los acentos (teal/sand/green/red/purple) se mantienen
   para preservar identidad visual; ajustamos el fondo, el texto y las superficies. */
:root[data-theme="light"] {
  --midnight: #F4EFE5;
  --navy:     #ECE5D6;
  --navy-l:   #E2D8C4;
  --teal:     #1F6F6F;
  --teal-l:   #2A8B8B;
  --teal-dim: rgba(31,111,111,0.10);
  --sand:     #B8965D;
  --sand-dim: rgba(184,150,93,0.14);
  --cream:    #F5F0E8;
  --green:    #1F8E51;
  --green-dim:rgba(31,142,81,0.12);
  --red:      #C24B40;
  --red-dim:  rgba(194,75,64,0.10);
  --purple:   #6E4FE2;
  --purple-dim:rgba(110,79,226,0.10);
  --text:     #1A2740;
  --muted:    rgba(26,39,64,0.62);
  --dim:      rgba(26,39,64,0.40);
  --border:   rgba(26,39,64,0.12);
  --card:     rgba(255,255,255,0.62);
  --card-h:   rgba(255,255,255,0.82);
  --input-bg: rgba(255,255,255,0.78);
  --shadow-card: 0 6px 18px rgba(26,39,64,0.08);
  --hover-tint: rgba(26,39,64,0.05);
  --pill-grey-bg: rgba(26,39,64,0.07);

  /* ── Glass (light) ── */
  --glass-bg:         rgba(255,255,255,0.60);
  --glass-bg-strong:  rgba(255,255,255,0.82);
  --glass-bg-elev:    rgba(255,255,255,0.78);
  --glass-border:     rgba(26,39,64,0.10);
  --glass-highlight:  rgba(255,255,255,0.70);
  --glass-blur:       22px;
  --glass-sat:        160%;
  --glass-shadow:     0 8px 28px rgba(26,39,64,0.10), inset 0 1px 0 var(--glass-highlight);
  --glass-shadow-lg:  0 24px 56px rgba(26,39,64,0.15), inset 0 1px 0 var(--glass-highlight);
  --orb-1:            rgba(31,111,111,0.26);
  --orb-2:            rgba(184,150,93,0.28);
  --orb-3:            rgba(110,79,226,0.22);
}

/* Transición suave al alternar tema. Excluimos transforms para no romper animaciones existentes. */
html { color-scheme: dark; }
:root[data-theme="light"] { color-scheme: light; }
body, .card, .modal, .feat-card, .step, input, select, textarea, button {
  transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

/* ── Orbes de color difuminados detrás de todo (estilo macOS Sonoma) ─────────
   Fixed al viewport, sin pointer events, en z-index negativo respecto al body.
   El backdrop-filter de las cards/topbar/modales recoge estos colores y los
   blurrea, dando el efecto de vidrio teñido. */
body::before {
  content: '';
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(60% 50% at 12% 0%,   var(--orb-1) 0%, transparent 65%),
    radial-gradient(55% 45% at 100% 18%, var(--orb-2) 0%, transparent 65%),
    radial-gradient(70% 55% at 50% 105%, var(--orb-3) 0%, transparent 65%),
    radial-gradient(45% 40% at 90% 72%, var(--orb-1) 0%, transparent 70%);
  filter: saturate(125%);
}

/* ── AGENCY SWITCHER ── */
.agency-switcher { position: relative; margin: 0 0 14px; }
.as-trigger {
  display: flex; align-items: center; gap: 8px; width: 100%;
  background: var(--card); border: 1px solid var(--border); border-radius: 9px;
  padding: 8px 10px; cursor: pointer; color: var(--text); font: inherit;
  transition: background 0.15s;
}
.as-trigger:hover { background: var(--card-h); }
.as-mark { width: 22px; height: 22px; border-radius: 5px; background: linear-gradient(135deg, var(--teal), var(--sand)); color: var(--midnight); display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; flex-shrink: 0; font-family: 'Playfair Display', serif; }
.as-name { flex: 1; min-width: 0; font-size: 12px; font-weight: 500; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.as-caret { font-size: 10px; color: var(--muted); flex-shrink: 0; }
.as-popup {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px);
  background: var(--glass-bg-elev);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 4px; max-height: 240px; overflow-y: auto; z-index: 50;
  box-shadow: var(--glass-shadow-lg);
  display: none;
}
.agency-switcher.open .as-popup { display: block; }
.as-item { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 6px; cursor: pointer; font-size: 12px; color: var(--text); }
.as-item:hover { background: var(--hover-tint); }
.as-item.current { background: var(--teal); color: #fff; }
.as-item-role { font-size: 9.5px; color: var(--muted); margin-left: auto; text-transform: uppercase; letter-spacing: 0.06em; }
.as-item.current .as-item-role { color: rgba(255,255,255,0.7); }
.as-empty { padding: 10px; font-size: 11px; color: var(--muted); text-align: center; }
.platform-pill { font-size: 8.5px; letter-spacing: 0.08em; text-transform: uppercase; background: var(--sand-dim); color: var(--sand); padding: 1px 6px; border-radius: 8px; margin-left: 4px; font-weight: 600; }

/* ── MODAL ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.42); backdrop-filter: blur(10px) saturate(140%); -webkit-backdrop-filter: blur(10px) saturate(140%); display: none; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
:root[data-theme="light"] .modal-overlay { background: rgba(26,39,64,0.22); }
.modal-overlay.open { display: flex; }
.modal {
  display: block;
  background: var(--glass-bg-elev);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  box-shadow: var(--glass-shadow-lg);
  width: 100%; max-width: 560px; max-height: 90vh;
  overflow-y: auto; overflow-x: hidden;
  padding: 22px 24px;
  /* En flex containers (como .modal-overlay), un item con contenido grande puede
     querer crecer más allá del max-width. flex-shrink:1 + min-width:0 garantiza
     que respete max-width y no se desborde horizontalmente. */
  flex: 0 1 auto;
  min-width: 0;
}
.modal-hd { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; }
.modal-title { font-family: 'Playfair Display', serif; font-size: 18px; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--muted); font-size: 22px; cursor: pointer; line-height: 1; }
.modal-close:hover { color: var(--text); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 10.5px; color: var(--muted); margin-bottom: 4px; letter-spacing: 0.04em; text-transform: uppercase; }
.field input, .field select, .field textarea { width: 100%; background: var(--input-bg); border: 1px solid var(--glass-border); color: var(--text); border-radius: 9px; padding: 8px 10px; font-family: inherit; font-size: 13px; transition: border-color 0.15s, box-shadow 0.15s; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--teal-l); box-shadow: 0 0 0 3px var(--teal-dim); }
.modal-ft { display: flex; gap: 8px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); justify-content: flex-end; }
.btn { background: var(--glass-bg-strong); backdrop-filter: blur(12px) saturate(160%); -webkit-backdrop-filter: blur(12px) saturate(160%); border: 1px solid var(--glass-border); color: var(--text); padding: 8px 16px; border-radius: 10px; font-family: inherit; font-size: 12.5px; cursor: pointer; transition: background 0.15s, border-color 0.15s, transform 0.12s; box-shadow: inset 0 1px 0 var(--glass-highlight); }
.btn:hover { background: var(--card-h); border-color: var(--glass-highlight); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: linear-gradient(180deg, var(--teal-l), var(--teal)); border-color: rgba(255,255,255,0.18); color: #fff; box-shadow: 0 6px 18px rgba(42,127,127,0.35), inset 0 1px 0 rgba(255,255,255,0.25); }
.btn-primary:hover { background: linear-gradient(180deg, var(--teal-l), var(--teal-l)); border-color: rgba(255,255,255,0.25); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.form-err { color: var(--red); font-size: 11px; min-height: 14px; }

/* Stats de visitas en la cabecera del modal de propiedad */
.prop-stat { display: inline-flex; align-items: baseline; gap: 5px; background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 6px 11px; font-size: 12px; color: var(--text); }
.prop-stat strong { font-size: 14px; font-weight: 600; font-family: 'Playfair Display', serif; color: var(--teal-l); }
.prop-stat .ps-icon { color: var(--muted); }
.prop-stat .ps-lb   { color: var(--muted); font-size: 11px; }

/* Visibilidad del sitio público (configuración) — 3 radios estilo card */
.vis-opt { cursor: pointer; position: relative; }
.vis-opt input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.vis-opt .vis-card {
  background: var(--card); border: 1.5px solid var(--border); border-radius: 10px;
  padding: 12px 14px; transition: all 0.15s; height: 100%;
}
.vis-opt:hover .vis-card { background: var(--card-h); border-color: var(--muted); }
.vis-opt input:checked + .vis-card { border-color: var(--teal-l); background: var(--teal-dim); box-shadow: inset 0 0 0 1px var(--teal-l); }
.vis-opt .vis-icon  { font-size: 20px; margin-bottom: 6px; }
.vis-opt .vis-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 3px; }
.vis-opt .vis-desc  { font-size: 11px; color: var(--muted); line-height: 1.4; }
@media (max-width: 640px) {
  .vis-grid { grid-template-columns: 1fr !important; }
}

/* Panel "✨ IA" del modal de propiedad (narrativas) */
.ai-panel { padding: 4px 0; }
.ai-empty { text-align: center; padding: 30px 18px; background: var(--card); border: 1px dashed var(--border); border-radius: 12px; }
.ai-tabs { display: flex; gap: 4px; align-items: center; border-bottom: 1px solid var(--border); margin-bottom: 14px; padding-bottom: 8px; flex-wrap: wrap; }
.ai-tab { background: transparent; border: 1px solid transparent; color: var(--muted); padding: 6px 12px; font: inherit; font-size: 12px; border-radius: 7px; cursor: pointer; transition: all 0.15s; }
.ai-tab:hover { color: var(--text); background: var(--card); }
.ai-tab.active { background: var(--teal-dim); color: var(--teal-l); border-color: rgba(58,173,173,0.3); }
.ai-text { background: var(--glass-bg); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid var(--glass-border); border-radius: 12px; padding: 14px 16px; font-size: 13px; line-height: 1.7; color: var(--text); white-space: pre-wrap; max-height: 320px; overflow-y: auto; }
.ai-meta { font-size: 10.5px; color: var(--muted); margin-top: 8px; display: flex; gap: 12px; flex-wrap: wrap; }
.ai-actions { display: flex; gap: 8px; margin-top: 12px; justify-content: flex-end; flex-wrap: wrap; }

/* Autocomplete de dirección (Nominatim/OSM) */
.addr-ac { position: relative; }
.addr-ac-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px);
  background: var(--glass-bg-elev);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  max-height: 240px; overflow-y: auto; z-index: 60;
  box-shadow: var(--glass-shadow-lg);
}
.addr-ac-item { padding: 8px 10px; cursor: pointer; font-size: 12.5px; color: var(--text); border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; line-height: 1.3; }
.addr-ac-item:last-child { border-bottom: none; }
.addr-ac-item:hover, .addr-ac-item.active { background: var(--teal-dim); }
.addr-ac-item .ac-main { font-weight: 500; }
.addr-ac-item .ac-sub  { font-size: 10.5px; color: var(--muted); }
.addr-ac-status { padding: 10px 12px; font-size: 11.5px; color: var(--muted); text-align: center; }

/* Calendario de visitas */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-head { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; padding: 6px 4px; text-align: center; }
.cal-cell { background: var(--card); border: 1px solid var(--border); border-radius: 8px; min-height: 92px; padding: 6px 8px; cursor: pointer; transition: background 0.12s; display: flex; flex-direction: column; gap: 3px; }
.cal-cell:hover { background: var(--card-h); }
.cal-cell.other-month { opacity: 0.35; }
.cal-cell.today { border-color: var(--teal-l); }
.cal-cell.today .cal-day-num { color: var(--teal-l); font-weight: 700; }
.cal-day-num { font-size: 11.5px; color: var(--muted); margin-bottom: 2px; }
.cal-event { font-size: 10.5px; padding: 3px 6px; border-radius: 4px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.3; }
.cal-event:hover { filter: brightness(1.2); }
.cal-event.scheduled { background: var(--teal-dim); color: var(--teal-l); }
.cal-event.done { background: var(--green-dim); color: #5DD68A; }
.cal-event.no_show { background: var(--red-dim); color: var(--red); }
.cal-event.cancelled { background: var(--hover-tint); color: var(--muted); text-decoration: line-through; }
.cal-event-time { font-weight: 600; margin-right: 4px; }
.cal-more { font-size: 10px; color: var(--muted); padding: 2px 4px; cursor: pointer; }
.cal-more:hover { color: var(--text); }

@media (max-width: 700px) {
  .cal-cell { min-height: 64px; padding: 4px 5px; }
  .cal-event { padding: 1px 4px; font-size: 9.5px; }
  .cal-day-num { font-size: 10px; }
}

/* Timeline reutilizable */
.timeline-panel { position: relative; padding: 6px 0 6px 26px; max-height: 460px; overflow-y: auto; }
.timeline-panel::before { content: ''; position: absolute; left: 11px; top: 0; bottom: 0; width: 1px; background: var(--border); }
.tl-event { position: relative; padding: 8px 0 14px; }
.tl-event::before {
  content: ''; position: absolute; left: -19px; top: 12px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--bullet, var(--teal)); box-shadow: 0 0 0 3px var(--midnight);
}
.tl-event .tl-when { font-size: 10.5px; color: var(--muted); margin-bottom: 2px; }
.tl-event .tl-title { font-size: 12.5px; font-weight: 500; line-height: 1.4; }
.tl-event .tl-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.tl-event .tl-actor { font-size: 10.5px; color: var(--muted); margin-top: 2px; font-style: italic; }
.tl-event[data-kind="note"]                 { --bullet: var(--sand); }
.tl-event[data-kind="lead_received"]        { --bullet: var(--teal-l); }
.tl-event[data-kind="lead_first_response"]  { --bullet: var(--teal); }
.tl-event[data-kind="visit_scheduled"]      { --bullet: var(--purple); }
.tl-event[data-kind="visit_done"]           { --bullet: var(--green); }
.tl-event[data-kind="visit_noshow"]         { --bullet: var(--red); }
.tl-event[data-kind="visit_cancelled"]      { --bullet: var(--muted); }
.tl-event[data-kind="op_opened"]            { --bullet: var(--sand); }
.tl-event[data-kind="op_closed"]            { --bullet: #5DD68A; }
.tl-event[data-kind="rent_paid"]            { --bullet: #5DD68A; }
.tl-event[data-kind="photo_uploaded"]       { --bullet: var(--teal-l); }
.tl-event[data-kind="property_created"],
.tl-event[data-kind="client_created"]       { --bullet: var(--sand); }
.tl-event[data-kind="demand_created"]       { --bullet: var(--purple); }
.tl-empty { padding: 24px; text-align: center; font-size: 12.5px; color: var(--muted); }

/* Tabs de detalle (cliente, etc.) */
.cdet-panel { animation: fadeUp 0.18s ease; min-height: 200px; }

/* Galería de fotos en propiedades */
.photo-tile { position: relative; aspect-ratio: 4/3; background: var(--midnight); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; cursor: pointer; }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-tile.is-main { outline: 2px solid var(--sand); }
.photo-tile .photo-actions { position: absolute; top: 4px; right: 4px; display: flex; gap: 4px; opacity: 0; transition: opacity 0.15s; }
.photo-tile:hover .photo-actions { opacity: 1; }
.photo-tile .photo-actions button { background: rgba(0,0,0,0.65); border: none; color: #fff; font-size: 10px; padding: 4px 6px; border-radius: 4px; cursor: pointer; backdrop-filter: blur(4px); }
.photo-tile .photo-actions button:hover { background: rgba(0,0,0,0.85); }
.photo-tile .main-pill { position: absolute; bottom: 4px; left: 4px; font-size: 9px; background: var(--sand); color: var(--midnight); padding: 2px 6px; border-radius: 3px; font-weight: 600; }

/* Tabs internos del modal de propiedad */
.prop-tab-panel { animation: fadeUp 0.2s ease; }

/* ── Asistente AI de construcción de template ── */
.tpl-builder summary::-webkit-details-marker { display: none; }
.tpl-builder[open] .tpl-caret { transform: rotate(180deg); }
.tpl-builder-result {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  padding: 14px;
}
.tpl-builder-result .meta-row {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  font-size: 11.5px;
  margin-bottom: 10px;
}
.tpl-builder-result .meta-row .chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  background: var(--glass-bg-strong); border: 1px solid var(--glass-border);
  color: var(--muted);
}
.tpl-builder-result .meta-row .chip strong { color: var(--text); font-weight: 500; }
.tpl-builder-result .meta-row .swatch { width: 14px; height: 14px; border-radius: 4px; flex-shrink: 0; border: 1px solid var(--glass-border); }
.tpl-builder-result .code-box {
  position: relative;
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  margin-top: 8px;
  max-height: 360px; overflow: auto;
}
:root[data-theme="light"] .tpl-builder-result .code-box { background: rgba(26,39,64,0.06); }
.tpl-builder-result .code-box pre {
  margin: 0; padding: 12px 14px;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 11px; line-height: 1.55;
  color: var(--text);
  white-space: pre;
}
.tpl-builder-result .code-actions {
  display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; align-items: center;
}
.tpl-builder-result .notes {
  margin-top: 10px;
  font-size: 11.5px; line-height: 1.55;
  color: var(--muted);
  background: var(--sand-dim);
  border-left: 2px solid var(--sand);
  padding: 8px 10px;
  border-radius: 0 6px 6px 0;
  white-space: pre-wrap;
}

/* ── Selector de template público (Configuración → Inmobiliaria) ── */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-top: 6px; }
.tpl-card {
  position: relative; cursor: pointer;
  background: var(--glass-bg);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 0;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  overflow: hidden;
  box-shadow: inset 0 1px 0 var(--glass-highlight);
}
.tpl-card:hover { transform: translateY(-2px); border-color: var(--glass-highlight); }
.tpl-card.selected {
  border-color: var(--teal);
  box-shadow: 0 0 0 2px var(--teal-dim), inset 0 1px 0 var(--glass-highlight);
}
.tpl-card .tpl-preview {
  height: 88px;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  overflow: hidden;
}
.tpl-card .tpl-preview::before {
  content: ''; position: absolute; inset: 0;
  background: var(--tpl-bg, var(--card-h));
}
.tpl-card .tpl-preview::after {
  content: ''; position: absolute; left: 18%; right: 18%; top: 22%; bottom: 22%;
  background: var(--tpl-accent, var(--teal));
  border-radius: 4px;
  opacity: 0.55;
}
.tpl-card.selected .tpl-preview::after { opacity: 0.85; }
.tpl-card .tpl-body { padding: 10px 12px 12px; }
.tpl-card .tpl-name { font-size: 12.5px; font-weight: 600; margin-bottom: 3px; display: flex; align-items: center; gap: 6px; }
.tpl-card .tpl-name .tpl-check {
  width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--border);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 9px; color: transparent;
}
.tpl-card.selected .tpl-name .tpl-check {
  background: var(--teal); border-color: var(--teal); color: #fff;
}
.tpl-card.selected .tpl-name .tpl-check::before { content: '✓'; }
.tpl-card .tpl-desc { font-size: 10.5px; color: var(--muted); line-height: 1.4; }

/* ── Editor de imágenes (TUI Image Editor wrapper) ── */
.img-editor-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(8px) saturate(140%);
  -webkit-backdrop-filter: blur(8px) saturate(140%);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
:root[data-theme="light"] .img-editor-overlay { background: rgba(26,39,64,0.35); }
.img-editor-modal {
  width: 100%; max-width: 1280px; height: 100%; max-height: 92vh;
  background: var(--glass-bg-elev);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  box-shadow: var(--glass-shadow-lg);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.img-editor-hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
}
.img-editor-title { font-family: 'Playfair Display', serif; font-size: 16px; font-weight: 600; }
.img-editor-body { flex: 1; min-height: 0; position: relative; background: #1e1e1e; }
/* TUI usa su propio tema interno, no lo intervenimos */
@media (max-width: 700px) {
  .img-editor-overlay { padding: 10px; }
  .img-editor-modal { max-height: 96vh; border-radius: 12px; }
  .img-editor-title { font-size: 14px; }
}

/* ── Grilla de amenities (chips agrupados por categoría) ── */
.amenities-grid { display: flex; flex-direction: column; gap: 14px; margin-top: 4px; }
.amenity-group { display: flex; flex-direction: column; gap: 7px; }
.amenity-group-title { font-size: 10px; letter-spacing: 0.10em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding-left: 2px; }
.amenity-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.amenity-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 11px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px; font-weight: 500;
  cursor: pointer; user-select: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
  box-shadow: inset 0 1px 0 var(--glass-highlight);
}
.amenity-chip:hover { background: var(--glass-bg-strong); color: var(--text); border-color: var(--glass-highlight); }
.amenity-chip:active { transform: scale(0.97); }
.amenity-chip svg { width: 14px; height: 14px; flex-shrink: 0; stroke-width: 1.8; }
.amenity-chip.selected {
  background: var(--teal-dim);
  border-color: rgba(58,173,173,0.45);
  color: var(--teal-l);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.10), 0 0 0 1px rgba(58,173,173,0.15);
}
.amenity-chip.selected:hover { background: rgba(42,127,127,0.22); }
:root[data-theme="light"] .amenity-chip.selected { color: var(--teal); background: rgba(31,111,111,0.14); border-color: rgba(31,111,111,0.35); }

/* Lista de tareas */
.task-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.task-row:last-child { border-bottom: none; }
.task-row.completed .task-title { text-decoration: line-through; color: var(--muted); }
.task-checkbox { width: 16px; height: 16px; border-radius: 4px; border: 1.5px solid var(--border); cursor: pointer; flex-shrink: 0; display: flex; align-items: center; justify-content: center; background: transparent; }
.task-checkbox.checked { background: var(--teal); border-color: var(--teal); }
.task-checkbox.checked::after { content: '✓'; color: #fff; font-size: 11px; }
.task-title { font-size: 12.5px; font-weight: 500; }
.task-meta { font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.priority-pill { font-size: 9.5px; padding: 1px 5px; border-radius: 3px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.priority-pill.high   { background: var(--red-dim); color: var(--red); }
.priority-pill.medium { background: var(--sand-dim); color: var(--sand); }
.priority-pill.low    { background: var(--card-h); color: var(--muted); }

/* Notes panel reutilizable */
.notes-panel { background: var(--glass-bg); backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat)); -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat)); border: 1px solid var(--glass-border); border-radius: 14px; padding: 14px 16px; box-shadow: var(--glass-shadow); }
.notes-panel .notes-list { max-height: 240px; overflow-y: auto; margin-bottom: 10px; }
.notes-panel .note { background: var(--glass-bg-strong); border: 1px solid var(--glass-border); border-radius: 10px; padding: 8px 10px; font-size: 12px; margin-bottom: 8px; line-height: 1.5; }
.notes-panel .note-meta { font-size: 10.5px; color: var(--muted); margin-bottom: 3px; display: flex; justify-content: space-between; align-items: center; }
.notes-panel .note-del { background: none; border: none; color: var(--red); cursor: pointer; font-size: 11px; }
.notes-panel textarea { width: 100%; background: var(--input-bg); border: 1px solid var(--glass-border); color: var(--text); border-radius: 9px; padding: 8px 10px; font-family: inherit; font-size: 12.5px; resize: vertical; }
.notes-panel .add-row { display: flex; gap: 8px; margin-top: 8px; align-items: flex-start; }
.notes-panel .add-row textarea { flex: 1; }

/* Leaflet popup oscuro */
.leaflet-popup-content-wrapper { background: var(--navy); color: var(--text); border: 1px solid var(--border); }
.leaflet-popup-tip { background: var(--navy); }
.leaflet-container { background: var(--midnight); }

/* Filtros inline (selects/inputs en row de filtros) */
.field-inline { background: var(--input-bg); border: 1px solid var(--glass-border); color: var(--text); border-radius: 9px; padding: 7px 10px; font-family: inherit; font-size: 12px; transition: border-color 0.15s, box-shadow 0.15s; }
.field-inline:focus { outline: none; border-color: var(--teal-l); box-shadow: 0 0 0 3px var(--teal-dim); }

/* Botón "+ Nuevo" en cards */
.btn-add { background: var(--teal); color: #fff; border: none; padding: 6px 12px; border-radius: 7px; font-size: 12px; font-family: inherit; cursor: pointer; }
.btn-add:hover { background: var(--teal-l); }

@media (max-width: 600px) {
  .form-grid { grid-template-columns: 1fr; }
}


html { height: 100%; background: var(--midnight); color: var(--text); }
body { height: 100%; font-family: 'DM Sans', sans-serif; background: transparent; color: var(--text); font-size: 13px; overflow: hidden; }

/* ── SHELL ── */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100vh; }

/* ── SIDEBAR ── */
.sidebar {
  background: var(--glass-bg-elev);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  display: flex; flex-direction: column;
  padding: 22px 12px;
  border-right: 1px solid var(--glass-border);
  box-shadow: inset -1px 0 0 var(--glass-highlight);
  overflow-y: auto;
  min-width: 0;
}
.brand { display: flex; align-items: center; gap: 9px; margin-bottom: 28px; padding: 0 6px; }
.brand-mark { width: 30px; height: 30px; background: var(--sand); border-radius: 7px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.brand-mark span { font-family: 'Playfair Display', serif; font-size: 15px; font-weight: 700; color: var(--navy); }
.brand-name { font-family: 'Playfair Display', serif; font-size: 16px; font-weight: 700; color: var(--text); }
.brand-name em { color: var(--teal-l); font-style: normal; }

.nav-section-label { font-size: 9px; letter-spacing: 0.13em; text-transform: uppercase; color: var(--muted); padding: 0 10px; margin-bottom: 4px; margin-top: 16px; }
.nav-item { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 8px; color: var(--muted); cursor: pointer; transition: all 0.15s; margin-bottom: 1px; font-size: 12.5px; font-weight: 400; position: relative; }
.nav-item:hover { background: var(--card-h); color: var(--text); }
.nav-item.active { background: var(--teal); color: #fff; font-weight: 500; }
.nav-icon { font-size: 13px; opacity: 0.7; width: 16px; text-align: center; flex-shrink: 0; }
.nav-badge { margin-left: auto; background: var(--red); color: #fff; font-size: 9px; font-weight: 600; padding: 1px 5px; border-radius: 10px; }
.nav-badge.gold { background: var(--sand); color: var(--midnight); }

.sidebar-bottom { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); }
.user-row { display: flex; align-items: center; gap: 9px; padding: 9px; border-radius: 9px; background: var(--card); cursor: pointer; }
.user-row:hover { background: var(--card-h); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg,var(--teal),var(--sand)); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; color: #fff; flex-shrink: 0; }
.user-info .u-name { font-size: 12px; font-weight: 500; }
.user-info .u-role { font-size: 10px; color: var(--muted); }

/* Backdrop para drawer mobile (oculto en desktop) */
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 80; opacity: 0; transition: opacity 0.2s; }
.sidebar-backdrop.open { display: block; opacity: 1; }

/* ── MAIN ── */
.main { display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 26px;
  border-bottom: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  box-shadow: inset 0 1px 0 var(--glass-highlight);
  flex-shrink: 0; gap: 12px;
}
.tb-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tb-title { font-family: 'Playfair Display', serif; font-size: 19px; font-weight: 600; letter-spacing: -0.3px; }
.tb-sub { font-size: 11px; color: var(--muted); margin-top: 1px; }
.tb-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.menu-btn { display: none; width: 36px; height: 36px; border-radius: 8px; background: var(--card); border: 1px solid var(--border); color: var(--text); align-items: center; justify-content: center; cursor: pointer; font-size: 16px; flex-shrink: 0; }

.period-sel { display: flex; background: var(--card); border: 1px solid var(--border); border-radius: 7px; overflow: hidden; }
.period-sel span { padding: 5px 11px; font-size: 11px; color: var(--muted); cursor: pointer; transition: all 0.15s; }
.period-sel span.on { background: var(--teal); color: #fff; }
.icon-btn { width: 32px; height: 32px; border-radius: 7px; background: var(--card); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 14px; }
.notif-wrap { position: relative; }
.notif-wrap::after { content:''; position: absolute; top: 6px; right: 6px; width: 6px; height: 6px; background: var(--sand); border-radius: 50%; box-shadow: 0 0 0 2px var(--glass-bg-elev); }

/* ── CONTENT ── */
.content { flex: 1; overflow-y: auto; padding: 22px 26px 40px; display: flex; flex-direction: column; gap: 18px; }
.content::-webkit-scrollbar { width: 3px; }
.content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.view { display: none; flex-direction: column; gap: 18px; }
.view.active { display: flex; }

/* ── GRIDS ── */
.g4  { display: grid; grid-template-columns: repeat(4,1fr);    gap: 14px; }
.g3  { display: grid; grid-template-columns: repeat(3,1fr);    gap: 14px; }
.g2  { display: grid; grid-template-columns: 1fr 1fr;           gap: 14px; }
.g21 { display: grid; grid-template-columns: 1.7fr 1fr;         gap: 14px; }
.g12 { display: grid; grid-template-columns: 1fr 1.7fr;         gap: 14px; }
.g32 { display: grid; grid-template-columns: 1.5fr 1fr;         gap: 14px; }

/* ── KPI ── */
.kpi {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 17px 19px;
  position: relative; overflow: hidden;
  box-shadow: var(--glass-shadow);
  transition: background 0.18s, transform 0.18s, box-shadow 0.18s;
}
.kpi::before { content:''; position:absolute; top:0; left:0; right:0; height:2px; background: var(--kpi-color, var(--teal)); }
.kpi:hover { background: var(--glass-bg-strong); transform: translateY(-2px); box-shadow: var(--glass-shadow-lg); }
.kpi-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.kpi-label { font-size: 10.5px; color: var(--muted); line-height: 1.4; }
.kpi-icon { font-size: 15px; opacity: 0.55; }
.kpi-val { font-size: 25px; font-weight: 600; letter-spacing: -0.5px; line-height: 1; margin-bottom: 7px; }
.kpi-foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.badge { font-size: 10px; padding: 2px 6px; border-radius: 20px; font-weight: 500; }
.up   { background: var(--green-dim); color: #5DD68A; }
.dn   { background: var(--red-dim);   color: var(--red); }
.neu  { background: var(--sand-dim);  color: var(--sand); }
.kpi-note { font-size: 10.5px; color: var(--muted); }

/* ── CARD ── */
.card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 19px 21px;
  box-shadow: var(--glass-shadow);
}
.card-hd { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 15px; gap: 12px; flex-wrap: wrap; }
.card-title { font-size: 13.5px; font-weight: 500; margin-bottom: 2px; }
.card-sub { font-size: 11px; color: var(--muted); }
.card-link { font-size: 11px; color: var(--teal-l); cursor: pointer; white-space: nowrap; }
.placeholder { padding: 30px; text-align: center; color: var(--muted); font-size: 12.5px; line-height: 1.7; }
.placeholder strong { color: var(--text); }

/* ── TABLE ── */
.t-wrap { overflow-x: auto; }
.t { width: 100%; border-collapse: collapse; }
.t th { font-size: 10px; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); text-align: left; padding: 0 0 9px; border-bottom: 1px solid var(--border); font-weight: 400; white-space: nowrap; }
.t td { padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 12px; vertical-align: middle; }
.t td + td, .t th + th { padding-left: 10px; }
.t tr:last-child td { border-bottom: none; }
.t tr:hover td { color: var(--text); }
.t-name { font-weight: 500; margin-bottom: 1px; }
.t-sub  { font-size: 10.5px; color: var(--muted); }
.t-val  { font-weight: 600; color: var(--sand); white-space: nowrap; }

/* PILLS */
.pill { font-size: 10px; padding: 2px 8px; border-radius: 20px; font-weight: 500; white-space: nowrap; display: inline-block; }
.p-teal   { background: var(--teal-dim);   color: var(--teal-l); }
.p-sand   { background: var(--sand-dim);   color: var(--sand); }
.p-green  { background: var(--green-dim);  color: #5DD68A; }
.p-red    { background: var(--red-dim);    color: var(--red); }
.p-purple { background: var(--purple-dim); color: #A78BFA; }
.p-grey   { background: var(--pill-grey-bg); color: var(--muted); }

/* ── BAR CHART ── */
.bar-chart { display: flex; align-items: flex-end; gap: 7px; height: 110px; }
.bc-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; height: 100%; justify-content: flex-end; }
.bc-bars { width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 3px; height: 90px; }
.bc-bar { border-radius: 4px 4px 0 0; width: 45%; min-height: 4px; transition: opacity 0.2s; }
.bc-bar:hover { opacity: 0.8; }
.bc-lbl { font-size: 9.5px; color: var(--muted); }

/* ── FUNNEL ── */
.funnel-row { display: flex; align-items: center; gap: 9px; margin-bottom: 7px; }
.fn-lbl { font-size: 11px; color: var(--muted); width: 110px; flex-shrink: 0; line-height: 1.3; }
.fn-track { flex: 1; background: var(--border); border-radius: 4px; height: 22px; overflow: hidden; }
.fn-bar { height: 100%; border-radius: 4px; display: flex; align-items: center; padding-left: 8px; font-size: 10.5px; font-weight: 500; color: #fff; }
.fn-count { font-size: 11px; font-weight: 500; width: 28px; text-align: right; flex-shrink: 0; }

/* ── DONUT ── */
.donut-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.donut-rel { position: relative; width: 110px; height: 110px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
svg.donut { transform: rotate(-90deg); position: absolute; }
.donut-center { text-align: center; }
.donut-val { font-size: 20px; font-weight: 600; letter-spacing: -0.5px; }
.donut-lbl { font-size: 10px; color: var(--muted); }
.dl { display: flex; flex-direction: column; gap: 7px; flex: 1; min-width: 140px; }
.dl-row { display: flex; align-items: center; gap: 7px; }
.dl-dot { width: 7px; height: 7px; border-radius: 2px; flex-shrink: 0; }
.dl-name { flex: 1; font-size: 11.5px; color: var(--muted); }
.dl-pct { font-size: 11.5px; font-weight: 500; }

/* ── MINI STAT ── */
.mini {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 13px 15px; display: flex; align-items: center; gap: 11px;
  box-shadow: var(--glass-shadow);
}
.mini-ico { font-size: 18px; opacity: 0.7; }
.mini-val { font-size: 17px; font-weight: 600; letter-spacing: -0.4px; }
.mini-lbl { font-size: 10px; color: var(--muted); margin-top: 1px; }

/* ── AGENT ROW ── */
.ag-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.ag-row:last-child { border-bottom: none; }
.ag-av { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 600; flex-shrink: 0; color: #fff; }
.ag-name { font-size: 12px; font-weight: 500; }
.ag-meta { font-size: 10.5px; color: var(--muted); }
.ag-val { font-size: 12px; font-weight: 600; color: var(--sand); white-space: nowrap; margin-left: auto; }

/* ── ACTIVITY ── */
.act { display: flex; gap: 11px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.act:last-child { border-bottom: none; }
.act-line-wrap { display: flex; flex-direction: column; align-items: center; padding-top: 3px; }
.act-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.act-line { width: 1px; flex: 1; background: var(--border); margin-top: 3px; }
.act-title { font-size: 12px; font-weight: 500; margin-bottom: 2px; line-height: 1.4; }
.act-meta  { font-size: 10.5px; color: var(--muted); }

/* ── TIMELINE BAR ── */
.timeline-bar { display: flex; height: 40px; border-radius: 8px; overflow: hidden; gap: 2px; margin-bottom: 10px; }
.tl-seg { display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 500; border-radius: 6px; transition: flex 0.3s; padding: 0 4px; text-align: center; }

/* ── OPS TABS ── */
.ops-tabs { display:flex; gap:6px; margin-bottom:13px; flex-wrap: wrap; }
.ops-tab { display:flex; align-items:center; gap:6px; padding:6px 13px; border-radius:7px; border:1px solid var(--border); background:var(--card); color:var(--muted); cursor:pointer; font-size:12px; font-family:'DM Sans',sans-serif; transition:all 0.15s; }
.ops-tab.active { background: var(--glass-bg-strong); color:var(--text); border-color: var(--glass-highlight); box-shadow: inset 0 1px 0 var(--glass-highlight); }
.ops-tab:hover:not(.active) { background:var(--card-h); color:var(--text); }
.ops-tab-dot { width:7px; height:7px; border-radius:50%; flex-shrink:0; }
.ops-tab-count { font-size:10px; background:var(--pill-grey-bg); padding:1px 5px; border-radius:10px; margin-left:2px; }

/* ── PORTAL BADGE ── */
.portal-b { font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 4px; display: inline-block; }
.pz { background: rgba(0,122,255,0.18); color: #4DA3FF; }
.pa { background: rgba(255,149,0,0.18);  color: #FFB347; }
.pm { background: rgba(255,214,0,0.18);  color: #D4B800; }
.pr { background: rgba(192,57,43,0.18);  color: var(--red); }
.pi { background: var(--purple-dim); color: #A78BFA; }

.ppc-bar-wrap { position: relative; display: inline-flex; align-items: center; justify-content: center; min-width: 56px; height: 22px; }
.ppc-bar { position: absolute; left: 50%; transform: translateX(-50%); top: 0; bottom: 0; border-radius: 4px; opacity: 0.55; }
.ppc-bar-wrap span { position: relative; font-size: 11px; font-weight: 600; color: #fff; }

/* ── ANIMATIONS ── */
@keyframes fadeUp { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }
.view.active > * { animation: fadeUp 0.35s ease both; }
.view.active > *:nth-child(1) { animation-delay: 0.04s; }
.view.active > *:nth-child(2) { animation-delay: 0.09s; }
.view.active > *:nth-child(3) { animation-delay: 0.14s; }
.view.active > *:nth-child(4) { animation-delay: 0.19s; }
.view.active > *:nth-child(5) { animation-delay: 0.24s; }

/* ════════════════════════════════════════════════════════════════
   RESPONSIVE
   Breakpoints:
     ≥1100px  → desktop (default arriba)
     1100-900 → tablet wide  (g4 → 2col, g21/g12/g32 → 1col)
     900-700  → tablet
     ≤700px   → mobile (sidebar drawer, todo apilado)
   ════════════════════════════════════════════════════════════════ */

@media (max-width: 1099px) {
  .g4  { grid-template-columns: repeat(2, 1fr); }
  .g3  { grid-template-columns: repeat(2, 1fr); }
  .g21, .g12, .g32 { grid-template-columns: 1fr; }
}

@media (max-width: 899px) {
  .g3  { grid-template-columns: 1fr; }
  .g2  { grid-template-columns: 1fr; }
  .content { padding: 18px 18px 32px; gap: 14px; }
  .topbar { padding: 12px 18px; }
  .period-sel { display: none; }
}

@media (max-width: 699px) {
  :root { --sidebar-w: 0px; }
  body { overflow-y: auto; }
  html, body { height: auto; }
  .shell { display: block; height: auto; min-height: 100vh; }
  .main { height: auto; overflow: visible; }
  .content { overflow-y: visible; padding: 16px 14px 28px; gap: 12px; }

  /* Sidebar como drawer off-canvas — más opaca en mobile para legibilidad */
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 250px; max-width: 82vw;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    z-index: 90;
    background: var(--midnight);
    box-shadow: 8px 0 32px rgba(0,0,0,0.45), inset -1px 0 0 var(--glass-border);
  }
  :root[data-theme="light"] .sidebar { background: var(--navy); box-shadow: 8px 0 32px rgba(26,39,64,0.18), inset -1px 0 0 var(--glass-border); }
  .sidebar.open { transform: translateX(0); }

  .menu-btn { display: inline-flex; }

  .topbar { padding: 12px 14px; gap: 8px; }
  .tb-title { font-size: 16px; }
  .tb-sub { font-size: 10.5px; }
  .icon-btn { width: 30px; height: 30px; font-size: 13px; }

  .g4 { grid-template-columns: 1fr; }
  .kpi-val { font-size: 22px; }
  .card { padding: 16px 16px; }

  /* Tablas: scroll horizontal y reducir labels largos */
  .fn-lbl { width: 92px; font-size: 10.5px; }
  .bar-chart { height: 96px; }
  .bc-bars { height: 78px; }
}

@media (max-width: 420px) {
  .tb-title { font-size: 14.5px; }
  .kpi { padding: 14px 14px; }
  .card { padding: 14px 14px; }
  .ops-tab { padding: 5px 10px; font-size: 11px; }
  .funnel-row { gap: 6px; }
  .fn-lbl { width: 80px; font-size: 10px; }
}

/* ═══════════════ Vista Mapa ═══════════════ */
.map-shell {
  background: var(--navy);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 140px);
  min-height: 480px;
}
.map-controls {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--navy);
  align-items: center;
  flex-wrap: wrap;
}
.map-controls input,
.map-controls select {
  background: var(--input-bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
}
.map-controls input { flex: 1; min-width: 200px; }
.map-controls input:focus,
.map-controls select:focus { outline: none; border-color: var(--teal); }
.map-toggle {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted);
  cursor: pointer; user-select: none;
}
.map-count {
  font-size: 11.5px;
  color: var(--muted);
  margin-left: auto;
  white-space: nowrap;
}
.map-canvas {
  flex: 1;
  width: 100%;
  background: var(--midnight);
}
.map-empty {
  padding: 18px;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
  border-top: 1px solid var(--border);
}

/* Mini-mapa del resumen */
.mini-map {
  height: 220px;
  width: 100%;
  border-radius: 10px;
  overflow: hidden;
  background: var(--midnight);
  border: 1px solid var(--border);
}

/* Pin custom: propio (teal) vs ajeno (purple) */
.map-pin {
  width: 26px; height: 26px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
}
.map-pin::after {
  content: '';
  width: 8px; height: 8px;
  background: #fff;
  border-radius: 50%;
  display: block;
}
.map-pin.own     { background: var(--teal); }
.map-pin.foreign { background: var(--purple); }

/* Popup card */
.leaflet-popup-content-wrapper {
  background: var(--navy);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0;
}
.leaflet-popup-content { margin: 0; min-width: 240px; }
.leaflet-popup-tip { background: var(--navy); }
.leaflet-popup-close-button { color: var(--muted) !important; }
.map-popup {
  padding: 0;
  font-family: 'DM Sans', sans-serif;
}
.map-popup .pop-photo {
  width: 100%;
  height: 130px;
  background-size: cover;
  background-position: center;
  background-color: var(--midnight);
  border-radius: 9px 9px 0 0;
}
.map-popup .pop-body { padding: 12px 14px 14px; }
.map-popup .pop-badges { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 6px; }
.map-popup .pop-title { font-size: 13.5px; font-weight: 600; line-height: 1.3; margin-bottom: 4px; color: var(--text); }
.map-popup .pop-addr  { font-size: 11px; color: var(--muted); margin-bottom: 8px; }
.map-popup .pop-price { font-family: 'Playfair Display', serif; font-size: 17px; font-weight: 600; color: var(--sand); margin-bottom: 10px; }
.map-popup .pop-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.map-popup .pop-actions .btn { padding: 6px 12px; font-size: 11.5px; }

/* Context menu del mapa (click derecho sobre el canvas) */
.map-ctx-menu {
  position: absolute;
  z-index: 1000;
  background: var(--navy);
  border: 1px solid var(--border);
  border-radius: 9px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  padding: 4px;
  display: flex;
  flex-direction: column;
  min-width: 220px;
  overflow: hidden;
}
.map-ctx-menu[hidden] { display: none; }
.map-ctx-menu button {
  background: none;
  border: none;
  color: var(--text);
  text-align: left;
  padding: 9px 12px;
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.map-ctx-menu button:hover { background: var(--teal-dim); }

/* Autocomplete de geocoding en el control del mapa */
#map-geo-ac .addr-ac-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 1001;
}

/* Flash de feedback cuando se copia algo al clipboard */
.toast-flash {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(58,173,173,0.95);
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  z-index: 9999;
  pointer-events: none;
  box-shadow: 0 6px 18px rgba(0,0,0,0.3);
  animation: toastFlash 1.8s ease-out forwards;
}
@keyframes toastFlash {
  0%   { opacity: 0; transform: translate(-50%, 10px); }
  10%  { opacity: 1; transform: translate(-50%, 0); }
  80%  { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, -10px); }
}
