/* v13 - 2026-08-12 */
/* ============================================================
   CRE Match OS — Design system
   Palette: Kadana light theme — white background, purple + teal
   accents.
   Font: Arial (system-standard, no webfont dependency).
   ============================================================ */

:root {
  --color-bg: #FFFFFF;
  --color-surface: #F5F0FF;
  --color-surface-hover: #F0EAFA;
  --color-border: #E8E0F5;
  --color-border-soft: #EFE9FA;

  --color-primary: #7B2FBE;
  --color-primary-dark: #5A1FA0;
  --color-primary-tint: #F0EAFA;

  --color-secondary: #00C4A7;
  --color-secondary-dark: #00A38C;
  --color-secondary-tint: #E6FBF8;

  --color-text: #1A0533;
  --color-text-muted: #6B5B8A;

  --color-danger: #FF4444;
  --color-danger-tint: #FFE8E8;
  --color-success: #00C4A7;
  --color-success-tint: #E6FBF8;
  --color-warning: #7B2FBE;
  --color-warning-tint: #F0EAFA;
  --color-gray: #888888;
  --color-gray-tint: #F0F0F0;

  --color-orange: #C8730A;
  --color-orange-tint: #FBEBD6;

  /* Radius scale — cards/buttons/fieldsets use --radius (12px) */
  --radius-xs: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(26, 5, 51, 0.06);
  --shadow-card: 0 1px 2px rgba(26, 5, 51, 0.04), 0 4px 14px rgba(26, 5, 51, 0.08);
  --shadow-card-hover: 0 2px 4px rgba(26, 5, 51, 0.05), 0 10px 24px rgba(123, 47, 190, 0.14);
  --shadow-md: 0 8px 24px rgba(26, 5, 51, 0.14);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: Arial, Helvetica, sans-serif;
  margin: 0;
  padding: 0;
  font-size: 15px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
}

h1, h2, h3 {
  font-family: Arial, Helvetica, sans-serif;
  font-weight: bold;
  color: var(--color-text);
  margin: 0 0 4px 0;
}
h1 { font-size: 1.65rem; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; margin-top: 4px; }
h3 { font-size: 1rem; }

a { color: var(--color-primary); }
a:hover { color: var(--color-secondary); }

.container {
  padding: 28px 32px 56px;
  max-width: 1220px;
  margin: 0 auto;
}
.container.narrow {
  max-width: 400px;
  margin-top: 64px;
}

/* ---------- Top navigation ---------- */
.topnav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  padding: 0 20px;
  background: #FFFFFF;
  border-bottom: 2px solid var(--color-primary);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topnav .brand {
  color: var(--color-text);
  font-weight: bold;
  font-size: 1rem;
  letter-spacing: 0.01em;
  padding: 16px 18px 16px 0;
  margin-right: 10px;
  border-right: 1px solid var(--color-border);
  white-space: nowrap;
}
.topnav .brand .dot { color: var(--color-secondary); }
.topnav .brand-logo { display: flex; align-items: center; }
.topnav .brand-logo img { height: 28px; max-width: 160px; object-fit: contain; }
.topnav a {
  color: var(--color-text-muted);
  text-decoration: none;
  padding: 16px 13px;
  font-size: 0.87rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color .15s ease;
}
.topnav a .icon { font-size: 0.95rem; }
.topnav a:hover { color: var(--color-secondary); }
.topnav a.active {
  color: var(--color-primary);
  font-weight: 600;
  border-bottom-color: var(--color-primary);
}
.topnav a.logout { margin-left: auto; color: var(--color-text-muted); }
.topnav a.logout:hover { color: var(--color-secondary); }
.topnav a.kadana-link { color: var(--color-primary); font-weight: 600; }
.topnav a.kadana-link:hover { color: var(--color-secondary); }
.topnav a.kadana-link.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }

@media (max-width: 900px) {
  .topnav { overflow-x: auto; }
}

/* ---------- Layout helpers ---------- */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
}
.page-header h1 { margin: 0; }
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 40px 0 14px;
}
.section-title h2 { margin: 0; color: var(--color-text); font-weight: bold; }

.card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 22px 24px;
  margin-bottom: 24px;
}
.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
.card-header-row h2 { margin: 0; }

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

