/* =========================================================
   Panel de Clientes — Mortgage by Monika
   Paleta de marca: azul marino + dorado
   ========================================================= */

:root {
  --navy: #0a192f;
  --navy-2: #112240;
  --navy-3: #1b3157;
  --gold: #c5a059;
  --gold-dark: #b08d4b;
  --gold-soft: #f6efdf;
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1d1d1f;
  --muted: #6b7280;
  --border: #e5e7eb;
  --ok: #1f7a4d;
  --ok-bg: #e7f5ee;
  --err: #b3261e;
  --err-bg: #fdecea;
  --warn: #9a6a00;
  --warn-bg: #fdf3e0;
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow: 0 8px 30px -12px rgba(10, 25, 47, .25);
  --font: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-title: 'Playfair Display', Georgia, serif;
}

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

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ---------------- Login ---------------- */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1100px 600px at 15% -10%, #16305a 0%, transparent 60%),
    radial-gradient(900px 500px at 110% 110%, #1b3157 0%, transparent 55%),
    var(--navy);
}

.login-wrap { width: 100%; max-width: 430px; }

.login-card {
  background: var(--card);
  border-radius: 18px;
  padding: 40px 36px 32px;
  box-shadow: 0 30px 70px -30px rgba(0, 0, 0, .6);
}

.login-brand { text-align: center; margin-bottom: 26px; }

.login-logo {
  width: 54px; height: 54px;
  margin: 0 auto 14px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-3) 100%);
  display: flex; align-items: center; justify-content: center;
}

.logo-dot {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 5px rgba(197, 160, 89, .22);
  display: inline-block;
}

.login-brand h1 {
  font-family: var(--font-title);
  font-size: 1.5rem;
  color: var(--navy);
  letter-spacing: .2px;
}

.login-brand p { font-size: .78rem; color: var(--muted); margin-top: 4px; letter-spacing: .3px; }

.login-card h2 {
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 6px;
}

.login-hint { font-size: .82rem; color: var(--muted); margin-bottom: 20px; }

.login-foot {
  margin-top: 22px;
  text-align: center;
  font-size: .75rem;
  color: var(--muted);
}
.login-foot a { color: var(--gold-dark); text-decoration: none; }
.login-foot a:hover { text-decoration: underline; }

/* ---------------- Campos y botones ---------------- */

.field { display: block; margin-bottom: 16px; }

.field span {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 6px;
  letter-spacing: .2px;
}

.field input,
.search input,
textarea {
  width: 100%;
  padding: 12px 14px;
  font-family: inherit;
  font-size: .9rem;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 9px;
  transition: border-color .2s, box-shadow .2s;
}

.field input:focus,
.search input:focus,
textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(197, 160, 89, .18);
}

.btn-primary, .btn-dark, .btn-ghost, .btn-outline, .btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: .84rem;
  font-weight: 600;
  padding: 11px 18px;
  border-radius: 9px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all .18s ease;
  white-space: nowrap;
}

