/* ============ DESIGN TOKENS=*** */
:root {
  --bg: #f8f7f5;
  --surface: #ffffff;
  --surface-hover: #fafaf9;
  --border: #e8e4df;
  --border-light: #f0ece7;
  --text: #1a1816;
  --text-secondary: #8c8580;
  --text-tertiary: #b5afa8;
  --accent: #bd9a68;
  --accent-hover: #a88856;
  --accent-light: #f3ece0;
  --accent-subtle: #faf6f0;
  --dark: #2c2826;
  --dark-surface: #3d3533;
  --green: #2d8a56;
  --green-bg: #e8f5e9;
  --amber: #c4972e;
  --amber-bg: #fff8e1;
  --red: #c44a3d;
  --red-bg: #fbe9e7;
  --blue: #3b82f6;
  --blue-bg: #eff6ff;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --shadow-sm: 0 2px 6px rgba(0,0,0,0.06);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
  --shadow-xl: 0 20px 60px rgba(0,0,0,0.15);
  --transition: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============ RESET ============ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
.main-content:has(.kanban) { overflow-x: visible; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ============ SIDEBAR ============ */
.app-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px;
  background: var(--dark);
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  transition: transform var(--transition-slow);
}
.sidebar-brand { padding: 20px 20px 24px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.sidebar-brand h1 { font-size: 16px; font-weight: 300; letter-spacing: 3px; color: var(--accent); text-transform: lowercase; }
.sidebar-brand span { font-size: 10px; color: rgba(255,255,255,0.35); text-transform: uppercase; letter-spacing: 1.5px; display: block; margin-top: 4px; }
.sidebar-nav { flex: 1; padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px;
  color: rgba(255,255,255,0.55); font-size: 13px; font-weight: 500;
  background: transparent; border: none; width: 100%; text-align: left;
  transition: all var(--transition); position: relative;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.85); }
.nav-item.active { background: rgba(189,154,104,0.15); color: var(--accent); }
.nav-item.active::before {
  content: ''; position: absolute; left: -8px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; background: var(--accent); border-radius: 0 3px 3px 0;
}
.nav-icon { width: 18px; height: 18px; opacity: 0.7; flex-shrink: 0; }
.nav-badge { margin-left: auto; background: rgba(189,154,104,0.2); color: var(--accent); font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 10px; }
.sidebar-footer { padding: 16px; border-top: 1px solid rgba(255,255,255,0.08); display: flex; flex-direction: column; gap: 10px; }
.sidebar-user { display: flex; align-items: center; gap: 10px; }
.sidebar-user-actions { display: flex; border: 1px solid rgba(255,255,255,0.12); border-radius: var(--radius-sm); overflow: hidden; }
.sidebar-user-actions button { flex: 1; background: none; border: none; color: rgba(255,255,255,0.45); font-size: 12px; padding: 6px 0; cursor: pointer; transition: background var(--transition), color var(--transition); }
.sidebar-user-actions button:hover { background: rgba(255,255,255,0.07); color: rgba(255,255,255,0.85); }
.sidebar-user-actions button + button { border-left: 1px solid rgba(255,255,255,0.12); }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); display: flex; align-items: center; justify-content: center; color: white; font-weight: 600; font-size: 12px; flex-shrink: 0; }
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 500; color: rgba(255,255,255,0.85); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: rgba(255,255,255,0.35); }

/* ============ MAIN CONTENT ============ */
.main-content { flex: 1; margin-left: 220px; min-height: 100vh; }
.page-header {
  padding: 20px 28px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
}
.page-header-left { display: flex; align-items: center; gap: 14px; }
.page-title { font-size: 20px; font-weight: 600; }
.page-count { background: var(--accent-light); color: var(--accent); padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.page-header-right { display: flex; align-items: center; gap: 8px; }

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px;
  border-radius: var(--radius-sm); font-size: 13px; font-weight: 500;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  transition: all var(--transition); white-space: nowrap;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-ghost { border: none; background: transparent; }
.btn-ghost:hover { background: var(--accent-subtle); }
.btn-danger { border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: var(--red-bg); }
.filter-btn {
  padding: 6px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); font-size: 12px; color: var(--text-secondary); transition: all var(--transition);
}
.filter-btn:hover, .filter-btn.active { border-color: var(--accent); color: var(--accent); background: var(--accent-subtle); }