.notice {
  background: var(--color-primary-tint);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 0.88rem;
  margin-bottom: 14px;
}
.notice.warn {
  background: var(--color-secondary-tint);
  border-color: rgba(0, 196, 167, 0.35);
  color: var(--color-text);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: var(--radius-xs);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.btn-primary {
  background: var(--color-primary);
  color: #fff;
}
.btn-primary:hover { background: var(--color-primary-dark); color: #fff; }
/* "Botón secundario" — outline teal, fills solid on hover */
.btn-gold {
  background: transparent;
  color: var(--color-secondary);
  border: 1px solid var(--color-secondary);
}
.btn-gold:hover { background: var(--color-secondary); color: #fff; }
.btn-ghost {
  background: transparent;
  color: var(--color-text);
  border-color: var(--color-border);
}
.btn-ghost:hover { background: var(--color-surface-hover); }
.btn-danger {
  background: var(--color-danger);
  color: #fff;
}
.btn-danger:hover { background: #E03333; color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 0.78rem; }
.btn-link-danger {
  background: none;
  border: none;
  color: var(--color-danger);
  cursor: pointer;
  font-size: inherit;
  font-family: inherit;
  padding: 0;
  text-decoration: underline;
}
.btn-link-danger:hover { color: #cc0000; }

/* ---------- Forms ---------- */
form label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 14px;
}
form label.inline-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  color: var(--color-text);
}
form label.inline-check input[type="checkbox"] { width: auto; margin: 0; }
label.block-label { margin-bottom: 8px; }

input, select, textarea {
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 400;
  color: var(--color-text);
  width: 100%;
  padding: 10px 14px;
  margin-top: 5px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xs);
  background: #FFFFFF;
}
input::placeholder, select::placeholder, textarea::placeholder { color: var(--color-text-muted); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(123, 47, 190, 0.14);
}
input[type="checkbox"], input[type="radio"] { width: auto; margin-top: 0; }

button {
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-xs);
  padding: 9px 16px;
  cursor: pointer;
  margin-top: 8px;
}
button:hover { background: var(--color-primary-dark); }
button[type="button"].btn-link-danger { background: none; }

.form-card { max-width: 980px; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0 20px;
}
.form-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 12px;
}

fieldset {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px 18px 4px;
  margin-bottom: 18px;
}
legend {
  font-weight: bold;
  color: var(--color-primary);
  padding: 0 8px;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 6px 12px;
  margin-bottom: 14px;
}
.checkbox-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 400;
  color: var(--color-text);
  margin-bottom: 0;
}
.checkbox-item input { width: auto; margin: 0; }

.inherited-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px 20px;
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 6px 0 8px;
}
.inherited-summary div { display: flex; flex-direction: column; gap: 2px; }
.inherited-summary .muted { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; }
.inherited-summary strong { font-size: 0.9rem; font-weight: 600; color: var(--color-text); }

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 18px;
}
.filter-bar label { margin-bottom: 0; min-width: 200px; flex: 1; }

