/* ===== Variables de tema ===== */
:root {
  --bg:        #eef2f7;   /* fondo general (gris muy claro) */
  --surface:   #ffffff;   /* paneles (blanco) */
  --surface-2: #f1f5f9;
  --border:    #e2e8f0;
  --text:      #1e293b;   /* texto oscuro */
  --muted:     #64748b;
  --primary:   #f59e0b;   /* ámbar: tono "construcción" */
  --primary-d: #d97706;
  --green:     #16a34a;
  --red:       #dc2626;
  --radius:    12px;
  --sidebar-w: 248px;
}

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

body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px;
  border-bottom: 1px solid var(--border);
}
.brand__logo { font-size: 26px; }
.brand__name { font-weight: 700; font-size: 17px; }
.brand__name span { color: var(--primary); }

.nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
  font-size: 15px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.nav__item:hover { background: var(--surface-2); color: var(--text); }
.nav__item.is-active { background: var(--primary); color: #1a1206; font-weight: 600; }

.sidebar__footer { padding: 14px; border-top: 1px solid var(--border); }
.user { display: flex; align-items: center; gap: 10px; }
.user__avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--primary); color: #1a1206;
  display: grid; place-items: center; font-weight: 700;
}
.user__info { display: flex; flex-direction: column; }
.user__info { flex: 1; }
.user__info small { color: var(--muted); font-size: 12px; }
.logout {
  background: transparent; border: 1px solid var(--border);
  color: var(--muted); border-radius: 8px; cursor: pointer;
  font-size: 15px; padding: 5px 9px; line-height: 1;
}
.logout:hover { background: var(--surface-2); color: var(--text); }

/* ===== Main ===== */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.topbar__title { font-size: 20px; }
.topbar__actions { display: flex; gap: 12px; align-items: center; }
.search {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 9px;
  font-size: 14px;
  width: 220px;
}
.search::placeholder { color: var(--muted); }

.btn {
  border: none; cursor: pointer; font-size: 14px; font-weight: 600;
  padding: 9px 16px; border-radius: 9px;
}
.btn--primary { background: var(--primary); color: #1a1206; }
.btn--primary:hover { background: var(--primary-d); }

/* ===== Vistas ===== */
.view { display: none; padding: 24px 28px; }
.view.is-active { display: block; }

/* Tarjetas de estadística */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: 0 1px 3px rgba(15,23,42,.05);
}
.card__label { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.card__value { font-size: 28px; font-weight: 700; }

/* Paneles */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 1px 3px rgba(15,23,42,.05);
}
.panel__title { font-size: 16px; margin-bottom: 16px; }

/* Tablas */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; color: var(--muted); font-weight: 600;
  padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13px;
}
.table td { padding: 12px; border-bottom: 1px solid var(--border); }
.table tbody tr:hover { background: var(--surface-2); }

/* Barra de avance */
.avance-list { display: flex; flex-direction: column; gap: 16px; }
.avance__row { }
.avance__top { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 14px; }
.avance__bar { background: var(--bg); border-radius: 6px; height: 10px; overflow: hidden; }
.avance__fill { height: 100%; background: var(--primary); border-radius: 6px; transition: width .4s; }