/* ============ KANBAN ============ */
.kanban {
  display: flex; gap: 12px; padding: 20px 28px; overflow-x: auto;
  min-height: calc(100vh - 80px); align-items: flex-start;
  -webkit-overflow-scrolling: touch; scroll-behavior: smooth;
  max-width: calc(100vw - 220px);
}
.kanban::-webkit-scrollbar { height: 8px; }
.kanban::-webkit-scrollbar-track { background: var(--border-light); border-radius: 4px; }
.kanban::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 4px; min-width: 60px; }
.kanban { overscroll-behavior-x: contain; touch-action: pan-x pan-y; }
.kanban-column {
  flex: 0 0 290px; min-width: 290px; background: var(--surface);
  border-radius: var(--radius-lg); border: 1px solid var(--border);
  display: flex; flex-direction: column; max-height: calc(100vh - 100px);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
}
.kanban-column.drag-over { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-light); }
.column-header { padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border-light); }
.column-title { display: flex; align-items: center; gap: 8px; }
.column-dot { width: 8px; height: 8px; border-radius: 50%; }
.column-name { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-secondary); }
.column-count { background: var(--bg); color: var(--text-secondary); padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.column-total { font-size: 11px; color: var(--text-tertiary); font-weight: 500; margin-left: auto; }
.column-cards {
  padding: 10px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 12px;
  transition: background var(--transition);
}
.kanban-column.drag-over .column-cards { background: var(--accent-subtle); }
.column-cards::-webkit-scrollbar { width: 4px; }
.column-cards::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.column-empty { text-align: center; padding: 30px 16px; color: var(--text-tertiary); font-size: 12px; }

/* ============ DEAL CARD ============ */
.deal-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 14px 14px 18px; cursor: grab;
  transition: all var(--transition); position: relative; overflow: hidden;
  box-shadow: var(--shadow-sm); flex-shrink: 0;
}
.deal-card::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--tipo, var(--accent));
}
.deal-card:hover { border-color: var(--accent); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.deal-card:active { cursor: grabbing; }
.deal-card.dragging { opacity: 0.4; transform: rotate(1deg) scale(0.98); }
.card-thumb { width: 100%; height: 80px; border-radius: var(--radius-sm); object-fit: cover; object-position: center; aspect-ratio: 16/9; margin-bottom: 10px; }
.card-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-bottom: 8px; }
.card-type {
  display: inline-flex; align-items: center; gap: 4px; line-height: 1;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px;
  padding: 3px 8px; border-radius: 6px;
}
.card-ref { font-size: 11px; font-weight: 600; color: var(--accent); letter-spacing: 0.3px; }
.card-badge { font-size: 9px; font-weight: 700; padding: 2px 6px; border-radius: 4px; text-transform: uppercase; letter-spacing: 0.5px; flex-shrink: 0; }
.card-move-btn { margin-left: auto; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; padding: 0; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text-secondary); cursor: pointer; }
.card-move-btn:hover { background: var(--accent-subtle); color: var(--accent); border-color: var(--accent); }
.move-stage-list { display: flex; flex-direction: column; gap: 6px; }
.move-stage-opt { display: flex; align-items: center; gap: 10px; width: 100%; padding: 13px 14px; text-align: left; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); font-size: 15px; cursor: pointer; }
.move-stage-opt:hover:not(:disabled) { background: var(--accent-subtle); border-color: var(--accent); }
.move-stage-opt:disabled { opacity: .55; cursor: default; }
.move-stage-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.move-stage-tag { margin-left: auto; font-size: 11px; color: var(--text-tertiary); font-weight: 600; }
@media (max-width: 768px) { .card-move-btn { width: 38px; height: 38px; } }
.badge-exclusiva { background: var(--accent); color: white; }
.badge-oferta { background: var(--blue); color: white; }
/* Generic badges — usable anywhere */
.badge { display: inline-flex; align-items: center; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 20px; white-space: nowrap; }
.badge-green  { background: var(--green-bg);  color: var(--green); }
.badge-red    { background: var(--red-bg);    color: var(--red); }
.badge-blue   { background: var(--blue-bg);   color: var(--blue); }
.badge-amber  { background: var(--amber-bg);  color: var(--amber); }
.card-address { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 2px; line-height: 1.3; }
.card-zona { font-size: 11px; color: var(--text-tertiary); margin-bottom: 10px; }
.card-meta { display: flex; gap: 10px; font-size: 12px; color: var(--text-secondary); margin-bottom: 10px; }
.card-meta span { display: flex; align-items: center; gap: 3px; }
.card-precio { font-size: 20px; font-weight: 800; color: var(--text); letter-spacing: -0.3px; margin-bottom: 12px; }
.card-footer { display: flex; justify-content: space-between; align-items: center; padding-top: 10px; border-top: 1px solid var(--border-light); }
.card-captador { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); }
.captador-dot {
  width: 22px; height: 22px; border-radius: 50%; background: var(--accent-light);
  color: var(--accent); display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700;
}
.card-dias { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; }
.dias-green { background: var(--green-bg); color: var(--green); }
.dias-amber { background: var(--amber-bg); color: var(--amber); }
.dias-red { background: var(--red-bg); color: var(--red); }

/* ============ DASHBOARD ============ */
.dashboard { padding: 24px 28px; display: none; }
.dashboard.active { display: block; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 24px; }
.kpi-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px; box-shadow: var(--shadow-sm); transition: all var(--transition); }
.kpi-card:hover { border-color: var(--accent); box-shadow: var(--shadow-md); }
.kpi-label { font-size: 11px; font-weight: 500; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.kpi-value { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1.1; }
.kpi-value.accent { color: var(--accent); }
.kpi-sub { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.dash-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow-sm); }
.dash-card-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 16px; text-transform: uppercase; letter-spacing: 0.3px; }
.pipeline-bar { display: flex; height: 32px; border-radius: 8px; overflow: hidden; margin-bottom: 12px; }
.pipeline-segment { display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; color: var(--text); transition: all var(--transition); position: relative; }
.pipeline-segment:hover { filter: brightness(0.95); }
.pipeline-legend { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.legend-item { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text-secondary); }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; }
.agent-row { display: flex; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border-light); }
.agent-row:last-child { border-bottom: none; }
.agent-name { width: 130px; font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.agent-bar-wrap { flex: 1; height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; margin: 0 12px; }
.agent-bar { height: 100%; background: var(--accent); border-radius: 3px; transition: width var(--transition-slow); }
.agent-stat { font-size: 12px; font-weight: 600; color: var(--text); min-width: 30px; text-align: right; }
.activity-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border-light); }
.activity-item:last-child { border-bottom: none; }
.activity-icon { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; flex-shrink: 0; }
.activity-icon.visita { background: var(--green-bg); color: var(--green); }
.activity-icon.llamada { background: var(--blue-bg); color: var(--blue); }
.activity-icon.whatsapp { background: var(--green-bg); color: var(--green); }
.activity-icon.email { background: var(--amber-bg); color: var(--amber); }
.activity-icon.oferta { background: var(--red-bg); color: var(--red); }
.activity-body { flex: 1; min-width: 0; }
.activity-title { font-size: 13px; font-weight: 500; color: var(--text); }
.activity-desc { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.activity-time { font-size: 11px; color: var(--text-tertiary); white-space: nowrap; }
.alert-item { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: var(--radius-sm); margin-bottom: 6px; font-size: 12px; }
.alert-item.high { background: var(--red-bg); color: var(--red); }
.alert-item.medium { background: var(--amber-bg); color: var(--amber); }

/* ============ DATA TABLE ============ */
.data-view { padding: 20px 28px; display: none; }
.data-view.active { display: block; }
.data-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.search-input {
  flex: 1; max-width: 320px; padding: 8px 14px 8px 36px;
  border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%238c8580' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zm-5.598.856a5 5 0 1 1 0-10 5 5 0 0 1 0 10z'/%3E%3C/svg%3E") no-repeat 12px center;
  transition: border-color var(--transition); outline: none;
}
.search-input:focus { border-color: var(--accent); }
.data-table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
}
.data-table th { text-align: left; padding: 10px 14px; font-size: 11px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; background: var(--bg); border-bottom: 1px solid var(--border); }
.data-table td { padding: 12px 14px; font-size: 13px; border-bottom: 1px solid var(--border-light); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--accent-subtle); }
.data-table tr { cursor: pointer; transition: background var(--transition); }
.cal-badge { display: inline-block; width: 22px; height: 22px; border-radius: 50%; text-align: center; line-height: 22px; font-size: 11px; font-weight: 700; color: white; }
.cal-A { background: var(--green); }
.cal-B { background: var(--amber); }
.cal-C { background: var(--red); }
.urgencia-badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; }
.urgencia-alta { background: var(--red-bg); color: var(--red); }
.urgencia-mitja { background: var(--amber-bg); color: var(--amber); }
.urgencia-baixa { background: var(--green-bg); color: var(--green); }
.match-score { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 10px; }
.score-high { background: var(--green-bg); color: var(--green); }
.score-mid { background: var(--amber-bg); color: var(--amber); }
.score-low { background: var(--red-bg); color: var(--red); }