/* ---------- Tables ---------- */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.86rem;
}
thead th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-primary);
  background: var(--color-surface);
  padding: 11px 12px;
  border-bottom: 2px solid var(--color-primary);
  white-space: nowrap;
}
thead th:first-child { border-top-left-radius: var(--radius); }
thead th:last-child { border-top-right-radius: var(--radius); }
tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
  color: var(--color-text);
}
tbody tr { background: #FFFFFF; }
tbody tr:nth-child(even) { background: var(--color-surface); }
tbody tr:hover { background: var(--color-surface-hover) !important; }
.actions-cell { display: flex; gap: 10px; flex-wrap: wrap; white-space: nowrap; }
.actions-cell a { font-size: 0.82rem; font-weight: 600; text-decoration: none; color: var(--color-primary); }
.actions-cell a:hover { color: var(--color-secondary); text-decoration: underline; }

.error { color: var(--color-danger); }
.muted { color: var(--color-text-muted); font-size: 0.82rem; }
tr.overdue { background: var(--color-danger-tint) !important; }
tr.overdue:hover { background: #FFD9D9 !important; }

/* ---------- Badges ----------
   Semantic status colors: teal = active/available, purple = in progress,
   red = overdue/lost, gray = closed/neutral. Driven by stage_badge() in
   choices.py, which maps every stage-like DB value to one of these. */
.badge {
  display: inline-block;
  background: var(--color-primary-tint);
  color: var(--color-primary);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge-muted { background: var(--color-gray-tint); color: var(--color-gray); }
.badge-warn { background: var(--color-primary-tint); color: var(--color-primary); }
.badge-gold { background: var(--color-secondary-tint); color: var(--color-secondary); }
.badge-danger, .badge-red { background: var(--color-danger-tint); color: var(--color-danger); }
.badge-success, .badge-green { background: var(--color-secondary-tint); color: var(--color-secondary); }
.badge-yellow { background: var(--color-warning-tint); color: var(--color-warning); }
.badge-gray { background: var(--color-gray-tint); color: var(--color-gray); }
.badge-orange { background: var(--color-orange-tint); color: var(--color-orange); }

/* ---------- AI-assist highlight ---------- */
.ai-prefilled {
  background: var(--color-secondary-tint);
  border: 1px solid rgba(0, 196, 167, 0.35);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 10px;
}

/* ---------- Photo gallery ---------- */
.photo-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
.photo-gallery figure {
  margin: 0;
  width: 140px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}
.photo-gallery img {
  width: 140px;
  height: 140px;
  object-fit: cover;
  display: block;
}
.photo-gallery figcaption {
  font-size: 0.72rem;
  text-align: center;
  padding: 4px;
  color: var(--color-text-muted);
}
.contact-row {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 8px;
}

/* ---------- Dashboard KPI cards ----------
   Big number first (purple), small uppercase label below it (muted). */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 12px;
}
.kpi-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px 20px 18px;
  box-shadow: var(--shadow-card);
  transition: box-shadow .18s ease, transform .18s ease;
}
.kpi-card:hover { box-shadow: var(--shadow-card-hover); transform: translateY(-1px); }
.kpi-card .kpi-value {
  font-size: 32px;
  font-weight: bold;
  color: var(--color-primary);
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.kpi-card .kpi-label {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  font-weight: 700;
  margin-top: 8px;
}
.kpi-card .kpi-sub { font-size: 0.78rem; color: var(--color-text-muted); margin-top: 4px; }
.kpi-card.accent-gold { border-color: rgba(0, 196, 167, 0.35); }
.kpi-card.accent-gold .kpi-value { color: var(--color-secondary); }
.kpi-card.accent-gold::before {
  content: "";
  display: block;
  width: 28px;
  height: 3px;
  border-radius: 999px;
  background: var(--color-secondary);
  margin-bottom: 12px;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
@media (max-width: 800px) {
  .two-col { grid-template-columns: 1fr; }
}

/* ---------- Dashboard: "Actividad de hoy" — 3 columns ---------- */
.three-col {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 24px;
}
@media (max-width: 900px) {
  .three-col { grid-template-columns: 1fr; }
}
.today-col { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.today-col-header {
  background: var(--color-primary);
  color: #fff;
  font-weight: 700;
  padding: 12px 18px;
  font-size: 0.95rem;
}
.today-col-body {
  background: var(--color-surface);
  padding: 14px 18px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.today-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  text-decoration: none;
  color: var(--color-text);
}
a.today-row:hover { color: var(--color-primary); }
.today-row-time {
  font-variant-numeric: tabular-nums;
  color: var(--color-text-muted);
  font-size: 0.78rem;
  min-width: 38px;
}
.today-col-link {
  display: block;
  padding: 10px 18px;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border-soft);
  font-size: 0.82rem;
  font-weight: 600;
}

/* ---------- Dashboard: "Esta semana" — vertical day-row list ---------- */
.week-list {
  display: flex;
  flex-direction: column;
}
.week-list-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--color-border-soft);
}
.week-list-row:last-child { border-bottom: none; }
.week-list-row-today {
  background: #F5F0FF;
  border-radius: var(--radius-xs);
}
.week-list-day {
  flex: 0 0 150px;
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--color-text);
}
.week-list-row-today .week-list-day { color: #7B2FBE; }
.week-list-chips {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.week-list-chip {
  display: inline-block;
  font-size: 0.76rem;
  line-height: 1.3;
  padding: 4px 10px;
  border-radius: 999px;
  text-decoration: none;
}
@media (max-width: 600px) {
  .week-list-row { flex-direction: column; align-items: flex-start; gap: 6px; }
  .week-list-day { flex-basis: auto; }
}

.dashboard-action-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--color-border-soft);
  text-decoration: none;
  color: var(--color-text);
  font-size: 0.88rem;
}
.dashboard-action-row:last-child { border-bottom: none; }
.dashboard-action-row:hover { background: var(--color-surface-hover); }