/* Etiquetas de estado */
.tag { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.tag--ok    { background: rgba(34,197,94,.15);  color: var(--green); }
.tag--warn  { background: rgba(245,158,11,.15); color: var(--primary); }
.tag--late  { background: rgba(239,68,68,.15);  color: var(--red); }

/* Botones de acción en las tablas (editar / borrar) */
.acciones { text-align: right; white-space: nowrap; }
.icon-btn {
  background: transparent; border: 1px solid var(--border);
  border-radius: 8px; cursor: pointer; font-size: 14px;
  padding: 5px 9px; margin-left: 6px; line-height: 1;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn--del:hover { background: rgba(239,68,68,.15); border-color: var(--red); }

/* Botón secundario (cancelar) */
.btn--ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn--ghost:hover { background: var(--surface-2); color: var(--text); }

/* ===== Portal del cliente ===== */
.portal-page { flex-direction: column; }
.portal-top {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.portal-top__brand { font-weight: 700; }
.portal-top__brand span { color: var(--primary); }
.portal-top__user { color: var(--muted); font-size: 14px; }

.portal { width: 100%; max-width: 720px; margin: 0 auto; padding: 28px 20px; }
.portal__title { font-size: 24px; }
.portal__title span { color: var(--primary); }
.portal__sub { color: var(--muted); margin: 6px 0 24px; }

.portal-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 22px; margin-bottom: 18px;
}
.portal-card__title { font-size: 16px; margin-bottom: 16px; }

.portal-unidad { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 16px; }
.portal-unidad .lbl { display: block; color: var(--muted); font-size: 12px; }
.portal-unidad .val { display: block; font-size: 16px; font-weight: 600; margin-top: 3px; }

.portal-hitos { list-style: none; margin-top: 18px; display: flex; flex-direction: column; gap: 10px; }
.portal-hitos li { font-size: 14px; color: var(--muted); }
.portal-hitos li.is-done { color: var(--text); }

.portal-saldo {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border);
}
.portal-saldo strong { font-size: 20px; color: var(--primary); }

/* ===== Login ===== */
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 32px;
}
.login-card__brand { text-align: center; margin-bottom: 26px; }
.login-card__logo { font-size: 40px; }
.login-card__brand h1 { font-size: 22px; margin-top: 6px; }
.login-card__brand h1 span { color: var(--primary); }
.login-card__sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-btn { width: 100%; padding: 12px; font-size: 15px; margin-top: 4px; }
.login-error { color: var(--red); font-size: 13px; min-height: 16px; margin: -6px 0 0; }
.login-card__foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 22px; }

/* ===== Modal ===== */
.modal { display: none; position: fixed; inset: 0; z-index: 50; }
.modal.is-open { display: block; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.55); }
.modal__box {
  position: relative;
  max-width: 460px;
  margin: 5vh auto;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(15,23,42,.18);
}
.modal__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface); z-index: 2;
}
.modal__title { font-size: 17px; }
.modal__close {
  background: transparent; border: none; color: var(--muted);
  font-size: 18px; cursor: pointer; line-height: 1;
}
.modal__close:hover { color: var(--text); }
.modal__foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 16px 22px; border-top: 1px solid var(--border);
  position: sticky; bottom: 0; background: var(--surface);
}

/* ===== Documentos ===== */
.docs-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.docs-nota { color: var(--muted); font-size: 12px; }
.pcard__docs {
  margin-top: 8px; background: transparent; border: 1px solid var(--border);
  color: var(--muted); border-radius: 7px; padding: 4px 9px; font-size: 12px; cursor: pointer;
}
.pcard__docs:hover { background: var(--bg); color: var(--text); }

/* Checkbox de tareas */
.chk { width: 17px; height: 17px; accent-color: var(--primary); cursor: pointer; }

/* ===== Ajustes ===== */
.perfil { display: flex; align-items: center; gap: 16px; }
.perfil__foto {
  width: 72px; height: 72px; border-radius: 50%; overflow: hidden;
  background: var(--primary); flex-shrink: 0; position: relative;
}
.perfil__foto img { width: 100%; height: 100%; object-fit: cover; display: none; }
.perfil__foto span {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: #1a1206; font-weight: 700; font-size: 26px;
}