/* ============ MODAL ============ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  backdrop-filter: blur(6px); z-index: 500; display: none;
  opacity: 0; transition: opacity var(--transition-slow);
}
.modal-overlay.show { display: flex; opacity: 1; align-items: flex-start; justify-content: center; padding: 40px 20px; overflow-y: auto; }
.modal {
  background: var(--surface); border-radius: var(--radius-xl);
  width: 720px; max-width: 95vw;
  box-shadow: 0 24px 64px rgba(0,0,0,0.14), 0 0 0 1px rgba(189,154,104,0.1);
  border-top: 2px solid var(--accent);
  transform: translateY(16px) scale(0.98); transition: transform var(--transition-slow);
  margin: auto 0;
}
.modal-overlay.show .modal { transform: translateY(0) scale(1); }
.modal-header {
  padding: 20px 24px 18px; display: flex; align-items: flex-start; justify-content: space-between;
  border-bottom: 1px solid var(--border-light);
  background: linear-gradient(160deg, var(--accent-subtle) 0%, var(--surface) 55%);
  position: sticky; top: 0;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0; z-index: 1;
}
.modal-title { font-size: 18px; font-weight: 600; line-height: 1.3; color: var(--text); }
.modal-subtitle { font-size: 13px; color: var(--text-secondary); margin-top: 3px; }
.modal-close {
  width: 30px; height: 30px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--text-secondary); font-size: 13px; display: flex; align-items: center;
  justify-content: center; transition: all var(--transition); flex-shrink: 0; cursor: pointer;
}
.modal-close:hover { background: var(--red-bg); color: var(--red); border-color: var(--red); }
.modal-body { padding: 20px 24px 24px; }
.inmueble-hero { position: relative; width: 100%; height: 220px; flex-shrink: 0; overflow: hidden; cursor: pointer; background: var(--bg); }
.inmueble-hero img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.3s ease; }
.inmueble-hero:hover img { transform: scale(1.03); }
.inmueble-hero::after { content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 60px; background: linear-gradient(to bottom, transparent, rgba(0,0,0,0.18)); pointer-events: none; }
.inmueble-hero-count { position: absolute; bottom: 10px; right: 12px; background: rgba(0,0,0,0.55); color: white; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 12px; backdrop-filter: blur(4px); }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 24px; border-top: 1px solid var(--border-light); }
.modal-text { font-size: 13px; color: var(--text-secondary); line-height: 1.6; margin: 0; }
.detail-tab { min-height: 320px; }
.modal-section { margin-bottom: 20px; }
.modal-section-title {
  font-size: 11px; font-weight: 600; color: var(--text-tertiary);
  text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 10px;
  display: flex; align-items: center; gap: 7px;
}
.modal-section-title::before {
  content: ''; width: 3px; height: 10px; background: var(--accent);
  border-radius: 2px; flex-shrink: 0;
}
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: start; }
.detail-item label { font-size: 11px; color: var(--text-tertiary); display: block; margin-bottom: 2px; }
.detail-item span { font-size: 14px; font-weight: 500; color: var(--text); }
.gestiones-timeline { border-left: 2px solid var(--border); padding-left: 16px; margin-top: 8px; }
.timeline-item { position: relative; padding-bottom: 14px; }
.timeline-item::before {
  content: ''; position: absolute; left: -21px; top: 5px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--accent); border: 2px solid var(--surface);
}
.timeline-date { font-size: 11px; color: var(--text-tertiary); }
.timeline-content { font-size: 13px; color: var(--text); margin-top: 2px; }

/* ============ PHOTO GALLERY ============ */
.photo-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-top: 8px; }
.photo-item { position: relative; border-radius: var(--radius-sm); overflow: hidden; aspect-ratio: 4/3; cursor: pointer; }
.photo-item img { width: 100%; height: 100%; object-fit: cover; transition: transform var(--transition); }
.photo-item:hover img { transform: scale(1.05); }
.photo-item .photo-actions {
  position: absolute; top: 4px; right: 4px; display: none; gap: 4px;
}
.photo-item:hover .photo-actions { display: flex; }
.photo-action-btn {
  width: 24px; height: 24px; border-radius: 50%; border: none;
  background: rgba(0,0,0,0.6); color: white; font-size: 11px;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.photo-action-btn:hover { background: var(--accent); }

/* ============ DOCUMENT LIST ============ */
.doc-list { margin-top: 8px; }
.doc-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--border-light); border-radius: var(--radius-sm); margin-bottom: 4px; transition: all var(--transition); }
.doc-item:hover { border-color: var(--accent); background: var(--accent-subtle); }
.doc-icon { font-size: 18px; }
.doc-info { flex: 1; min-width: 0; }
.doc-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-meta { font-size: 11px; color: var(--text-tertiary); }
.doc-actions { display: flex; gap: 4px; }

/* ============ FORMS ============ */
.form-input { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; background: var(--surface); color: var(--text); outline: none; transition: border var(--transition); }
.form-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(189,154,104,0.12); }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238c8580' viewBox='0 0 16 16'%3E%3Cpath d='M8 12L2 6h12z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; }
.form-textarea { resize: vertical; min-height: 60px; }
.form-check { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.form-check input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }
.equip-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }

/* ============ TABS ============ */
.tab-nav { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab-btn { padding: 8px 16px; font-size: 13px; font-weight: 500; color: var(--text-secondary); background: none; border: none; border-bottom: 2px solid transparent; transition: all var(--transition); }
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ============ DESCRIPTION RICH TEXT ============ */
.descripcion-rendered { line-height: 1.7; color: var(--text); }
.descripcion-rendered p { margin-bottom: 10px; }
.descripcion-rendered ul, .descripcion-rendered ol { margin: 8px 0 8px 20px; }
.descripcion-rendered li { margin-bottom: 4px; }
.descripcion-rendered strong { font-weight: 600; }

/* ============ HAMBURGER MOBILE ============ */
.hamburger { display: none; position: fixed; top: 12px; left: 12px; z-index: 300; width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 18px; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.3); z-index: 150; }
.sidebar-overlay.show { display: block; }

/* ============ LOGIN ============ */
.login-screen { position:fixed; inset:0; z-index:9999; display:flex; align-items:center; justify-content:center; background:var(--bg); }
.login-card { background:var(--surface); border-radius:16px; padding:48px 40px; width:100%; max-width:380px; box-shadow:0 8px 32px rgba(0,0,0,0.08); text-align:center; }
.login-logo { max-width:200px; height:auto; margin-bottom:16px; }
.login-card .subtitle { font-size:13px; color:var(--text-secondary); margin-bottom:32px; letter-spacing:2px; text-transform:uppercase; }
.login-field { width:100%; padding:12px 14px; font-size:14px; border:1px solid var(--border); border-radius:var(--radius); background:var(--bg); color:var(--text); margin-bottom:12px; box-sizing:border-box; outline:none; transition:border 0.2s; }
.login-field:focus { border-color:var(--accent); }
.login-btn { width:100%; padding:12px; background:var(--accent); color:white; border:none; border-radius:var(--radius); font-size:15px; font-weight:600; cursor:pointer; transition:0.2s; }
.login-btn:hover { background:#a88650; }
.login-btn:disabled { opacity:0.6; cursor:wait; }
.login-error { color:var(--red); font-size:13px; margin-top:12px; min-height:20px; }
.forgot-password { display:inline-block; margin-top:16px; font-size:13px; color:var(--text-secondary); text-decoration:none; transition:color 0.2s; }
.forgot-password:hover { color:var(--accent); }
.login-card .version { font-size:11px; color:var(--text-tertiary); margin-top:16px; }

/* ============ SETTINGS ============ */
.settings-layout { display: flex; gap: 0; min-height: calc(100vh - 80px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm); }
.settings-sidebar { width: 216px; background: var(--bg); border-right: 1px solid var(--border); padding: 12px 8px; flex-shrink: 0; overflow-y: auto; }
.settings-nav-group { margin-bottom: 20px; }
.settings-nav-group-label { font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-tertiary); padding: 0 8px; margin-bottom: 4px; display: block; }
.settings-tab { display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: var(--radius-sm); border: none; background: none; width: 100%; text-align: left; font-size: 13px; color: var(--text-secondary); cursor: pointer; transition: all var(--transition); }
.settings-tab:hover { background: var(--surface); color: var(--text); }
.settings-tab.active { background: var(--surface); color: var(--accent); font-weight: 600; box-shadow: var(--shadow-sm); }
.settings-tab .tab-icon { font-size: 15px; width: 20px; text-align: center; flex-shrink: 0; }
.settings-content { flex: 1; padding: 28px 36px; overflow-y: auto; max-height: calc(100vh - 130px); }

/* Settings page header */
.settings-page-title { font-size: 20px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.settings-page-desc { font-size: 13px; color: var(--text-secondary); margin-bottom: 28px; }

/* Setting rows */
.settings-section { margin-bottom: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm); }
.settings-section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-tertiary); padding: 12px 20px; background: var(--bg); border-bottom: 1px solid var(--border); }
.setting-row { display: flex; align-items: center; justify-content: space-between; padding: 13px 20px; border-bottom: 1px solid var(--border-light); gap: 24px; }
.setting-row:last-child { border-bottom: none; }
.setting-label-group { flex: 1; min-width: 0; }
.setting-label { font-size: 13px; font-weight: 500; color: var(--text); }
.setting-desc { font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }
.setting-control { flex-shrink: 0; }
.setting-control input[type="text"], .setting-control input[type="number"], .setting-control input[type="email"], .setting-control input[type="password"],
.setting-control select { width: 220px; padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; background: var(--surface); color: var(--text); transition: border-color var(--transition); }
.setting-control input:focus, .setting-control select:focus { outline: none; border-color: var(--accent); }
.setting-control input[type="color"] { width: 44px; height: 34px; padding: 2px 4px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; }

/* Inline save feedback */
.setting-saved { font-size: 11px; color: var(--green); margin-left: 8px; opacity: 0; transition: opacity 0.3s; }
.setting-saved.show { opacity: 1; }