/* ---------- Actividad: full-month calendar (/actividad/calendario) ---------- */
.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-bottom: 14px;
}
.calendar-month-label {
  margin: 0;
  min-width: 220px;
  text-align: center;
  text-transform: capitalize;
}
.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.month-weekday-header {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--color-text-muted);
  text-align: center;
  padding-bottom: 4px;
}
.month-cell {
  min-height: 110px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xs);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.month-cell-faded { background: var(--color-gray-tint); }
.month-cell-faded .month-day-number { color: var(--color-gray); }
.month-cell-today { background: var(--color-primary-tint); border-color: var(--color-primary); }
.month-day-number { font-size: 0.82rem; font-weight: 700; color: var(--color-text); }
.month-day-chips { display: flex; flex-direction: column; gap: 3px; overflow: hidden; }
.month-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  line-height: 1.25;
  padding: 2px 5px;
  border-radius: var(--radius-xs);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
}
.month-chip-dot {
  width: 6px;
  height: 6px;
  min-width: 6px;
  border-radius: 50%;
  background: currentColor;
}
.month-chip-text { overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 700px) {
  .month-cell { min-height: 56px; padding: 4px; }
  .calendar-month-label { min-width: 0; font-size: 1rem; }
  .month-chip-text { display: none; }
  .month-chip { padding: 2px; justify-content: center; }
}

.pipeline-bars { display: flex; flex-direction: column; gap: 10px; }
.pipeline-bar-row { display: flex; align-items: center; gap: 10px; font-size: 0.82rem; }
.pipeline-bar-row .pb-label { width: 130px; flex-shrink: 0; color: var(--color-text-muted); }
.pipeline-bar-track {
  flex: 1;
  background: var(--color-surface);
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
}
.pipeline-bar-fill { background: var(--color-primary); height: 100%; border-radius: 999px; }
.pipeline-bar-row .pb-count { width: 36px; text-align: right; font-weight: 700; color: var(--color-primary); }

/* ---------- KADANA visual separation ---------- */
.kadana-scope {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--color-primary-tint) 0%, var(--color-bg) 90px);
  padding: 4px 20px 20px;
  margin-bottom: 24px;
}
.kadana-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 0 6px;
  color: var(--color-primary);
  font-weight: 800;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.kadana-banner .icon { font-size: 1rem; }
.brokerage-scope {
  border-left: 3px solid var(--color-primary);
  padding-left: 16px;
}

/* ---------- Task list ---------- */
.task-list { list-style: none; margin: 0; padding: 0; }
.task-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.86rem;
}
.task-list li:last-child { border-bottom: none; }
.task-list .task-title.completed { text-decoration: line-through; color: var(--color-text-muted); }
.task-form { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.task-form input[type="text"] { flex: 2; min-width: 160px; margin-top: 0; }
.task-form input[type="date"] { flex: 1; min-width: 140px; margin-top: 0; }
.task-form button { margin-top: 0; }

/* ---------- htmx ---------- */
.htmx-indicator { display: none; color: var(--color-text-muted); font-size: 0.82rem; }
.htmx-request .htmx-indicator { display: inline; }
.htmx-request.htmx-indicator { display: inline; }

/* ---------- Login ---------- */
.login-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 32px 28px;
  text-align: center;
}
.login-card h1 { margin-bottom: 20px; }
.login-card .brand-mark { color: var(--color-secondary); }
.login-card .login-logo { max-height: 56px; max-width: 100%; object-fit: contain; margin-bottom: 20px; }