.catalogo { list-style: none; display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.catalogo li {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 9px 14px; font-size: 14px;
}
.catalogo__add { display: flex; gap: 8px; }
.catalogo__add input {
  flex: 1; background: var(--bg); border: 1px solid var(--border); color: var(--text);
  padding: 9px 12px; border-radius: 9px; font-size: 14px;
}
.catalogo__add input:focus { outline: none; border-color: var(--primary); }

.integraciones { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.integ {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 14px;
}
.integ__icon { font-size: 24px; }
.integ__info { flex: 1; display: flex; flex-direction: column; }
.integ__info small { color: var(--muted); font-size: 12px; }

/* ===== Detalle de proyecto (página completa) ===== */
.pd-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.pd-head__title { display: flex; gap: 12px; align-items: flex-start; }
.pd-name { font-size: 22px; margin: 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pd-name .proy-badge { position: static; }
.pd-loc { color: var(--muted); font-size: 14px; margin-top: 4px; }
.pd-head__btns { display: flex; gap: 8px; }

.pd-top { display: grid; grid-template-columns: 1fr 320px; gap: 16px; margin-bottom: 16px; }
.pd-gal { height: 300px; border-radius: var(--radius); background: var(--surface-2); background-size: cover; background-position: center; position: relative; border: 1px solid var(--border); }
.pd-gal--empty { display: grid; place-items: center; color: var(--muted); }
.pd-gal--empty span { font-size: 44px; }
.pd-gal__nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,.9); border: 1px solid var(--border); width: 36px; height: 36px; border-radius: 50%; cursor: pointer; font-size: 18px; }
.pd-gal__prev { left: 12px; } .pd-gal__next { right: 12px; }
.pd-gal__count { position: absolute; bottom: 12px; right: 12px; background: rgba(15,23,42,.7); color: #fff; padding: 3px 10px; border-radius: 999px; font-size: 12px; }
.pd-resumen { padding: 18px 20px; }
.pd-rango__lbl { color: var(--muted); font-size: 13px; }
.pd-rango { font-size: 22px; font-weight: 700; margin-top: 4px; }
.pd-sep { height: 1px; background: var(--border); margin: 16px 0; }
.pd-sub2 { font-weight: 600; margin-bottom: 10px; }
.pd-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 14px; }
.pd-row span { color: var(--muted); }

.pd-banner { background: #2563eb; color: #fff; border-radius: var(--radius); padding: 16px 20px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; margin-bottom: 16px; }
.pd-banner div div { font-size: 13px; opacity: .9; }
.pd-banner span { font-size: 22px; }

.pd-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 16px; }
.pd-accion { display: block; width: 100%; text-align: left; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); border-radius: 9px; padding: 11px 14px; font-size: 14px; cursor: pointer; margin-bottom: 8px; }
.pd-accion:hover { border-color: var(--primary); }