/* Toggle switch */
.toggle { position: relative; display: inline-block; width: 42px; height: 24px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: #d0cbc4; border-radius: 12px; cursor: pointer; transition: 0.25s; }
.toggle-slider::before { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: 0.25s; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }
.toggle input:disabled + .toggle-slider { opacity: 0.5; cursor: not-allowed; }

/* ============ EQUIPO TABLE ============ */
.equipo-table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.equipo-table { width: 100%; border-collapse: collapse; }
.equipo-table th { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-tertiary); padding: 10px 14px; background: var(--bg); border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.equipo-table td { padding: 12px 14px; border-bottom: 1px solid var(--border-light); vertical-align: middle; font-size: 13px; }
.equipo-table tr:last-child td { border-bottom: none; }
.equipo-table tr:hover td { background: var(--accent-subtle); }
.equipo-avatar { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.equipo-agent-cell { display: flex; align-items: center; gap: 10px; }
.equipo-name { font-weight: 600; color: var(--text); }
.equipo-email { font-size: 12px; color: var(--text-tertiary); }
.rol-badge { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 10px; display: inline-block; }
.rol-gerente { background: #f3e5f5; color: #7b1fa2; }
.rol-captador { background: var(--blue-bg); color: var(--blue); }
.rol-comprador { background: var(--green-bg); color: var(--green); }
.rol-operaciones { background: var(--amber-bg); color: var(--amber); }
.rol-bot { background: var(--bg); color: var(--text-tertiary); }
.equipo-actions { display: flex; gap: 6px; justify-content: flex-end; }
.btn-icon { width: 30px; height: 30px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text-secondary); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 14px; transition: all var(--transition); }
.btn-icon:hover { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }
.btn-icon.danger:hover { background: var(--red-bg); border-color: var(--red); color: var(--red); }

/* Portals grid */
.portals-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.portal-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.portal-logo { font-size: 28px; text-align: center; }
.portal-name { font-size: 14px; font-weight: 600; text-align: center; color: var(--text); }
.portal-status { text-align: center; }
.portal-toggle { display: flex; justify-content: center; margin-top: 4px; }

/* ============ QUILL OVERRIDES ============ */
.ql-container { min-height: 250px; }
.ql-editor { min-height: 220px; }

/* ============ LIGHTBOX ============ */
.lightbox-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.92);
  z-index: 1000; display: none; align-items: center; justify-content: center;
}
.lightbox-overlay.show { display: flex; }
.lightbox-img { max-width: 90vw; max-height: 88vh; border-radius: var(--radius); object-fit: contain; box-shadow: var(--shadow-xl); }
.lightbox-close { position: absolute; top: 20px; right: 24px; width: 40px; height: 40px; border-radius: 50%; border: none; background: rgba(255,255,255,0.15); color: white; font-size: 22px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.lightbox-close:hover { background: rgba(255,255,255,0.3); }
.lightbox-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 50%; border: none; background: rgba(255,255,255,0.15); color: white; font-size: 20px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.lightbox-nav:hover { background: rgba(255,255,255,0.3); }
.lightbox-prev { left: 20px; }
.lightbox-next { right: 20px; }
.lightbox-counter { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); color: rgba(255,255,255,0.7); font-size: 13px; }

/* ============ SCORING BADGES ============ */
.scoring-badge { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 10px; letter-spacing: 0.3px; }
.scoring-A { background: var(--green-bg); color: var(--green); }
.scoring-B { background: var(--blue-bg); color: var(--blue); }
.scoring-C { background: var(--amber-bg); color: var(--amber); }
.scoring-D { background: var(--red-bg); color: var(--red); }

/* ============ SEARCH + FILTER TOOLBAR ============ */
.data-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.scoring-filter { display: flex; gap: 4px; }
.scoring-filter-btn { padding: 5px 12px; border-radius: 20px; border: 1px solid var(--border); background: var(--surface); font-size: 12px; font-weight: 600; cursor: pointer; transition: all var(--transition); }
.scoring-filter-btn:hover { border-color: var(--accent); }
.scoring-filter-btn.active-A { background: var(--green-bg); color: var(--green); border-color: var(--green); }
.scoring-filter-btn.active-B { background: var(--blue-bg); color: var(--blue); border-color: var(--blue); }
.scoring-filter-btn.active-C { background: var(--amber-bg); color: var(--amber); border-color: var(--amber); }
.scoring-filter-btn.active-D { background: var(--red-bg); color: var(--red); border-color: var(--red); }
.scoring-filter-btn.active-all { background: var(--accent-light); color: var(--accent); border-color: var(--accent); }

/* ============ LEAD CARD (listado enriquecido) ============ */
.lead-card { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-bottom: 1px solid var(--border-light); cursor: pointer; transition: background var(--transition); }
.lead-card:hover { background: var(--accent-subtle); }
.lead-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--accent-light); color: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; flex-shrink: 0; }
.lead-info { flex: 1; min-width: 0; }
.lead-name { font-size: 14px; font-weight: 600; color: var(--text); }
.lead-meta { font-size: 12px; color: var(--text-secondary); margin-top: 2px; display: flex; gap: 10px; flex-wrap: wrap; }
.lead-meta span { display: flex; align-items: center; gap: 4px; }
.lead-tipo { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; background: var(--bg); color: var(--text-secondary); }

/* ============ DEMANDA CARD ============ */
.demanda-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border-light); cursor: pointer; transition: background var(--transition); }
.demanda-row:hover { background: var(--accent-subtle); }
.demanda-score-circle { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 16px; flex-shrink: 0; }
.score-circle-A { background: var(--green-bg); color: var(--green); }
.score-circle-B { background: var(--blue-bg); color: var(--blue); }
.score-circle-C { background: var(--amber-bg); color: var(--amber); }
.score-circle-D { background: var(--red-bg); color: var(--red); }
.score-circle-none { background: var(--bg); color: var(--text-tertiary); }

/* ============ CEDES VIEW ============ */
.cedes-banner { background: var(--amber-bg); border: 1px solid var(--amber); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; font-size: 13px; color: var(--amber); display: flex; align-items: center; gap: 8px; }