@media (max-width: 600px) {
  .container { padding: 14px; }
  table, thead, tbody, th, td, tr { display: block; }
  thead { display: none; }
  tbody tr {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    margin-bottom: 10px;
    padding: 4px 10px;
    background: var(--color-bg);
  }
  tbody td {
    border: none;
    padding: 6px 0;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    text-align: right;
  }
  td::before {
    content: attr(data-label) ": ";
    font-weight: 700;
    color: var(--color-text-muted);
    text-align: left;
  }
  .form-grid { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
}

/* ============================================================
   v9 — CRM centrado en clientes: avatares, estado de contacto,
   acciones rápidas, timeline, modal, búsqueda global.
   ============================================================ */

/* ---------- Avatares (inicial + color por id % 6) ---------- */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
  line-height: 1;
}
.avatar-lg { width: 52px; height: 52px; font-size: 1.25rem; }
.avatar-0 { background: var(--color-primary); }
.avatar-1 { background: var(--color-secondary); }
.avatar-2 { background: var(--color-orange); }
.avatar-3 { background: #2F6FE0; }
.avatar-4 { background: #C8398A; }
.avatar-5 { background: #5B6472; }

.cell-with-avatar {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  text-decoration: none;
}
.cell-with-avatar:hover { text-decoration: underline; }

/* ---------- Estado de contacto (punto de color) ---------- */
.status-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}
.status-dot-active { background: var(--color-secondary); }
.status-dot-this-week { background: var(--color-warning); }
.status-dot-cold { background: var(--color-danger); }
.status-dot-uncontacted { background: var(--color-gray); }

/* ---------- Filtro por estado: chips ---------- */
.chip-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}
.chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-muted);
  background: #fff;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.chip input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.chip:hover { border-color: var(--color-primary); color: var(--color-primary); }
.chip.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

/* ---------- Quick actions (íconos sin texto en cada fila) ---------- */
.qa-group {
  display: inline-flex;
  gap: 2px;
  margin-right: 8px;
}
.qa-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: none;
  border: none;
  border-radius: 6px;
  font-size: 1.125rem; /* 18px */
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  color: var(--color-text);
}
.qa-btn:hover { background: var(--color-surface-hover); }
.qa-btn-danger:hover { background: var(--color-danger-tint); }

/* ---------- Pill-group (radios como botones: canal, estado del cliente) ---------- */
.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.pill-group input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.pill-group label {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  margin: 0;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.pill-group input:checked + label {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}
.pill-group input:focus-visible + label { outline: 2px solid var(--color-primary); outline-offset: 2px; }

/* ---------- Ficha: header centrado en cliente ---------- */
.client-header { margin-bottom: 20px; }
.client-header-top {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.client-header-info { flex: 1; min-width: 200px; }
.client-header-info h1 { margin-bottom: 2px; }
.client-header-meta { color: var(--color-text-muted); font-size: 0.85rem; }
.client-header-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 0.85rem;
}
.client-header-next-action {
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--color-surface);
  border-radius: var(--radius);
  font-size: 0.88rem;
}
.client-header-next-action.is-empty { color: var(--color-text-muted); background: transparent; border: 1px dashed var(--color-border); }