.pd-reserva { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.switch { position: relative; display: inline-block; width: 46px; height: 26px; }
.switch input { display: none; }
.switch__sl { position: absolute; inset: 0; background: var(--border); border-radius: 999px; transition: .2s; }
.switch__sl::before { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .switch__sl { background: #dc2626; }
.switch input:checked + .switch__sl::before { transform: translateX(20px); }

.pd-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.pd-tab { background: transparent; border: none; border-bottom: 2px solid transparent; color: var(--muted); padding: 10px 14px; font-size: 14px; cursor: pointer; }
.pd-tab.is-active { color: var(--red); border-bottom-color: var(--red); font-weight: 600; }
.pd-meta { display: flex; justify-content: space-between; align-items: center; background: rgba(34,197,94,.08); border-color: rgba(34,197,94,.3); }
.pd-etapas { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.pd-etapa { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.pd-etapa__h { font-weight: 600; font-size: 14px; display: flex; justify-content: space-between; margin-bottom: 8px; }
.pd-etapa__h span { background: var(--bg); border-radius: 999px; padding: 1px 9px; font-size: 12px; }
.pd-etapa__u { font-size: 13px; padding: 5px 0; border-top: 1px solid var(--border); }
@media (max-width: 820px) { .pd-top { grid-template-columns: 1fr; } }

/* ===== Editor de proyecto (sub-página) ===== */
.editor-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; flex-wrap: wrap; gap: 12px;
}
.ep-textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: 9px; padding: 12px; font-size: 14px; font-family: inherit; resize: vertical; line-height: 1.5;
}
.ep-textarea:focus { outline: none; border-color: var(--primary); }

.planos-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.plano { position: relative; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.plano img { width: 100%; height: 140px; object-fit: cover; display: block; }
.plano__nom { padding: 9px 12px; font-size: 13px; }
.plano__del { position: absolute; top: 6px; right: 6px; background: rgba(15,23,42,.8); }
.plano--sel { outline: 3px solid var(--primary); cursor: pointer; }
.planos-grid .plano[data-render-toggle] { cursor: pointer; }

/* ===== Cotizaciones ===== */
.cotiz-form {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px; margin-bottom: 18px;
}
.cotiz-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

/* Documento (papel blanco) */
.cotizacion-doc {
  background: #fff; color: #1a1a1a; max-width: 720px; margin: 22px auto 0;
  padding: 44px 48px; border-radius: 8px; font-size: 14px; line-height: 1.6;
}
.cotizacion-doc .doc-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  border-bottom: 2px solid #1a1a1a; padding-bottom: 14px; margin-bottom: 24px;
}
.cotizacion-doc .doc-empresa { font-size: 20px; font-weight: 700; }
.cotizacion-doc .doc-fecha { color: #666; font-size: 13px; text-align: right; }
.cotizacion-doc h3 { font-size: 17px; margin: 0 0 16px; }
.cotizacion-doc table { width: 100%; border-collapse: collapse; margin: 18px 0; }
.cotizacion-doc td { padding: 9px 0; border-bottom: 1px solid #e3e3e3; }
.cotizacion-doc td.k { color: #666; width: 42%; }
.cotizacion-doc .doc-total { font-size: 17px; font-weight: 700; }
.cotizacion-doc .doc-firmas {
  display: flex; justify-content: space-between; gap: 40px; margin-top: 56px;
}
.cotizacion-doc .doc-firma { flex: 1; border-top: 1px solid #1a1a1a; padding-top: 8px; text-align: center; color: #666; font-size: 13px; }
.cotizacion-doc .doc-nota { color: #888; font-size: 12px; margin-top: 28px; }
.cotizacion-doc table.plan { font-size: 13px; }
.cotizacion-doc table.plan th { text-align: left; color: #666; font-weight: 600; border-bottom: 2px solid #1a1a1a; padding-bottom: 6px; }
.cotizacion-doc table.plan td { padding: 6px 0; }
.cotizacion-doc .doc-renders { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 18px 0; }
.cotizacion-doc .doc-renders img { width: 100%; height: 180px; object-fit: cover; border-radius: 6px; display: block; }

/* Chips de variables (editor de plantillas) */
.vars { display: flex; flex-wrap: wrap; gap: 6px; }
.var-chip {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--primary);
  border-radius: 7px; padding: 4px 9px; font-size: 12px; font-family: monospace; cursor: pointer;
}
.var-chip:hover { background: var(--bg); }
#plantillaCuerpo { font-family: monospace; font-size: 13px; line-height: 1.5; }

@media print {
  body * { visibility: hidden; }
  .cotizacion-doc, .cotizacion-doc * { visibility: visible; }
  .cotizacion-doc { position: absolute; left: 0; top: 0; width: 100%; box-shadow: none; margin: 0; max-width: none; }
}

/* Mini barras (estado de proyectos) */
.mini { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.mini-bar { background: var(--bg); border-radius: 5px; height: 8px; overflow: hidden; max-width: 150px; }
.mini-bar > div { height: 100%; border-radius: 5px; }

/* ===== Metas ===== */
.metas-edit { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.metas-edit .field { flex: 1; min-width: 120px; }

.barras { display: flex; justify-content: space-around; align-items: flex-end; gap: 10px; padding: 10px 0; }
.bar-group { display: flex; flex-direction: column; align-items: center; gap: 8px; flex: 1; }
.bars-pair { display: flex; align-items: flex-end; gap: 6px; }
.bar { width: 28px; border-radius: 5px 5px 0 0; min-height: 3px; transition: height .4s; }
.bar--meta { background: var(--green); }
.bar--real { background: #378add; }
.bar-label { font-size: 13px; color: var(--muted); text-align: center; }

.barras-leyenda { display: flex; gap: 20px; justify-content: center; margin-top: 14px; font-size: 13px; color: var(--muted); }
.dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 4px; vertical-align: -1px; }
.dot--meta { background: var(--green); }
.dot--real { background: #378add; }

/* ===== Cartera ===== */
.cartera-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: 0 1px 3px rgba(15,23,42,.05); }
.cartera-card__top { color: var(--muted); font-size: 13px; font-weight: 600; }
.cartera-card__val { font-size: 24px; font-weight: 700; margin: 8px 0 4px; }
.cartera-card__sub { color: var(--muted); font-size: 12px; }

.aging { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 18px; }
.aging__lbl { color: var(--muted); font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.aging__val { font-size: 17px; font-weight: 700; margin-bottom: 8px; }
.aging__bar { background: var(--bg); border-radius: 6px; height: 8px; overflow: hidden; margin-bottom: 5px; }
.aging__bar > div { height: 100%; border-radius: 6px; min-width: 2px; }
.aging__pct { color: var(--muted); font-size: 12px; }

/* ===== Calendario de visitas ===== */
.cal-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; gap: 12px; }
.cal-nav { display: flex; align-items: center; gap: 12px; }
.cal-mes { font-size: 16px; font-weight: 600; text-transform: capitalize; min-width: 150px; text-align: center; }
.cal-filtro { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.cal-filtro select { background: var(--bg); border: 1px solid var(--border); color: var(--text); padding: 8px 12px; border-radius: 9px; font-size: 14px; }

.cal-head { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 6px; }
.cal-head div { text-align: center; font-size: 12px; color: var(--muted); font-weight: 600; padding: 4px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-cell { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; min-height: 88px; padding: 6px; }
.cal-cell--off { background: transparent; border: none; }
.cal-cell--hoy { border-color: var(--primary); border-width: 2px; }
.cal-dia { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.cal-visita {
  background: rgba(245,158,11,.15); color: var(--primary-d); border-radius: 5px;
  padding: 2px 6px; font-size: 11px; margin-bottom: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cal-iframe { width: 100%; height: 520px; border: 1px solid var(--border); border-radius: 9px; margin-top: 6px; }
@media (max-width: 760px) { .cal-cell { min-height: 64px; } .cal-visita { font-size: 10px; } }

/* ===== Embudo y métricas ===== */
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 22px; }
.funnel { display: flex; flex-direction: column; gap: 16px; }
.funnel__top { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 6px; }
.funnel__bar { background: var(--bg); border-radius: 6px; height: 14px; overflow: hidden; }
.funnel__fill { height: 100%; border-radius: 6px; transition: width .4s; min-width: 2px; }
@media (max-width: 760px) { .metric-grid { grid-template-columns: 1fr; } }

/* ===== Barra de herramientas + interruptor de vista ===== */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar__right { display: flex; gap: 8px; flex-wrap: wrap; }
.view-toggle { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.vt { background: transparent; border: none; color: var(--muted); padding: 8px 14px; font-size: 14px; cursor: pointer; }
.vt.is-active { background: var(--primary); color: #1a1206; font-weight: 600; }

/* ===== Barra de filtros ===== */
.filtros {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px; margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(15,23,42,.05);
}
.filtros input, .filtros select {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  padding: 8px 11px; border-radius: 8px; font-size: 13px;
}
.filtros input[type="text"] { min-width: 150px; }
.filtros__fecha { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }

/* ===== Pipeline (Kanban de prospectos) ===== */
.pipeline { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 8px; align-items: flex-start; }
.pcol {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); width: 230px; min-width: 230px; flex-shrink: 0;
  display: flex; flex-direction: column;
}
.pcol__head {
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  font-size: 14px; font-weight: 600; display: flex; justify-content: space-between;
  border-top: 3px solid var(--primary); border-radius: var(--radius) var(--radius) 0 0;
}
.pcol__count {
  color: var(--muted); font-weight: 600; background: var(--bg);
  border-radius: 999px; padding: 1px 9px; font-size: 12px;
}
.pcol__body { padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 70px; }
.pcol.dragover { outline: 2px dashed var(--primary); outline-offset: -2px; }

.pcard {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 9px; padding: 10px 12px; cursor: grab;
}
.pcard:active { cursor: grabbing; }
.pcard.dragging { opacity: .45; }
.pcard__name { font-weight: 600; font-size: 14px; cursor: pointer; flex: 1; }
.pcard__meta { color: var(--muted); font-size: 12px; margin-top: 4px; }
.pcard__del { cursor: pointer; color: var(--muted); font-size: 13px; }
.pcard__del:hover { color: var(--red); }

/* Tarjeta enriquecida */
.pcard__top { display: flex; align-items: center; gap: 8px; }
.pcard__avatar {
  width: 26px; height: 26px; border-radius: 6px; flex-shrink: 0;
  background: var(--primary); color: #1a1206; font-weight: 700; font-size: 13px;
  display: grid; place-items: center;
}
.pcard__estado-row { display: flex; align-items: center; gap: 7px; margin-top: 8px; }
.pcard__dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); flex-shrink: 0; }
.pcard__dot.is-off { background: var(--muted); }
.pcard__estado {
  background: transparent; border: 1px solid var(--border); color: var(--text);
  border-radius: 7px; font-size: 11px; padding: 2px 6px; cursor: pointer;
}
.pcard__hoy { background: rgba(59,130,246,.15); color: #2563eb; border-radius: 999px; padding: 2px 9px; font-size: 11px; font-weight: 600; margin-left: auto; }
.pcard__hoy--gris { background: var(--surface-2); color: var(--muted); }

.pcard__tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.etq { border-radius: 6px; padding: 2px 8px; font-size: 11px; font-weight: 600; display: inline-flex; align-items: center; gap: 5px; }
.etq__del { cursor: pointer; font-weight: 700; }
.etq-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }

.pcard__acciones { display: flex; gap: 4px; margin-top: 10px; border-top: 1px solid var(--border); padding-top: 8px; }
.pcard__acciones button {
  flex: 1; background: transparent; border: none; cursor: pointer; font-size: 14px;
  padding: 5px; border-radius: 6px; position: relative;
}
.pcard__acciones button:hover { background: var(--surface-2); }
.pcard__badge {
  position: absolute; top: -2px; right: 0; background: var(--red); color: #fff;
  border-radius: 999px; font-size: 9px; min-width: 14px; height: 14px; line-height: 14px; padding: 0 3px;
}

/* Colores por etapa (borde superior de la columna) */
.pcol[data-etapa="Interesado"]  .pcol__head { border-top-color: #60a5fa; }
.pcol[data-etapa="Visita"]      .pcol__head { border-top-color: var(--primary); }
.pcol[data-etapa="Negociación"] .pcol__head { border-top-color: #a78bfa; }
.pcol[data-etapa="Cerrado"]     .pcol__head { border-top-color: var(--green); }
.pcol[data-etapa="Perdido"]     .pcol__head { border-top-color: var(--red); }
.pcol[data-etapa="No contesta"] .pcol__head { border-top-color: #64748b; }

/* Enlace clicable dentro de tablas */
.link { color: var(--primary); cursor: pointer; font-weight: 600; }
.link:hover { text-decoration: underline; }

/* ===== Proyectos (tarjetas + stats) ===== */
.btn--rojo { background: #dc2626; color: #fff; }
.btn--rojo:hover { background: #b91c1c; }

.proy-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 12px; }
.proy-sub { color: var(--muted); font-size: 14px; margin: 0; }

.proy-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.proy-stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; align-items: center; gap: 12px; box-shadow: 0 1px 3px rgba(15,23,42,.05); }
.proy-stat__ic { font-size: 20px; }
.proy-stat__val { font-size: 22px; font-weight: 700; line-height: 1; }
.proy-stat__lbl { color: var(--muted); font-size: 12px; margin-top: 3px; }

.proy-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.proy-buscar { flex: 1; min-width: 200px; background: var(--surface); border: 1px solid var(--border); color: var(--text); padding: 10px 14px; border-radius: 9px; font-size: 14px; }
.proy-toolbar select, #proyDir { background: var(--surface); border: 1px solid var(--border); color: var(--text); padding: 9px 12px; border-radius: 9px; font-size: 13px; cursor: pointer; }
.vt2 { background: transparent; border: none; color: var(--muted); padding: 8px 12px; font-size: 15px; cursor: pointer; }
.vt2.is-active { background: var(--primary); color: #1a1206; }

.proy-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.proy-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: 0 1px 3px rgba(15,23,42,.05); }
.proy-card__img { height: 150px; background: var(--surface-2); background-size: cover; background-position: center; position: relative; display: grid; place-items: center; }
.proy-card__ph { font-size: 38px; opacity: .5; }
.proy-card__menu { position: absolute; top: 8px; right: 8px; }
.proy-card__menu .btn--azul { background: rgba(255,255,255,.9); color: #1e293b; padding: 4px 9px; }
.proy-badge { position: absolute; top: 10px; left: 10px; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.proy-badge--warn { background: #fef3c7; color: #b45309; }
.proy-badge--ok   { background: #dcfce7; color: #15803d; }
.proy-badge--info { background: #dbeafe; color: #1d4ed8; }
.proy-card__body { padding: 14px 16px; }
.proy-card__title { font-size: 16px; margin: 0 0 6px; cursor: pointer; color: var(--primary-d); }
.proy-card__desc { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 0 0 10px; }
.proy-card__loc { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.proy-card__nums { font-size: 13px; border-top: 1px solid var(--border); padding-top: 10px; }

/* Botón azul */
.btn--azul { background: #378add; color: #fff; }
.btn--azul:hover { background: #2f78c2; }

/* Menú desplegable de opciones */
.dropdown { position: relative; display: inline-block; }
.dropmenu {
  display: none; position: absolute; right: 0; top: calc(100% + 4px);
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  min-width: 190px; z-index: 30; overflow: hidden; box-shadow: 0 12px 30px rgba(15,23,42,.15);
}
.dropmenu.open { display: block; }
.dropmenu a { display: flex; align-items: center; gap: 9px; padding: 11px 14px; font-size: 14px; color: var(--text); cursor: pointer; }
.dropmenu a:hover { background: var(--surface-2); }

/* Tag bloqueada */
.tag--bloqueada { background: rgba(239,68,68,.15); color: var(--red); }

/* Unidades de venta: imágenes y formulario */
.u-thumb { width: 46px; height: 34px; object-fit: cover; border-radius: 5px; }
.u-thumb-lg { width: 90px; height: 64px; object-fit: cover; border-radius: 7px; vertical-align: middle; margin-top: 10px; }
.u-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; align-items: center; }
.u-form input, .u-form select {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  padding: 9px 11px; border-radius: 9px; font-size: 13px; width: 100%;
}
.u-form input:focus, .u-form select:focus { outline: none; border-color: var(--primary); }
.u-render {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted);
  padding: 9px 11px; border-radius: 9px; font-size: 13px; cursor: pointer;
}
.u-render:hover { color: var(--text); }

/* Modal ancho (detalle) */
.modal__box--wide { max-width: 760px; }

/* Selector de etapa en la gestión */
.gest-etapa { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.gest-etapa .lbl { color: var(--muted); font-size: 14px; font-weight: 600; }
.gest-etapa select {
  background: var(--bg); border: 2px solid var(--primary); color: var(--text);
  padding: 8px 14px; border-radius: 9px; font-size: 14px; font-weight: 600;
}
.gest-etapa select:focus { outline: none; }
.gest-etapa-hint { color: var(--muted); font-size: 12px; }

/* Subventana de gestión (estilo referencia) */
.gest-section { color: #ef4444; font-weight: 700; font-size: 15px; margin: 10px 0 8px; }
.gest-box { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin-bottom: 16px; }
.gest-box__title { background: var(--surface-2); padding: 10px 14px; font-weight: 600; font-size: 14px; border-bottom: 1px solid var(--border); }
.gest-grid { display: grid; }
.gest-grid--3 { grid-template-columns: repeat(3, 1fr); }
.gest-grid--2 { grid-template-columns: repeat(2, 1fr); }
.gest-grid--1 { grid-template-columns: 1fr; }
.gc { padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 13px; }
.gest-grid--3 .gc:not(:nth-child(3n)),
.gest-grid--2 .gc:not(:nth-child(2n)) { border-right: 1px solid var(--border); }
.gc b { color: var(--muted); font-weight: 600; margin-right: 4px; }
.gest-sub { padding: 12px 14px; font-weight: 600; font-size: 13px; }
.gest-box--empty { padding: 18px 14px; color: var(--muted); font-size: 13px; }
.gest-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.gest-btn--save   { background: #22c55e; color: #06270f; }
.gest-btn--send   { background: #378add; color: #fff; }
.gest-btn--cancel { background: var(--primary); color: #1a1206; }
@media (max-width: 640px) { .gest-grid--3, .gest-grid--2 { grid-template-columns: 1fr; } .gc { border-right: none !important; } }
.detalle__body { padding: 20px 22px; }
.detalle__resumen {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 12px; margin-bottom: 20px;
}
.detalle__stat { background: var(--surface-2); border-radius: 9px; padding: 12px 14px; }
.detalle__stat .lbl { color: var(--muted); font-size: 12px; }
.detalle__stat .val { font-size: 20px; font-weight: 700; margin-top: 4px; }
.detalle__sub { color: var(--muted); font-size: 13px; margin-bottom: 10px; }

/* Etiquetas de estado de unidad */
.tag--vendida    { background: rgba(34,197,94,.15);  color: var(--green); }
.tag--reservada  { background: rgba(245,158,11,.15); color: var(--primary); }
.tag--disponible { background: rgba(148,163,184,.15); color: var(--muted); }

/* Campos de formulario */
.form__fields { padding: 20px 22px; display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--muted); font-weight: 600; }
.field input, .field select, .field textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 9px;
  font-size: 14px;
  width: 100%;
  font-family: inherit;
  resize: vertical;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--primary); }

/* Formulario de seguimiento (gestión) */
.seg-add { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.seg-add input, .seg-add select {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  padding: 9px 11px; border-radius: 9px; font-size: 13px;
}
.seg-add input[type="text"] { flex: 1; min-width: 140px; }
.seg-add input:focus, .seg-add select:focus { outline: none; border-color: var(--primary); }
.seg-envio {
  background: rgba(34,197,94,.12); border: 1px solid var(--green); color: var(--green);
  border-radius: 9px; padding: 12px 14px; font-size: 13px; margin: 16px 0 4px;
}

/* Ficha de cliente */
.ficha { display: flex; flex-direction: column; gap: 2px; }
.ficha__row { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.ficha__row .lbl { color: var(--muted); }
.ficha__notas {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px;
  padding: 14px; font-size: 14px; line-height: 1.5; color: var(--text); white-space: pre-wrap;
}

/* Responsivo básico */
@media (max-width: 760px) {
  .sidebar { width: 64px; }
  .brand__name, .nav__item span, .user__info { display: none; }
  .search { width: 130px; }
}