.btn-primary { background: var(--gold); color: #fff; box-shadow: 0 6px 18px -8px rgba(197, 160, 89, .9); }
.btn-primary:hover { background: var(--gold-dark); transform: translateY(-1px); }

.btn-dark { background: var(--navy); color: #fff; }
.btn-dark:hover { background: var(--navy-2); }

.btn-ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.btn-ghost:hover { color: var(--navy); border-color: #cbd5e1; background: #fff; }

.btn-outline { background: transparent; color: var(--navy); border-color: rgba(10, 25, 47, .25); }
.btn-outline:hover { background: var(--navy); color: #fff; }

.btn-danger { background: transparent; color: var(--err); border-color: #f2c6c2; }
.btn-danger:hover { background: var(--err); color: #fff; border-color: var(--err); }

.btn-block { width: 100%; margin-top: 6px; padding: 13px 18px; }

/* ---------------- Avisos ---------------- */

.alert {
  padding: 11px 14px;
  border-radius: 9px;
  font-size: .84rem;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.alert-error { background: var(--err-bg); color: var(--err); border-color: #f6d2ce; }
.alert-ok { background: var(--ok-bg); color: var(--ok); border-color: #c6e7d5; }

/* ---------------- Layout app ---------------- */

.topbar {
  background: var(--navy);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 4px 20px -10px rgba(10, 25, 47, .8);
}

.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.topbar-brand { display: flex; align-items: center; gap: 12px; }
.topbar-brand strong { display: block; font-size: .95rem; letter-spacing: .2px; }
.topbar-brand small { display: block; font-size: .7rem; color: rgba(255, 255, 255, .55); letter-spacing: .4px; text-transform: uppercase; }

.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.topbar-actions .btn-ghost { color: rgba(255, 255, 255, .8); border-color: rgba(255, 255, 255, .22); }
.topbar-actions .btn-ghost:hover { background: rgba(255, 255, 255, .1); color: #fff; border-color: rgba(255, 255, 255, .4); }
.topbar-actions .btn-outline { color: #fff; border-color: rgba(255, 255, 255, .3); }
.topbar-actions .btn-outline:hover { background: #fff; color: var(--navy); }

.topbar-user {
  font-size: .78rem;
  color: rgba(255, 255, 255, .65);
  padding-left: 10px;
  border-left: 1px solid rgba(255, 255, 255, .18);
}

.container { max-width: 1280px; margin: 0 auto; padding: 26px 24px 60px; }

/* ---------------- KPIs ---------------- */

.kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.kpi {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.kpi::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 3px;
  background: var(--border);
}

.kpi-accent::after { background: var(--gold); }

.kpi-label {
  display: block;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted);
  margin-bottom: 8px;
}

.kpi-value {
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--navy);
  line-height: 1;
  font-family: var(--font-title);
}
.kpi-value em { font-size: 1rem; font-style: normal; color: var(--muted); margin-left: 2px; }

/* ---------------- Panel y tabla ---------------- */

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.panel-narrow { max-width: 520px; padding: 28px; }
.panel-title { font-family: var(--font-title); color: var(--navy); font-size: 1.25rem; margin-bottom: 6px; }

.panel-toolbar {
  padding: 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.search { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.search input { max-width: 380px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 500;
  color: var(--muted);
  background: #f1f3f7;
  border: 1px solid transparent;
  text-decoration: none;
  transition: all .15s;
}
.chip b { font-weight: 700; color: var(--navy); }
.chip:hover { background: #e8ecf3; }
.chip-on { background: var(--navy); color: #fff; border-color: var(--navy); }
.chip-on b { color: var(--gold); }

.table-scroll { overflow-x: auto; }

.leads-table { width: 100%; border-collapse: collapse; font-size: .85rem; }

.leads-table thead th {
  text-align: left;
  font-size: .69rem;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted);
  padding: 12px 16px;
  background: #fafbfd;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.leads-table tbody td {
  padding: 16px 16px;
  border-bottom: 1px solid #f1f3f7;
  vertical-align: top;
}

.lead-row { cursor: pointer; transition: background .15s; }
.lead-row:hover { background: #fbfcfe; }

.cell-date { white-space: nowrap; color: var(--muted); font-size: .8rem; }

.lead-name { display: block; font-weight: 600; color: var(--navy); }
.lead-src { display: block; font-size: .7rem; color: var(--muted); margin-top: 3px; text-transform: uppercase; letter-spacing: .4px; }

.cell-contact a { display: block; color: var(--navy-3); text-decoration: none; }
.cell-contact a:hover { text-decoration: underline; }
.cell-contact span { display: block; color: var(--muted); font-size: .8rem; margin-top: 2px; }

.cell-purpose { max-width: 260px; color: #374151; }

.status-select {
  font-family: inherit;
  font-size: .78rem;
  font-weight: 600;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
}
.status-nuevo { color: var(--navy); border-color: #cdd8e8; background: #f3f7ff; }
.status-contactado { color: var(--warn); border-color: #f0dcb4; background: var(--warn-bg); }
.status-proceso { color: #7a4a00; border-color: #ecd9ae; background: #fdf0dc; }
.status-cerrado { color: var(--ok); border-color: #c6e7d5; background: var(--ok-bg); }
.status-perdido { color: var(--err); border-color: #f6d2ce; background: var(--err-bg); }

.empty { padding: 60px 24px; text-align: center; color: var(--muted); }
.empty .muted { font-size: .82rem; margin-top: 6px; }

.muted { color: var(--muted); }

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  font-size: .8rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

/* ---------------- Drawer ---------------- */

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 25, 47, .45);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s;
  z-index: 100;
}
.drawer-overlay.open { opacity: 1; pointer-events: auto; }

.drawer {
  position: absolute;
  top: 0; right: 0;
  height: 100%;
  width: min(460px, 100%);
  background: #fff;
  box-shadow: -20px 0 60px -25px rgba(0, 0, 0, .5);
  transform: translateX(100%);
  transition: transform .26s cubic-bezier(.4, 0, .2, 1);
  overflow-y: auto;
  padding: 28px;
}
.drawer-overlay.open .drawer { transform: translateX(0); }

.drawer-close {
  position: absolute;
  top: 14px; right: 16px;
  border: none;
  background: #f1f3f7;
  width: 34px; height: 34px;
  border-radius: 50%;
  font-size: 1.2rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}
.drawer-close:hover { background: #e5e9f0; color: var(--navy); }

.drawer h3 {
  font-family: var(--font-title);
  font-size: 1.3rem;
  color: var(--navy);
  margin-bottom: 4px;
  padding-right: 40px;
}

.drawer .sub { font-size: .78rem; color: var(--muted); margin-bottom: 20px; }

.detail-grid { display: grid; gap: 14px; margin-bottom: 22px; }

.detail-row { border-bottom: 1px dashed var(--border); padding-bottom: 12px; }
.detail-row dt { font-size: .68rem; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin-bottom: 4px; }
.detail-row dd { font-size: .9rem; color: var(--text); word-break: break-word; }
.detail-row dd a { color: var(--navy-3); }

.section-title {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--muted);
  margin: 22px 0 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.note-list { display: grid; gap: 10px; margin-bottom: 14px; }
.note {
  background: #fafbfd;
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold);
  border-radius: 8px;
  padding: 10px 12px;
}
.note p { font-size: .85rem; }
.note time { font-size: .68rem; color: var(--muted); }

.stack { display: grid; gap: 14px; }
.actions-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; }

/* ---------------- Toast ---------------- */

.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translate(-50%, 20px);
  background: var(--navy);
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: .85rem;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: all .25s;
  z-index: 300;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.toast-error { background: var(--err); }

/* ---------------- Responsive ---------------- */

@media (max-width: 1080px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .container { padding: 18px 14px 50px; }
  .topbar-inner { padding: 12px 14px; }
  .topbar-user { display: none; }
  .cell-purpose { max-width: 150px; }
  .panel-toolbar { padding: 14px; }
  .login-card { padding: 30px 22px 24px; }
}

/* =========================================================
   AMPLIACIÓN: menú lateral, interés y registro de clientes
   ========================================================= */

/* ---------- Estructura: contenido + menú derecho ---------- */
.app-shell {
  max-width: 1400px;
  margin: 0 auto;
  padding: 26px 24px 60px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 264px;
  gap: 24px;
  align-items: start;
}

.app-main { min-width: 0; }

/* El menú tiene su propio scroll */
.app-side {
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 116px);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.side-scroll {
  max-height: calc(100vh - 118px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 14px 18px;
  scrollbar-width: thin;
}

.side-scroll::-webkit-scrollbar { width: 7px; }
.side-scroll::-webkit-scrollbar-thumb { background: #d7dde6; border-radius: 8px; }
.side-scroll::-webkit-scrollbar-thumb:hover { background: #c2cad6; }

.side-group {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--muted);
  font-weight: 600;
  margin: 14px 6px 8px;
}
.side-group:first-child { margin-top: 0; }

.side-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  color: #3f4a5a;
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.side-link:hover { background: #f5f7fa; color: var(--navy); }
.side-link b {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--navy);
  background: #f1f4f8;
  border-radius: 999px;
  padding: 2px 8px;
  min-width: 24px;
  text-align: center;
}
.side-link.on {
  background: #f3f7ff;
  color: var(--navy);
  font-weight: 600;
  border-left-color: var(--gold);
}
.side-link.on b { background: var(--navy); color: var(--gold); }

.side-link.l-caliente { border-left-color: transparent; }
.side-link.l-caliente .dot { display: none; }

.side-action {
  width: 100%;
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px dashed rgba(197, 160, 89, 0.75);
  border-radius: 9px;
  background: #fdf8ee;
  color: #8a6c2c;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .18s ease;
}
.side-action:hover { background: var(--gold); border-color: var(--gold); color: #fff; }

.side-reset {
  display: block;
  margin: 16px 6px 0;
  font-size: 0.78rem;
  color: var(--muted);
  text-decoration: none;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.side-reset:hover { color: var(--navy); text-decoration: underline; }

/* ---------- Encabezado del panel ---------- */
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.panel-title { font-family: var(--font-title); color: var(--navy); font-size: 1.2rem; }

.btn-sm { padding: 9px 15px; font-size: 0.82rem; }

/* ---------- Etiquetas ---------- */
.lead-badges { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.tag {
  font-style: normal;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
  line-height: 1.5;
}
.tag-cliente { background: #e7f5ee; color: #1f7a4d; border-color: #c6e7d5; }
.tag-solicitud { background: #eef2fb; color: #2f4a7a; border-color: #d3ddf2; }
.tag-src { background: #f4f6f9; color: #6b7280; border-color: #e5e7eb; }

/* ---------- Selector de interés ---------- */
.temp-select {
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
}
.temp-none { color: #8a94a3; }
.temp-caliente { color: #b3261e; border-color: #f6d2ce; background: #fdecea; }
.temp-tibio { color: #9a6a00; border-color: #f0dcb4; background: #fdf3e0; }
.temp-frio { color: #2f4a7a; border-color: #d3ddf2; background: #eef2fb; }

/* ---------- Filtros activos ---------- */
.active-filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.af-label { font-size: 0.75rem; color: var(--muted); }
.af-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--navy);
  background: #f3f7ff;
  border: 1px solid #d3ddf2;
  border-radius: 999px;
  padding: 5px 11px;
  text-decoration: none;
}
.af-chip:hover { background: #e8eefc; }
.af-chip i { font-size: 0.7rem; color: #6b7280; }

/* ---------- Modal de registro ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 2500;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(6, 16, 32, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }

.modal-box {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 16px;
  border-top: 5px solid var(--gold);
  padding: 30px 28px 26px;
  box-shadow: 0 30px 70px -30px rgba(0, 0, 0, 0.7);
  animation: modalUp .3s cubic-bezier(.2, .8, .3, 1) both;
}
@keyframes modalUp { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }

.modal-close {
  position: absolute;
  top: 12px; right: 14px;
  width: 34px; height: 34px;
  border: none; border-radius: 50%;
  background: #f1f3f7; color: var(--muted);
  font-size: 1.25rem; line-height: 1; cursor: pointer;
}
.modal-close:hover { background: #e5e9f0; color: var(--navy); }

.modal-title { font-family: var(--font-title); font-size: 1.35rem; color: var(--navy); margin-bottom: 4px; }
.modal-sub { font-size: 0.82rem; color: var(--muted); margin-bottom: 20px; }

.fg { margin-bottom: 14px; min-width: 0; }
.fg label { display: block; font-size: 0.75rem; font-weight: 600; color: var(--navy); margin-bottom: 6px; }
.fg input, .fg select, .fg textarea {
  width: 100%;
  padding: 11px 13px;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 9px;
  transition: border-color .2s, box-shadow .2s;
}
.fg textarea { resize: vertical; min-height: 72px; }
.fg input:focus, .fg select:focus, .fg textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(197, 160, 89, 0.18);
}

.fg-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.modal-actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.modal-actions .btn-primary { flex: 1 1 auto; }

/* ---------- Drawer: interés y acciones extra ---------- */
.drawer-btns { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .app-side {
    position: static;
    max-height: none;
    order: -1;
  }
  .side-scroll { max-height: none; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 14px; }
  .side-group { width: 100%; margin: 8px 0 2px; }
  .side-link { border-left: none; border: 1px solid var(--border); }
  .side-link.on { border-color: var(--gold); }
  .side-action { width: auto; margin: 8px 0 0; }
  .side-reset { width: 100%; margin-top: 12px; }
}

@media (max-width: 680px) {
  .app-shell { padding: 16px 14px 50px; gap: 16px; }
  .fg-row { grid-template-columns: 1fr; gap: 0; }
  .modal-box { padding: 26px 18px 22px; }
  .panel-heading .btn-sm span { display: none; }
}

/* =========================================================
   EDITOR DE CONTENIDO
   ========================================================= */

.editor-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.editor-title { font-family: var(--font-title); font-size: 1.7rem; color: var(--navy); margin-bottom: 4px; }
.editor-sub { font-size: 0.85rem; color: var(--muted); }
.editor-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.editor-notice {
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 0.86rem;
  font-weight: 600;
  margin-bottom: 18px;
  border: 1px solid transparent;
}
.editor-notice.ok { background: var(--ok-bg); color: var(--ok); border-color: #c6e7d5; }
.editor-notice.err { background: var(--err-bg); color: var(--err); border-color: #f6d2ce; }

.ed-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
  overflow: hidden;
  scroll-margin-top: 96px;
}

.ed-card-head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 15px 20px;
  background: #fafbfd;
  border-bottom: 1px solid var(--border);
}
.ed-card-head i { color: var(--gold); font-size: 1rem; }
.ed-card-head h2 { font-size: 0.95rem; font-weight: 700; color: var(--navy); }

.ed-card-body { padding: 20px; display: grid; gap: 16px; }

.campo label { display: block; font-size: 0.76rem; font-weight: 600; color: var(--navy); margin-bottom: 6px; }
.campo input[type="text"],
.campo textarea {
  width: 100%;
  padding: 11px 13px;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 9px;
  transition: border-color .2s, box-shadow .2s;
}
.campo textarea { resize: vertical; line-height: 1.55; }
.campo input[type="text"]:focus,
.campo textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(197, 160, 89, 0.18); }

.campo-img .img-box {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: #fafbfd;
}
.img-preview {
  width: 132px;
  height: 86px;
  border-radius: 8px;
  overflow: hidden;
  background: #eef1f5;
  border: 1px solid var(--border);
  flex: 0 0 auto;
}
.img-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-side { flex: 1 1 auto; min-width: 200px; }

.file-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 9px;
  border: 1px dashed rgba(197, 160, 89, 0.8);
  background: #fdf8ee;
  color: #8a6c2c;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .18s ease;
}
.file-btn:hover { background: var(--gold); border-color: var(--gold); color: #fff; }
.file-btn input[type="file"] { display: none; }
.file-hint { font-size: 0.72rem; color: var(--muted); margin-top: 8px; }
.file-hint.ok { color: var(--ok); font-weight: 600; }
.file-hint.err { color: var(--err); font-weight: 600; }
.file-hint.subiendo { color: var(--gold-dark); font-weight: 600; }

.editor-foot { display: flex; justify-content: flex-end; padding: 6px 0 30px; }
.btn-lg { padding: 15px 30px; font-size: 0.95rem; }

@media (max-width: 680px) {
  .editor-title { font-size: 1.4rem; }
  .editor-actions { width: 100%; }
  .editor-actions .btn-primary,
  .editor-actions .btn-ghost { flex: 1 1 auto; justify-content: center; }
  .ed-card-body { padding: 16px; }
  .img-preview { width: 100%; height: 130px; }
}

/* =========================================================
   REFINAMIENTO DE DISEÑO
   Criterios tomados del referente Feralta:
   · paleta disciplinada (cada color con una sola función)
   · jerarquía tipográfica fuerte
   · mucho aire y ritmo constante
   · un solo sistema de componentes
   ========================================================= */

:root {
  --paper:      #f7f5f0;
  --card:       #ffffff;
  --line:       #e8e4dc;
  --line-soft:  #f1eee8;
  --ink:        #0a192f;
  --ink-soft:   #4a5568;
  --muted:      #767e8c;
  --gold:       #c5a059;
  --gold-deep:  #9c7c33;
  --gold-wash:  #fbf7ee;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;

  --sp-1: 8px;
  --sp-2: 14px;
  --sp-3: 22px;
  --sp-4: 34px;
  --sp-5: 52px;

  --shadow-1: 0 1px 2px rgba(10, 25, 47, .05);
  --shadow-2: 0 20px 45px -30px rgba(10, 25, 47, .35);
}

body.app-page {
  background: var(--paper);
  color: var(--ink);
}

/* --- Barra superior: más aire, menos ruido --- */
.topbar { background: var(--ink); box-shadow: none; }
.topbar-inner { padding: 18px 30px; max-width: 1440px; }
.topbar-brand strong { font-size: 1rem; letter-spacing: .2px; }
.topbar-brand small { letter-spacing: .9px; font-size: .66rem; }
.topbar-actions { gap: 8px; }
.topbar-user {
  font-size: .74rem;
  letter-spacing: .4px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .55);
  border-left-color: rgba(255, 255, 255, .14);
}

/* --- Un solo sistema de botones --- */
.btn-primary, .btn-dark, .btn-ghost, .btn-outline, .btn-danger {
  padding: 11px 18px;
  border-radius: 999px;
  font-size: .83rem;
  letter-spacing: .2px;
}
.btn-primary {
  background: var(--gold);
  color: #fff;
  box-shadow: none;
}
.btn-primary:hover { background: var(--gold-deep); transform: none; }
.btn-dark { background: var(--ink); }
.btn-dark:hover { background: #13294a; }
.btn-ghost { border-color: var(--line); background: transparent; }
.btn-ghost:hover { border-color: var(--ink); color: var(--ink); background: #fff; }
.btn-outline { border-color: rgba(255, 255, 255, .22); }
.btn-outline:hover { background: #fff; color: var(--ink); }

/* --- Estructura con más aire --- */
.app-shell {
  max-width: 1440px;
  padding: var(--sp-4) 30px 90px;
  gap: 30px;
  grid-template-columns: minmax(0, 1fr) 286px;
}
.app-side { border-color: var(--line); box-shadow: none; border-radius: var(--r-lg); }
.side-scroll { padding: 18px 12px 20px; }

.side-group {
  font-size: .62rem;
  letter-spacing: 1.1px;
  color: var(--muted);
  margin: 18px 10px 8px;
}
.side-link {
  padding: 10px 12px;
  border-radius: var(--r-sm);
  font-size: .845rem;
  color: var(--ink-soft);
  border-left: 2px solid transparent;
}
.side-link:hover { background: var(--line-soft); color: var(--ink); }
.side-link b {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: .7rem;
  padding: 1px 8px;
}
.side-link.on {
  background: var(--gold-wash);
  border-left-color: var(--gold);
  color: var(--ink);
}
.side-link.on b { background: var(--ink); border-color: var(--ink); color: var(--gold); }

.side-action {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 11px 14px;
  font-size: .82rem;
}
.side-action:hover { background: var(--ink); border-color: var(--ink); color: #fff; }
.side-reset { border-top-color: var(--line); margin-top: 20px; }

/* --- Tarjetas --- */
.panel, .ed-card {
  border-color: var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}
.panel-toolbar { padding: 24px 24px 20px; border-bottom-color: var(--line-soft); gap: 16px; }
.panel-title { font-size: 1.3rem; letter-spacing: -.2px; }

/* --- KPIs: menos cajas, más respiración --- */
.kpis { gap: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; margin-bottom: 26px; }
.kpi { border: none; border-right: 1px solid var(--line-soft); border-radius: 0; box-shadow: none; padding: 22px 22px 20px; }
.kpi:last-child { border-right: none; }
.kpi::after { display: none; }
.kpi-label { font-size: .64rem; letter-spacing: 1px; color: var(--muted); margin-bottom: 10px; }
.kpi-value { font-size: 1.85rem; letter-spacing: -.5px; }
.kpi-accent .kpi-value { color: var(--gold-deep); }

/* --- Tabla --- */
.leads-table thead th {
  font-size: .63rem;
  letter-spacing: 1px;
  color: var(--muted);
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 16px 20px;
}
.leads-table tbody td { padding: 18px 20px; border-bottom: 1px solid var(--line-soft); }
.lead-row:hover { background: #fcfbf8; }
.lead-name { font-size: .9rem; }
.tag { border-radius: 999px; font-size: .6rem; letter-spacing: .7px; padding: 3px 9px; }

/* --- Selectores discretos --- */
.status-select, .temp-select {
  border-color: var(--line);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: .75rem;
  background: #fff;
}

/* --- Chip de filtros --- */
.chip { border-radius: 999px; background: transparent; border: 1px solid var(--line); padding: 8px 14px; }
.chip:hover { background: var(--line-soft); }
.chip-on { background: var(--ink); border-color: var(--ink); }

/* =========================================================
   EDITOR DE CONTENIDO — estructura nueva
   ========================================================= */

.ed-bar {
  position: sticky;
  top: 74px;
  z-index: 40;
  background: rgba(247, 245, 240, .92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  margin: 0 -30px 34px;
  padding: 0 30px;
}
.ed-bar-in {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  padding: 18px 0;
}
.ed-bar h1 {
  font-family: var(--font-title);
  font-size: 1.65rem;
  color: var(--ink);
  letter-spacing: -.3px;
  line-height: 1.15;
}
.ed-bar p { font-size: .8rem; color: var(--muted); margin-top: 3px; }
.ed-bar-actions { display: flex; gap: 10px; }

.ed-notice {
  border-radius: var(--r-md);
  padding: 13px 18px;
  font-size: .84rem;
  font-weight: 600;
  margin-bottom: 26px;
  border: 1px solid transparent;
}
.ed-notice.ok { background: #f0f7f2; color: #1f7a4d; border-color: #d3e9dc; }
.ed-notice.err { background: #fdf1ef; color: #b3261e; border-color: #f3d5d1; }

.ed-sec {
  margin-bottom: 44px;
  scroll-margin-top: 170px;
}
.ed-sec-head {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding-bottom: 14px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--line);
}
.ed-num {
  font-family: var(--font-title);
  font-size: 1.05rem;
  color: var(--gold);
  letter-spacing: .5px;
  flex: 0 0 auto;
}
.ed-sec-head h2 {
  font-family: var(--font-title);
  font-size: 1.32rem;
  color: var(--ink);
  letter-spacing: -.2px;
  font-weight: 700;
}
.ed-sec-head span {
  margin-left: auto;
  font-size: .68rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
}

.ed-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 22px; }
.ed-grid .ancho { grid-column: 1 / -1; }

.ed-field label {
  display: block;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.ed-field input[type="text"],
.ed-field textarea {
  width: 100%;
  padding: 12px 14px;
  font-family: inherit;
  font-size: .9rem;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  transition: border-color .18s, box-shadow .18s;
}
.ed-field textarea { resize: vertical; line-height: 1.6; }
.ed-field input[type="text"]:focus,
.ed-field textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(197, 160, 89, .15);
}
.ed-tip { font-size: .7rem; color: var(--muted); margin-top: 7px; }

/* campos de imagen */
.ed-img {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px;
}
.ed-img-prev {
  width: 148px; height: 92px;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: #efece6;
  flex: 0 0 auto;
}
.ed-img-prev img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ed-img-side { flex: 1 1 210px; min-width: 190px; }

.ed-file {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 11px 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .18s ease;
}
.ed-file:hover { background: var(--ink); border-color: var(--ink); color: #fff; }
.ed-file input[type="file"] { display: none; }
.file-hint { font-size: .7rem; color: var(--muted); margin-top: 9px; }
.file-hint.ok { color: #1f7a4d; font-weight: 600; }
.file-hint.err { color: #b3261e; font-weight: 600; }
.file-hint.subiendo { color: var(--gold-deep); font-weight: 600; }

.ed-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 26px 0 40px;
  border-top: 1px solid var(--line);
}
.ed-foot p { font-size: .78rem; color: var(--muted); }

/* menú lateral del editor */
.ed-nav a {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  font-size: .83rem;
  color: var(--ink-soft);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: all .15s ease;
}
.ed-nav a:hover { background: var(--line-soft); color: var(--ink); }
.ed-nav a b {
  font-size: .66rem;
  color: var(--gold);
  font-weight: 700;
  flex: 0 0 auto;
  min-width: 16px;
  font-family: var(--font-title);
}

@media (max-width: 1080px) {
  .app-shell { padding: 22px 16px 70px; gap: 22px; }
  .ed-bar { position: static; margin: 0 0 26px; padding: 0; background: none; border: none; }
  .ed-bar-in { padding: 0; }
  .side-scroll { display: block; }
  .ed-nav { display: flex; flex-wrap: wrap; gap: 6px; }
  .ed-nav a { border: 1px solid var(--line); border-left-width: 1px; }
}

@media (max-width: 700px) {
  .ed-grid { grid-template-columns: minmax(0, 1fr); }
  .ed-bar h1 { font-size: 1.35rem; }
  .ed-bar-actions { width: 100%; }
  .ed-bar-actions .btn-primary, .ed-bar-actions .btn-ghost { flex: 1 1 auto; justify-content: center; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { border-right: none; border-bottom: 1px solid var(--line-soft); }
  .ed-img-prev { width: 100%; height: 150px; }
}

/* =========================================================
   MENÚ A LA IZQUIERDA + SUBMENÚ "EDITAR"
   ========================================================= */

.app-shell { grid-template-columns: 286px minmax(0, 1fr); }
.app-side { order: -1; }

/* Botón desplegable del menú */
.side-group-toggle {
  list-style: none;
  cursor: pointer;
}
.side-group-toggle::-webkit-details-marker { display: none; }
.side-group-toggle > summary { list-style: none; }

.side-parent {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  font-size: .845rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: all .15s ease;
}
.side-parent:hover { background: var(--line-soft); }
.side-parent i { font-size: .7rem; color: var(--gold); transition: transform .2s ease; }
details[open] > .side-parent { background: var(--gold-wash); border-left-color: var(--gold); }
details[open] > .side-parent i { transform: rotate(180deg); }

.side-sub {
  display: grid;
  gap: 1px;
  margin: 4px 0 8px 13px;
  padding-left: 13px;
  border-left: 1px solid var(--line);
}
.side-sub a {
  display: block;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: .79rem;
  color: var(--muted);
  text-decoration: none;
  transition: all .15s ease;
}
.side-sub a:hover { background: var(--line-soft); color: var(--ink); }

/* En móvil, el menú sigue arriba */
@media (max-width: 1080px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .app-side { order: -1; }
  .side-sub { display: flex; flex-wrap: wrap; gap: 6px; border-left: none; margin: 6px 0 0; padding-left: 0; }
  .side-sub a { border: 1px solid var(--line); }
}