/* ============ KANBAN FILTERS ============ */
.kanban-filters {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 28px 10px;
  align-items: center; border-bottom: 1px solid var(--border-light);
  background: var(--surface);
}
.kf-group { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.kf-tipo { display: inline-flex; align-items: center; gap: 5px; }
.kf-tipo-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.kf-sep { width: 1px; height: 20px; background: var(--border); margin: 0 6px; }
.kf-label { font-size: 10px; font-weight: 700; color: var(--text-tertiary);
  text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap; }
.kf-pill { padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 500;
  border: 1px solid var(--border); background: var(--bg); color: var(--text-secondary);
  cursor: pointer; transition: all var(--transition); white-space: nowrap; }
.kf-pill:hover { border-color: var(--accent); color: var(--accent); }
.kf-pill.active { background: var(--accent); color: white; border-color: var(--accent); }
.kf-pill.active-all { background: var(--bg); color: var(--text); border-color: var(--border); font-weight: 600; }
.kf-pill.active-all.active { background: var(--accent-light); color: var(--accent); border-color: var(--accent); }
.kf-clear { font-size: 11px; color: var(--text-tertiary); cursor: pointer; padding: 2px 6px;
  border-radius: 8px; transition: all var(--transition); margin-left: 4px; }
.kf-clear:hover { color: var(--red); background: var(--red-bg); }
.kf-price-input { width: 88px; padding: 2px 7px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 12px; background: var(--bg); color: var(--text); font-family: inherit; outline: none; }
.kf-price-input:focus { border-color: var(--accent); }
.kf-price-sep { font-size: 11px; color: var(--text-tertiary); padding: 0 2px; }
.kanban-filter-bar { background: var(--surface); border-bottom: 1px solid var(--border-light); }

/* ============ RUEDA DE ASIGNACIONES ============ */
.demandas-layout { display: flex; gap: 16px; align-items: flex-start; }
.demandas-main { flex: 1; min-width: 0; }
.rueda-panel { width: 252px; flex-shrink: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; position: sticky; top: 20px; align-self: flex-start; box-shadow: var(--shadow-sm); }
.rueda-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.rueda-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; }
.rueda-next-label { font-size: 11px; color: var(--text-tertiary); margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--border-light); }
.rueda-next-label strong { color: var(--accent); }
.rueda-agent { display: flex; align-items: center; gap: 9px; padding: 7px 8px; border-radius: var(--radius-sm); margin-bottom: 3px; transition: background var(--transition); }
.rueda-agent.is-next { background: var(--accent-light); border: 1px solid #e8d5b0; }
.rueda-agent:not(.is-next) { border: 1px solid transparent; }
.rueda-avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--bg); color: var(--text-secondary); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex-shrink: 0; }
.rueda-agent.is-next .rueda-avatar { background: var(--accent); color: white; }
.rueda-agent-name { font-size: 12px; font-weight: 500; color: var(--text); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rueda-agent.is-next .rueda-agent-name { color: var(--accent); font-weight: 600; }
.rueda-agent-count { font-size: 11px; color: var(--text-tertiary); background: var(--bg); border-radius: 10px; padding: 1px 6px; flex-shrink: 0; }
.rueda-next-indicator { font-size: 14px; line-height: 1; }
.rueda-actions { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border-light); display: flex; flex-direction: column; gap: 6px; }
.btn-rueda-assign { width: 100%; padding: 8px; background: var(--accent); color: white; border: none; border-radius: var(--radius-sm); font-size: 12px; font-weight: 600; cursor: pointer; transition: background var(--transition); }
.btn-rueda-assign:hover { background: var(--accent-hover); }
.btn-rueda-skip { width: 100%; padding: 6px; background: transparent; color: var(--text-tertiary); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 11px; cursor: pointer; transition: all var(--transition); }
.btn-rueda-skip:hover { border-color: var(--amber); color: var(--amber); }


/* ============ ZONAS SETTINGS ============ */
.zonas-muni-group { margin-bottom: 24px; }
.zonas-muni-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-tertiary); margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.zonas-muni-badge { background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 1px 8px; font-size: 11px; color: var(--text-tertiary); font-weight: 400; }
.zona-row { display: flex; align-items: center; gap: 10px; padding: 7px 10px;
  border-radius: var(--radius-sm); border: 1px solid transparent; margin-bottom: 3px; }
.zona-row:hover { background: var(--bg); border-color: var(--border-light); }
.zona-row-name { flex: 1; font-size: 13px; color: var(--text); }
.zona-row-cp { font-size: 11px; color: var(--text-tertiary); }
.zona-row-actions { display: flex; gap: 4px; opacity: 0; transition: opacity var(--transition); }
.zona-row:hover .zona-row-actions,
.setting-row:hover .zona-row-actions { opacity: 1; }
.zona-add-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px;
  margin-top: 12px; }
.zona-add-form .form-group { display: flex; flex-direction: column; gap: 4px; }
.zona-add-form label { font-size: 11px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.04em; }

/* ============ TOAST NOTIFICATIONS ============ */
#toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 11000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  width: max-content;
  max-width: min(480px, calc(100vw - 32px));
}
.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 24px;
  border-radius: 11px;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.4;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  pointer-events: auto;
  cursor: pointer;
  animation: toast-in 0.25s cubic-bezier(0.34,1.46,0.64,1);
  transition: opacity 0.2s ease, transform 0.2s ease;
  border-left: 4px solid transparent;
  white-space: nowrap;
}
.toast-out { opacity: 0; transform: translateY(-10px); }
.toast-icon { font-size: 18px; flex-shrink: 0; font-style: normal; }
@keyframes toast-in { from { opacity:0; transform:translateY(-16px); } to { opacity:1; transform:none; } }
.toast-success { background:var(--green-bg); color:var(--green); border-left-color:var(--green); }
.toast-error   { background:var(--red-bg);   color:var(--red);   border-left-color:var(--red); }
.toast-warning { background:#fffbeb; color:#92400e; border-left-color:#f59e0b; }
.toast-info    { background:var(--surface); color:var(--text-primary); border:1px solid var(--border); border-left:3px solid var(--accent); }

/* ============ CONFIRM DIALOG ============ */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.42);
  z-index: 10500;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fade-in 0.15s ease;
}
.confirm-dialog {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 48px rgba(0,0,0,0.2);
  padding: 24px 24px 18px;
  max-width: 360px;
  width: calc(100% - 40px);
  animation: modal-scale 0.18s cubic-bezier(0.34,1.36,0.64,1);
}
.confirm-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}
.confirm-msg {
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.55;
  margin-bottom: 20px;
  white-space: pre-line;
}
.confirm-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.btn-danger-fill {
  background: var(--red);
  color: white;
  border-color: var(--red);
}
.btn-danger-fill:hover { background: #b03d31; border-color: #b03d31; }

/* ============ View toggle (Kanban/Lista) ============ */
.view-toggle { display: inline-flex; gap: 0; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 3px; }
.view-toggle .vt-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 11px; font-size: 12px; font-weight: 600;
  border: none; background: transparent; color: var(--text-secondary);
  border-radius: calc(var(--radius) - 3px); cursor: pointer; transition: all .15s;
}
.view-toggle .vt-btn:hover { color: var(--text); }
.view-toggle .vt-btn.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }

/* ============ Pipeline list mode ============ */
.pipeline-list-section { margin-bottom: 18px; }
.pipeline-list-header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 14px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0; border-bottom: none;
  font-size: 12px; font-weight: 600; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: .5px;
}
.pipeline-list-header .stage-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.pipeline-list-body { background: var(--surface); border: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius); overflow: hidden; }
.pipeline-list-row {
  display: grid; grid-template-columns: 44px 1fr 90px 70px 110px 110px 100px;
  align-items: center; gap: 10px;
  padding: 10px 14px; cursor: pointer; border-top: 1px solid var(--border-light);
  transition: background .12s;
}
.pipeline-list-row:first-child { border-top: none; }
.pipeline-list-row:hover { background: var(--bg); }
.pipeline-list-row .plr-thumb { width: 40px; height: 40px; border-radius: var(--radius-sm); object-fit: cover; background: var(--bg); }
.pipeline-list-row .plr-name { font-size: 13px; font-weight: 600; color: var(--text); line-height: 1.3; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pipeline-list-row .plr-sub { font-size: 11px; color: var(--text-tertiary); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pipeline-list-row .plr-cell { font-size: 12px; color: var(--text-secondary); text-align: right; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pipeline-list-row .plr-precio { font-size: 14px; font-weight: 700; color: var(--accent); text-align: right; }
.pipeline-list-row .plr-dias { display: inline-block; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 10px; }
.plr-dias.dias-green { background: var(--green-bg); color: var(--green); }
.plr-dias.dias-amber { background: var(--amber-bg); color: var(--amber); }
.plr-dias.dias-red   { background: var(--red-bg); color: var(--red); }

/* ---- Tabla de permisos (scopes) del agente — grid propio, full-width ---- */
.scope-table {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.scope-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px 64px 64px;
  align-items: center;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
}
.scope-table .scope-grid:last-child { border-bottom: none; }
.scope-grid > span { text-align: center; }
.scope-grid .scope-res {
  text-align: left;
  font-size: 13px;
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.scope-grid.scope-head {
  background: var(--bg);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-tertiary);
}
.scope-grid.scope-head .scope-res { font-weight: 700; }

/* ============ MOBILE RESPONSIVE (al final: gana sobre las reglas base) ============ */
@media (max-width: 768px) {
  /* ---- Permisos del agente: columnas más estrechas, se mantiene la rejilla ---- */
  .scope-grid {
    grid-template-columns: minmax(0, 1fr) 46px 46px 46px;
    padding: 8px 10px;
  }
  .scope-grid.scope-head { font-size: 10px; }

  /* ---- Foundation: no tap-zoom, native touch feel ---- */
  * { -webkit-tap-highlight-color: transparent; }
  input, select, textarea,
  .form-input, .search-input, .login-field, .kf-price-input,
  .setting-control input, .setting-control select { font-size: 16px !important; }

  /* ---- Navigation: drawer + top hamburger ---- */
  .hamburger {
    display: flex; align-items: center; justify-content: center;
    top: max(10px, env(safe-area-inset-top)); left: 12px;
    width: 40px; height: 40px; box-shadow: var(--shadow-md);
  }
  .sidebar { transform: translateX(-100%); width: 82vw; max-width: 300px; box-shadow: var(--shadow-xl); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-nav { padding: 10px; gap: 3px; }
  .nav-item { font-size: 15px; padding: 12px 14px; }
  /* min-width:0 lets the flex item shrink instead of being stretched by wide
     children (e.g. the Equipo table), which otherwise balloons the mobile viewport */
  .main-content { margin-left: 0; min-width: 0; }

  /* ---- Page headers: clear the hamburger, allow wrap ---- */
  .page-header {
    padding: 12px 16px 12px 64px !important;
    flex-wrap: wrap; gap: 8px; row-gap: 10px; min-height: 60px;
  }
  .page-title { font-size: 18px; }
  .page-header-right { margin-left: auto; }
  .page-header-right .btn { font-size: 13px; padding: 9px 13px; }

  /* ---- View paddings (sin padding-top: el header va a tope, alineado con la
     hamburguesa fija, igual que en Operaciones) ---- */
  .dashboard, .data-view { padding: 0 16px 16px; }
  .dashboard-grid { grid-template-columns: minmax(0, 1fr); }
  .kpi-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
  .kpi-card { padding: 14px 16px; }
  .kpi-value { font-size: 24px; }
  /* Donut de Operaciones: capar tamaño para que no ensanche el viewport */
  .dash-card svg[viewBox="0 0 136 136"] { max-width: 120px !important; max-height: 150px !important; min-height: 0 !important; }

  /* ---- Toolbars: full-width search, wrap filters ---- */
  .data-toolbar { gap: 8px; }
  .search-input { max-width: none; flex: 1 1 100%; padding-top: 10px; padding-bottom: 10px; }
  .filter-btn { padding: 8px 13px; }

  /* ---- Tables → stacked cards (Leads, Prospectos) ---- */
  #leads-list, #prospectos-list, #contactos-list, #gestiones-list, #cedes-list, #demandas-list {
    background: transparent !important; border: none !important;
    box-shadow: none !important; overflow: visible !important;
  }
  .data-table { display: block; width: 100%; border: none; background: transparent; border-radius: 0; }
  .data-table thead { display: none; }
  .data-table tbody, .data-table tr { display: block; width: 100%; }
  .data-table tr {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-sm);
    padding: 12px 14px; margin-bottom: 10px;
  }
  .data-table tr:active { background: var(--accent-subtle); }
  .data-table tr:hover td { background: transparent; }
  .data-table td {
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    padding: 5px 0; border: none; font-size: 14px; text-align: right;
  }
  .data-table td::before {
    content: attr(data-label);
    font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
    color: var(--text-tertiary); text-align: left; flex-shrink: 0;
  }
  .data-table td[data-label=""]::before { display: none; }
  .data-table td[data-label=""] { padding-top: 10px; }
  .data-table td[data-label=""] .btn { width: 100%; justify-content: center; }
  .data-table td:empty { display: none; }
  .col-sec { display: none !important; }

  /* ---- Settings: stack, nav becomes horizontal tab strip ---- */
  /* La hamburguesa va arriba; los tabs en su propia fila debajo, sin
     compartir espacio con el botón → menos apretado y más tocable.
     Forzamos el padding-top con !important porque .dashboard, .data-view
     pone padding: 0 16px 16px que lo pisa. */
  #view-settings { padding-top: 56px !important; }
  .settings-layout { flex-direction: column; min-height: 0; border-radius: var(--radius); margin-top: 0; }
  .settings-sidebar {
    width: 100%; display: flex; flex-direction: row; gap: 4px;
    overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap;
    border-right: none; border-bottom: 1px solid var(--border);
    padding: 10px 12px;
    scroll-padding-left: 16px;
    scroll-padding-right: 16px;
    scroll-behavior: smooth;
  }
  .settings-nav-group { display: flex; gap: 4px; margin-bottom: 0; flex-shrink: 0; }
  .settings-nav-group-label { display: none; }
  .settings-tab { width: auto; flex-shrink: 0; padding: 9px 13px; }
  /* La tab activa visualmente destacada para que sea inconfundible */
  .settings-tab.active { background: var(--accent); color: white; }
  .settings-tab.active .tab-icon { color: white; }
  .settings-content { padding: 20px 16px; max-height: none; min-width: 0; overflow-x: hidden; }
  .setting-row { flex-direction: column; align-items: stretch; gap: 10px; }
  .setting-control { width: 100%; }
  .setting-control input, .setting-control select { width: 100% !important; }
  .settings-section-title { padding: 12px 16px; }

  /* ---- Equipo / Usuarios tables (admin): horizontal scroll ---- */
  .equipo-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
  .equipo-table { min-width: 560px; }

  /* Tablas en settings que viven dentro de un wrap con overflow-x:auto:
     forzamos min-width para que realmente se vea el scroll horizontal en
     vez de quedarse el contenido cortado sin manera de acceder a él.
     Sombra interna a la derecha como pista visual de "hay más contenido". */
  .settings-content [style*="overflow-x:auto"],
  .settings-content [style*="overflow-x: auto"] {
    -webkit-overflow-scrolling: touch;
    box-shadow: inset -8px 0 8px -8px rgba(0,0,0,0.18);
  }
  .settings-content [style*="overflow-x:auto"] > .equipo-table,
  .settings-content [style*="overflow-x: auto"] > .equipo-table { min-width: 560px; }
  /* Mensaje sutil debajo del wrap "← desliza para ver más →" */
  .settings-content [style*="overflow-x:auto"]::after,
  .settings-content [style*="overflow-x: auto"]::after {
    content: none; /* deshabilitado por ahora; el shadow basta */
  }

  /* ---- Demandas: stack list + rueda ---- */
  .demandas-layout { flex-direction: column; }
  .rueda-panel { width: 100%; position: static; }

  /* ---- Kanban: paged columns with snap, compact filters ---- */
  .kanban {
    padding: 12px; gap: 12px; max-width: 100vw; min-height: 0;
    scroll-snap-type: x mandatory;
  }
  .kanban-column {
    flex: 0 0 86vw; min-width: 86vw; max-width: 360px;
    scroll-snap-align: start; max-height: calc(100dvh - 168px);
  }
  .kanban-filters { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 8px 12px; gap: 8px; }
  .kf-group { flex-shrink: 0; flex-wrap: nowrap; }
  .kf-sep { flex-shrink: 0; }

  /* Pipeline list mode móvil:
     Layout: card por inmueble con 3 columnas en cabecera (thumb | info | precio)
     y debajo una segunda fila a ancho completo con tipo + meta + captador + días,
     en flex-wrap para que no se solape nada. */
  .pipeline-list-row {
    display: grid;
    grid-template-columns: 50px minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    row-gap: 6px; column-gap: 10px; padding: 12px;
  }
  .pipeline-list-row .plr-thumb {
    grid-column: 1; grid-row: 1; align-self: center;
    width: 46px; height: 46px;
  }
  .pipeline-list-row .plr-info  {
    grid-column: 2; grid-row: 1; min-width: 0; align-self: center;
  }
  .pipeline-list-row .plr-precio {
    grid-column: 3; grid-row: 1; align-self: center;
    font-size: 14px; font-weight: 700; color: var(--accent);
    text-align: right; white-space: nowrap;
  }
  /* La cabecera ocupa toda la primera fila. La segunda fila lleva todos los
     plr-cell apilados en un wrap horizontal a ancho completo. Para que el
     navegador entienda que cada plr-cell tiene su propio orden visual,
     usamos display:contents en un truco: definimos cada uno en columnas
     individuales del grid de la 2ª fila. */
  .pipeline-list-row .plr-cell {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 11px; color: var(--text-secondary);
    grid-row: 2;
  }
  .pipeline-list-row .plr-tipo      { grid-column: 1 / 4; justify-self: start; }
  .pipeline-list-row .plr-meta      { grid-column: 1 / 4; grid-row: 3; }
  .pipeline-list-row .plr-cap       { grid-column: 1 / 4; grid-row: 4; }
  .pipeline-list-row .plr-dias-wrap { grid-column: 1 / 4; grid-row: 5; justify-self: start; }
  .pipeline-list-row .plr-excl {
    margin-left: 6px; font-size: 10px; padding: 2px 6px; border-radius: 8px;
    background: var(--accent-subtle); color: var(--accent); font-weight: 700;
  }

  /* ---- Modal → full-screen sheet ---- */
  /* flex-start (no stretch): el modal crece con su contenido en vez de quedar
     fijado a la altura del viewport (si no, el fondo blanco se corta y el
     contenido sobrante queda sobre el overlay) */
  .modal-overlay.show { padding: 0; align-items: flex-start; }
  .modal {
    width: 100%; max-width: 100%; min-height: 100dvh;
    border-radius: 0; border-top: none; margin: 0;
  }
  .modal-header { border-radius: 0; padding: 14px 16px; padding-top: max(14px, env(safe-area-inset-top)); }
  .modal-body { padding: 16px; }
  .modal-footer { flex-wrap: wrap; padding: 16px; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .modal-footer .btn { flex: 1; justify-content: center; }
  .detail-grid { grid-template-columns: 1fr; }
  .equip-grid { grid-template-columns: repeat(2, 1fr); }
  .modal-body [style*="grid-template-columns:1fr 1fr"],
  .modal-body [style*="grid-template-columns: 1fr 1fr"] { grid-template-columns: 1fr !important; }
  .tab-nav { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .tab-nav::-webkit-scrollbar { display: none; }
  .tab-btn { white-space: nowrap; flex-shrink: 0; }
  .inmueble-hero { height: 200px; }

  /* ---- Misc ---- */
  .photo-gallery { grid-template-columns: 1fr 1fr; }
  #toast-container { max-width: calc(100vw - 32px); top: 12px; }
  .toast { white-space: normal; font-size: 16px; padding: 14px 18px; }
}