/* ---------- Timeline de contacto ---------- */
.timeline { display: flex; flex-direction: column; }
.timeline-item {
  display: grid;
  grid-template-columns: 88px 20px 1fr;
  gap: 14px;
  padding-bottom: 18px;
}
.timeline-datetime {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--color-text);
  padding-top: 2px;
}
.timeline-marker-col {
  position: relative;
  display: flex;
  justify-content: center;
}
.timeline-marker-col::before {
  content: "";
  position: absolute;
  top: 16px;
  bottom: -18px;
  width: 2px;
  background: var(--color-border);
}
.timeline-item:last-child .timeline-marker-col::before { display: none; }
.timeline-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  margin-top: 4px;
  z-index: 1;
  background: var(--color-gray);
}
.timeline-dot.badge-red { background: var(--color-danger); }
.timeline-dot.badge-yellow { background: var(--color-warning); }
.timeline-dot.badge-green { background: var(--color-secondary); }
.timeline-dot.badge-gray { background: var(--color-gray); }
.timeline-card {
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-border);
  border-radius: var(--radius);
  padding: 12px 16px;
  background: #fff;
}
.timeline-card-whatsapp { border-left-color: var(--color-secondary); }
.timeline-card-call { border-left-color: #2F6FE0; }
.timeline-card-email { border-left-color: var(--color-orange); }
.timeline-card-in_person { border-left-color: var(--color-primary); }
.timeline-card-linkedin { border-left-color: #5B6472; }
.timeline-card-other { border-left-color: var(--color-gray); }
.timeline-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.timeline-channel-icon { font-size: 1rem; }
.timeline-card p { margin: 4px 0; font-size: 0.88rem; }
.timeline-next-action { color: var(--color-primary); font-weight: 600; }
.timeline-card-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 8px;
}
.timeline-edit-link { font-size: 0.82rem; font-weight: 600; text-decoration: none; }

/* ---------- Modal de actividad rápida ---------- */
dialog#quick-activity-modal {
  border: none;
  border-radius: var(--radius-lg);
  padding: 0;
  max-width: 560px;
  width: 92%;
  box-shadow: var(--shadow-md);
}
dialog#quick-activity-modal::backdrop { background: rgba(26, 5, 51, 0.45); }
dialog#quick-activity-modal .modal-body { position: relative; padding: 26px 26px 20px; }
dialog#quick-activity-modal .modal-close {
  position: absolute;
  top: 10px;
  right: 14px;
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 4px;
  margin: 0;
}
dialog#quick-activity-modal .modal-close:hover { color: var(--color-text); }
dialog#quick-activity-modal h3 { margin-bottom: 16px; padding-right: 20px; }

/* ---------- Búsqueda global (navbar) ---------- */
.nav-search {
  position: relative;
  margin-left: auto;
  margin-right: 12px;
}
.nav-search input {
  width: 220px;
  padding: 8px 12px;
  margin-top: 0;
  font-size: 0.85rem;
}
.nav-search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 320px;
  max-height: 420px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 30;
}
.nav-search-results:empty { display: none; border: none; box-shadow: none; }
.search-group-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-primary);
  background: var(--color-surface);
  padding: 8px 14px;
}
.search-result-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 9px 14px;
  text-decoration: none;
  color: var(--color-text);
  font-size: 0.86rem;
  border-bottom: 1px solid var(--color-border-soft);
}
.search-result-row:hover { background: var(--color-surface-hover); }
.search-result-name { flex: 1; font-weight: 600; }
.search-result-status { font-size: 0.72rem; }
.search-empty { padding: 14px; font-size: 0.85rem; color: var(--color-text-muted); }

@media (max-width: 900px) {
  .nav-search { margin-left: 0; width: 100%; order: 99; }
  .nav-search input { width: 100%; }
}

/* ============================================================
   v10 — Marcas/Propietarios: listas como cards compactas,
   segmentadas en "En seguimiento" / "Sin contactar".
   ============================================================ */

/* ---------- Más filtros (collapsed dropdown) ---------- */
.more-filters {
  margin-bottom: 18px;
}
.more-filters summary {
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-primary);
  padding: 6px 0;
  list-style: none;
}
.more-filters summary::-webkit-details-marker { display: none; }
.more-filters summary::before { content: "▸ "; }
.more-filters[open] summary::before { content: "▾ "; }
.more-filters label {
  margin: 10px 0 0;
  max-width: 260px;
}

/* ---------- Secciones de clientes ---------- */
.client-section { margin-bottom: 28px; }
.client-section-header { margin-bottom: 4px; }
.client-section-empty { padding: 10px 4px; }
.client-section-danger {
  background: #FFF5F5;
  border-radius: var(--radius);
  padding: 12px 14px 4px;
}

/* ---------- Lista de cards ---------- */
.client-card-list {
  background: var(--color-bg);
  border-radius: var(--radius);
  overflow: hidden;
}
.client-section-danger .client-card-list { background: transparent; }

.client-card {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 70px;
  padding: 12px 10px;
  border-bottom: 1px solid var(--color-border-soft);
  transition: background-color .12s ease;
}
.client-card-list .client-card:last-child { border-bottom: none; }
.client-card:hover { background: #F5F0FF; }
.client-card-overdue { background: #FFF0F0; }
.client-card-overdue:hover { background: #FFE4E4; }

.client-card-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 220px;
  min-width: 0;
}
.client-card-identity { min-width: 0; }
.client-card-name {
  display: block;
  font-size: 15px;
  font-weight: 700;
  color: var(--color-text);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.client-card-name:hover { color: var(--color-primary); text-decoration: underline; }
.client-card-subtitle {
  font-size: 12px;
  color: #6B5B8A;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.client-card-center {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 2 1 320px;
  min-width: 0;
  font-size: 12px;
  flex-wrap: wrap;
}
.client-card-status-line {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  color: var(--color-text-muted);
  white-space: nowrap;
}
.client-card-line { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.client-card-line-green { color: var(--color-secondary-dark); font-weight: 600; }
.client-card-line-warn { color: var(--color-orange); font-weight: 600; }
.client-card-line-danger { color: var(--color-danger); font-weight: 600; }

.client-card-right {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  margin-left: auto;
}

@media (max-width: 700px) {
  .client-card { flex-wrap: wrap; min-height: 0; }
  .client-card-left { flex: 1 1 100%; }
  .client-card-center { flex: 1 1 100%; padding-left: 42px; }
  .client-card-right { flex: 1 1 100%; padding-left: 42px; }
}

/* ============================================================
   v11 — Oportunidades: dashboard CC/Marcas, locales, tarjetas de
   presentación. Image-card grid — 3 columnas en desktop, 1 en
   móvil, hover con elevación de sombra.
   ============================================================ */
.opp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.opp-card {
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
a.opp-card:hover {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-2px);
}
.opp-card-static { cursor: default; }

.opp-card-img {
  position: relative;
  height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface);
  overflow: hidden;
}
.opp-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.opp-card-img-avatar { background: var(--color-primary-tint); }
.opp-card-img .avatar-lg { width: 64px; height: 64px; font-size: 1.5rem; }
.opp-card-img-badge {
  position: absolute;
  top: 10px;
  right: 10px;
}

.opp-card-body {
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.opp-card-body h3 {
  margin: 0 0 2px;
  font-size: 1.02rem;
  color: var(--color-text);
}

.opp-card-stats {
  display: flex;
  gap: 20px;
  margin: 6px 0 2px;
}
.opp-card-stat { display: flex; flex-direction: column; }
.opp-card-stat strong {
  font-size: 1.4rem;
  color: var(--color-primary);
  line-height: 1.1;
}
.opp-card-stat span {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.opp-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0;
}
.opp-card-line { font-size: 0.85rem; }
.opp-card-brands {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 4px 0;
}
.opp-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--color-border-soft);
}

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

/* ============================================================
   v12 — Pipeline: metas financieras (barra de progreso) y
   comisiones inline; asistente IA flotante.
   ============================================================ */
.goal-progress-track {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xs);
  height: 10px;
  overflow: hidden;
  margin: 10px 0 6px;
}
.goal-progress-fill {
  height: 100%;
  background: var(--color-secondary);
  border-radius: var(--radius-xs);
  transition: width 0.2s ease;
}

.pipeline-inline-form {
  display: flex;
  align-items: center;
  gap: 4px;
}
.pipeline-pct-input {
  width: 90px;
  padding: 4px 6px;
}

/* ---------- Asistente IA — botón flotante + panel de chat ---------- */
.assistant-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 40;
  border-radius: 999px;
  width: 56px;
  height: 56px;
  padding: 0;
  font-size: 1.4rem;
  box-shadow: var(--shadow-md);
}

dialog#assistant-modal {
  width: min(420px, 92vw);
  height: min(600px, 85vh);
  padding: 0;
  right: 24px;
  bottom: 24px;
  left: auto;
  top: auto;
  margin: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}
dialog#assistant-modal::backdrop { background: transparent; }
.assistant-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.assistant-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-border-soft);
  background: var(--color-surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.assistant-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.assistant-bubble {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  white-space: pre-wrap;
}
.assistant-bubble-user {
  align-self: flex-end;
  background: var(--color-primary);
  color: #fff;
}
.assistant-bubble-assistant {
  align-self: flex-start;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
}
.assistant-bubble-error {
  align-self: flex-start;
  background: var(--color-danger-tint);
  color: var(--color-danger);
  border: 1px solid var(--color-danger);
}
.assistant-form {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--color-border-soft);
}
.assistant-form textarea {
  flex: 1;
  resize: none;
  min-height: 40px;
  max-height: 90px;
}
