/* ============================================================
   POVPO CRM – Main Stylesheet (RTL / Hebrew)
   ============================================================ */

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

:root {
  --primary:       #6C63FF;
  --primary-light: #EDE9FF;
  --primary-dark:  #5A52D5;
  --success:       #10B981;
  --success-light: #D1FAE5;
  --warning:       #F59E0B;
  --warning-light: #FEF3C7;
  --danger:        #EF4444;
  --danger-light:  #FEE2E2;
  --info:          #3B82F6;
  --info-light:    #DBEAFE;
  --purple:        #8B5CF6;
  --purple-light:  #EDE9FE;
  --invested:      #059669;

  --bg:            #F8F9FC;
  --card-bg:       #FFFFFF;
  --border:        #E5E7EB;
  --border-focus:  #6C63FF;
  --text:          #1F2937;
  --text-muted:    #6B7280;
  --text-light:    #9CA3AF;

  --sidebar-w:     240px;
  --header-h:      64px;
  --radius:        10px;
  --radius-sm:     6px;
  --shadow:        0 1px 4px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --shadow-sm:     0 1px 3px rgba(0,0,0,.06);
}

html { font-size: 16px; }
body {
  font-family: 'Heebo', sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  min-height: 100vh;
}

/* ── Layout ─────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: #1E1B4B;
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; right: 0; bottom: 0;
  z-index: 100;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.brand-logo { font-size: 28px; }
.brand-name { font-size: 15px; font-weight: 700; }
.brand-sub  { font-size: 11px; color: rgba(255,255,255,.5); }
/* ── Logo image sizes ──────────────────────────────────────── */
.brand-logo-img          { display: block; object-fit: contain; border-radius: 4px; }
.brand-logo-img--sidebar { height: 54px; width: auto; margin: 0 auto; }
.brand-logo-img--mobile  { height: 32px; width: auto; }
.brand-logo-img--login   { height: 130px; width: auto; margin: 0 auto 12px; }
.brand-logo-img--landing { height: 30px; width: auto; margin: 0 auto 10px; }
.brand-logo-img--report  { height: 14px; width: auto; vertical-align: middle; margin-left: 6px; }

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.7);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all .15s;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-icon { font-size: 18px; width: 22px; text-align: center; }

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,.1);
  font-size: 13px;
}
.user-info { display: flex; align-items: center; gap: 8px; color: rgba(255,255,255,.8); }
.user-avatar { font-size: 20px; }
.logout-btn {
  color: rgba(255,255,255,.5);
  font-size: 18px;
  text-decoration: none;
  transition: color .15s;
}
.logout-btn:hover { color: var(--danger); }

/* ── Main Content ────────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-right: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px 0;
  min-height: 64px;
}
.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}
.page-actions { display: flex; gap: 10px; align-items: center; }
.page-body { padding: 20px 28px 40px; flex: 1; }

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── KPI Cards ───────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.kpi-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.kpi-icon.purple { background: var(--primary-light); }
.kpi-icon.green  { background: var(--success-light); }
.kpi-icon.orange { background: var(--warning-light); }
.kpi-icon.blue   { background: var(--info-light); }
.kpi-value { font-size: 28px; font-weight: 700; line-height: 1; }
.kpi-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: none;
  font-family: 'Heebo', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all .15s;
  white-space: nowrap;
}
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success   { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(.9); }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.9); }
.btn-warning   { background: var(--warning); color: #fff; }
.btn-ghost     { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-sm        { padding: 5px 12px; font-size: 13px; }
.btn-icon      { padding: 7px; width: 34px; height: 34px; justify-content: center; }

/* ── Forms ───────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--text); }
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'Heebo', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: #fff;
  direction: rtl;
  transition: border-color .15s;
}
.form-control:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(108,99,255,.12);
}
textarea.form-control { resize: vertical; min-height: 90px; }
select.form-control { cursor: pointer; }

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

/* ── Table ───────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table thead th {
  background: var(--bg);
  padding: 10px 14px;
  text-align: right;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.data-table thead th.sortable {
  cursor: pointer;
  user-select: none;
}
.data-table thead th.sortable:hover {
  background: var(--primary-light);
  color: var(--primary);
}
.data-table thead th.sort-active {
  color: var(--primary);
}
.sort-icon {
  font-size: 11px;
  opacity: 0.5;
  margin-right: 4px;
}
th.sort-active .sort-icon {
  opacity: 1;
}
.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .1s;
  position: relative;
}
.data-table tbody tr:hover { background: #F5F3FF; }
.data-table tbody td {
  padding: 11px 14px;
  vertical-align: middle;
}
.data-table tbody tr.inactive-lead {
  border-right: 4px solid var(--danger);
}
.data-table tbody tr.inactive-lead td:last-child::after {
  content: ' ⚠';
  color: var(--danger);
}

/* ── Status Badge ────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

/* ── Filter Bar ──────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.filter-bar .form-control { width: auto; min-width: 160px; }
.search-box { position: relative; }
.search-box .form-control { padding-right: 36px; }
.search-box::before {
  content: '🔍';
  position: absolute;
  right: 10px; top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  pointer-events: none;
}

/* ── Tabs ────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}
.tab-btn {
  padding: 10px 20px;
  border: none;
  background: none;
  font-family: 'Heebo', sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all .15s;
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Drawer (as centered popup) ─────────────────────────────── */
.drawer-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.drawer-overlay.open { display: flex; }

.drawer {
  position: relative;
  width: min(900px, 92vw);
  max-height: 88vh;
  background: #fff;
  z-index: 201;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  transform: scale(.95);
  opacity: 0;
  transition: transform .2s ease, opacity .2s ease;
}
.drawer.open {
  transform: scale(1);
  opacity: 1;
}
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.drawer-title { font-size: 18px; font-weight: 700; }
.drawer-close {
  background: none; border: none;
  font-size: 20px; cursor: pointer;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 4px;
}
.drawer-close:hover { background: var(--bg); }
.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* ── Status Picker ───────────────────────────────────────────── */
.status-badge-clickable {
  transition: opacity .15s;
}
.status-badge-clickable:hover { opacity: .75; }

.status-picker {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 8px 0 4px;
  box-shadow: var(--shadow);
  animation: fadeIn .15s ease;
}
.status-picker-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.status-picker-option {
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: 'Heebo', sans-serif;
  transition: transform .1s, opacity .1s;
}
.status-picker-option:hover { transform: scale(1.05); opacity: .85; }

/* ── Table floating status picker ───────────────────────────── */
.table-status-picker-float {
  position: fixed;
  z-index: 9999;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px;
  min-width: 170px;
  animation: fadeIn .12s ease;
}
.table-status-picker-float .status-picker-options {
  display: flex; flex-direction: column; gap: 5px;
}

/* ── Hide-not-interested toggle ─────────────────────────────── */
.hide-toggle-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  user-select: none;
}
.hide-toggle-label input[type="checkbox"] {
  width: 15px; height: 15px; cursor: pointer;
}

@keyframes fadeIn { from { opacity:0; transform:translateY(-4px); } to { opacity:1; transform:translateY(0); } }

/* ── Modal ───────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 300;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  width: 480px;
  max-width: 95vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close {
  background: none; border: none;
  font-size: 20px; cursor: pointer;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 4px;
}
.modal-close:hover { background: var(--bg); }
.modal-body {
  padding: 20px;
  overflow-y: auto;
}

/* ── Toast ───────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow);
  animation: slideIn .3s ease;
  min-width: 220px;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.info    { background: var(--primary); }
@keyframes slideIn {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ── Timeline (interactions) ─────────────────────────────────── */
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item {
  display: flex;
  gap: 14px;
  padding-bottom: 20px;
  position: relative;
}
.timeline-item:not(:last-child)::before {
  content: '';
  position: absolute;
  right: 19px;
  top: 28px;
  bottom: 0;
  width: 2px;
  background: var(--border);
}
.timeline-dot {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
  margin-top: 4px;
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px var(--primary);
}
.timeline-content { flex: 1; }
.timeline-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.timeline-date { font-size: 12px; color: var(--text-muted); }
.timeline-text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  white-space: pre-wrap;
}
.timeline-item-actions {
  display: flex;
  gap: 2px;
  margin-right: auto;
  opacity: 0;
  transition: opacity .15s;
}
.timeline-item:hover .timeline-item-actions { opacity: 1; }
.tl-action-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 2px 6px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-muted);
  transition: background .12s, border-color .12s;
}
.tl-action-btn:hover { background: var(--card); border-color: var(--border); color: var(--text); }
.tl-action-delete:hover { background: #fef2f2; border-color: #fecaca; color: #ef4444; }

/* ── Event type badge in timeline ───────────────────────────── */
.timeline-dot-event {
  background: #f59e0b;
  box-shadow: 0 0 0 2px #f59e0b;
}
.timeline-item-event > .timeline-content > .timeline-meta { flex-wrap: wrap; }

/* ── System activity log entries ────────────────────────────── */
.timeline-item-system {
  opacity: 0.75;
}
.timeline-item-system > .timeline-content {
  background: transparent;
  border: none;
  padding: 0 0 0 4px;
}
.timeline-dot-system {
  background: var(--text-light, #adb5bd);
  box-shadow: 0 0 0 2px var(--text-light, #adb5bd);
  width: 8px !important;
  height: 8px !important;
  margin-top: 5px;
}
.timeline-text-system {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  white-space: normal;
}
.timeline-item-system .timeline-date {
  font-size: 11px;
}
.event-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #fff7ed;
  color: #92400e;
  border: 1px solid #fcd34d;
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 600;
}
/* ── New event type inline row ───────────────────────────────── */
#newEventTypeRow { display: none; gap: 8px; align-items: center; }

/* ── Kanban ──────────────────────────────────────────────────── */
.kanban-board {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 20px;
  align-items: flex-start;
}
.kanban-col {
  flex-shrink: 0;
  width: 240px;
  background: var(--bg);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  height: calc(100vh - 260px);
}
.kanban-col-header {
  padding: 12px 14px;
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: var(--radius) var(--radius) 0 0;
  flex-shrink: 0;
}
.kanban-col-count {
  background: rgba(0,0,0,.12);
  color: inherit;
  border-radius: 20px;
  padding: 1px 8px;
  font-size: 12px;
}
.kanban-cards {
  flex: 1;
  min-height: 0;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}
.kanban-card {
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 12px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: box-shadow .15s, transform .15s;
  border-right: 3px solid transparent;
}
.kanban-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.kanban-card.dragging { opacity: .5; }
.kanban-card-name { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.kanban-card-phone { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.kanban-card-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-light);
}
.kanban-drop-zone {
  min-height: 60px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  display: none;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 13px;
}
.kanban-drop-zone.active { display: flex; border-color: var(--primary); }

/* ── Progress Bar ────────────────────────────────────────────── */
.progress-bar-wrap {
  background: var(--border);
  border-radius: 20px;
  height: 10px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  border-radius: 20px;
  background: var(--primary);
  transition: width .4s;
}

/* ── Reminder item ───────────────────────────────────────────── */
.reminder-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-bottom: 10px;
  transition: background .1s;
}
.reminder-item:hover { background: var(--bg); }
.reminder-item.done { opacity: .5; }
.reminder-time { font-size: 13px; color: var(--warning); font-weight: 600; min-width: 80px; }
.reminder-note { font-size: 14px; flex: 1; }
.reminder-lead { font-size: 12px; color: var(--text-muted); }

/* ── Inactive indicator ──────────────────────────────────────── */
.inactive-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--danger);
  font-weight: 600;
}

/* ── Inline editable ─────────────────────────────────────────── */
.editable-field {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
}
.editable-value {
  flex: 1;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: text;
  transition: background .1s;
}
.editable-value:hover { background: var(--bg); }
.editable-value.editing { display: none; }
.editable-input { flex: 1; }
.editable-input.hidden { display: none; }

/* ── Lead profile header v2 ──────────────────────────────────── */
.lead-header {
  background: var(--card);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 1px 6px rgba(0,0,0,.06);
}
.lh-top {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px 14px;
  background: linear-gradient(135deg, #f5f3ff, #eff6ff);
  border-bottom: 1px solid var(--border);
}
.lh-avatar {
  width: 50px; height: 50px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #818cf8);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: -1px;
  box-shadow: 0 2px 6px rgba(99,102,241,.35);
}
.lh-name {
  font-size: 19px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
  line-height: 1.2;
}
.lh-status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.lh-invested-badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: #dcfce7; color: #166534;
  padding: 2px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600;
}
.lh-score-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600;
}
.lh-body {
  padding: 12px 18px 10px;
}
.lh-info-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}
.lh-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 11px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.4;
}
.lh-chip a { color: inherit; text-decoration: none; }
.lh-chip a:hover { text-decoration: underline; }
.lh-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  padding: 10px 18px;
  background: var(--bg);
  border-top: 1px solid var(--border);
}
/* ── Interactions tab header ─────────────────────────────────── */
.interactions-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--border);
}
.interactions-count {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ── Investment payments section ────────────────────────────── */
.payments-section {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 12px;
}
.payments-header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  font-size: 14px;
  font-weight: 600;
}
.payments-count { font-weight: 400; color: var(--text-muted); }
.payments-total { flex: 1; font-size: 13px; color: var(--text-muted); font-weight: 400; }
.payment-row {
  display: grid;
  grid-template-columns: 90px 1fr auto 1fr 32px;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.payment-row:last-child { border-bottom: none; }
.payment-date { color: var(--text-muted); font-size: 12px; }
.payment-amount { font-weight: 600; color: var(--success); }
.payment-method-badge {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 4px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.payment-notes { color: var(--text-muted); font-size: 12px; }

/* ── Investment payments sub-rows (investments page table) ───── */
.inv-main-table tbody tr.inv-payments-sub td {
  background: var(--bg);
  padding: 0 12px 12px !important;
  border-top: none !important;
}
.inv-payments-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 4px 0 2px;
}
.inv-payment-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
}
.inv-pay-icon  { font-size: 15px; flex-shrink: 0; }
.inv-pay-date  { color: var(--text-muted); font-size: 12px; min-width: 72px; }
.inv-pay-amount { font-weight: 700; color: var(--success); font-size: 14px; }
.inv-pay-notes { color: var(--text-muted); font-size: 12px; font-style: italic; }

/* ── Investment card ─────────────────────────────────────────── */
.investment-summary {
  background: var(--success-light);
  border: 1px solid var(--success);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 14px;
}
.investment-type-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.inv-type-btn {
  padding: 8px 16px;
  border-radius: 20px;
  border: 2px solid var(--border);
  background: none;
  font-family: 'Heebo', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
}
.inv-type-btn.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

/* ── Import page ─────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  background: var(--bg);
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
}
.upload-zone-icon { font-size: 40px; margin-bottom: 12px; }
.upload-zone-text { font-size: 15px; font-weight: 500; margin-bottom: 6px; }
.upload-zone-sub  { font-size: 13px; color: var(--text-muted); }

/* ── Chart container ─────────────────────────────────────────── */
.chart-container {
  position: relative;
  height: 200px;
}

/* ── Report filters ──────────────────────────────────────────── */
.report-filters {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  background: var(--card-bg);
  padding: 16px 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.report-filters .form-group { margin-bottom: 0; }

/* ── Settings section ────────────────────────────────────────── */
.settings-section { margin-bottom: 32px; }
.settings-section-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
  color: var(--primary);
}
.lookup-table .data-table td { vertical-align: middle; }
.color-preview {
  width: 20px; height: 20px;
  border-radius: 50%;
  display: inline-block;
  border: 2px solid var(--border);
  vertical-align: middle;
}

/* ── Tags ────────────────────────────────────────────────────── */
.tag-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  cursor: default;
}
.tag-badge .tag-remove {
  cursor: pointer;
  opacity: 0.55;
  font-size: 10px;
  line-height: 1;
  margin-right: 1px;
  transition: opacity .15s;
}
.tag-badge .tag-remove:hover { opacity: 1; }
.lead-tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-height: 26px;
  margin: 6px 0 2px;
}
.btn-add-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.btn-add-tag:hover { border-color: var(--primary); color: var(--primary); }
.tag-picker-popup {
  position: absolute;
  top: 4px;
  right: 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,.14);
  padding: 12px 14px;
  z-index: 9999;
  min-width: 200px;
  max-width: 300px;
}
.tag-picker-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.tag-picker-divider {
  height: 1px;
  background: var(--border);
  margin: 10px 0 8px;
}
.tag-picker-new-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: 1px dashed var(--border);
  border-radius: 20px;
  padding: 3px 12px;
  font-size: 12px;
  color: var(--primary);
  cursor: pointer;
  width: 100%;
  justify-content: center;
  transition: background .12s, border-color .12s;
}
.tag-picker-new-btn:hover { background: #f5f3ff; border-color: var(--primary); }
.new-tag-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}
.tag-row-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.kanban-card-tags { display: flex; flex-wrap: wrap; gap: 3px; margin: 4px 0 2px; }

/* ── Utility ─────────────────────────────────────────────────── */
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.mt-0 { margin-top: 0 !important; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mb-16 { margin-bottom: 16px; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.flex-end { justify-content: flex-end; }
.align-center { align-items: center; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── Login page ──────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1E1B4B 0%, #312E81 50%, #4C1D95 100%);
}
.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 40px;
  width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  text-align: center;
}
.login-logo { margin-bottom: 8px; text-align: center; }
.login-title { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.login-sub { font-size: 14px; color: var(--text-muted); margin-bottom: 28px; }
.login-error {
  background: var(--danger-light);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 10px;
  font-size: 14px;
  margin-bottom: 16px;
}

/* ── Print ───────────────────────────────────────────────────── */
@media print {
  .sidebar, .page-header .page-actions, .filter-bar .btn,
  .drawer, .modal-overlay, #toastContainer { display: none !important; }
  .main-content { margin-right: 0 !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}

/* ── Loading ─────────────────────────────────────────────────── */
.loading-spinner {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 14px;
}
.loading-spinner::before {
  content: '⏳ ';
}

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state-text { font-size: 15px; }

/* ── Bulk selection ──────────────────────────────────────────── */
.lead-selected td { background: #ede9fe !important; }
.kpi-card-alert { border: 1.5px solid var(--danger) !important; }
.kpi-icon.red { background: #fef2f2; color: #b91c1c; }
.kpi-card-hot  { border: 1.5px solid #f97316; background: linear-gradient(135deg,#fff7ed,#fff); text-decoration:none; color:inherit; cursor:pointer; transition: box-shadow .15s, transform .1s; }
.kpi-card-hot:hover  { box-shadow: 0 4px 16px rgba(249,115,22,.25); transform: translateY(-2px); }
.kpi-card-good { border: 1.5px solid #eab308; background: linear-gradient(135deg,#fefce8,#fff); text-decoration:none; color:inherit; cursor:pointer; transition: box-shadow .15s, transform .1s; }
.kpi-card-good:hover { box-shadow: 0 4px 16px rgba(234,179,8,.25);  transform: translateY(-2px); }
.score-filter-badge { display:inline-flex;align-items:center;gap:6px;background:#fef3c7;border:1px solid #fbbf24;border-radius:20px;padding:4px 12px;font-size:13px;font-weight:600;color:#92400e; }
.score-filter-badge button { background:none;border:none;cursor:pointer;font-size:15px;line-height:1;color:#92400e;padding:0 0 0 2px; }
.kpi-card-invested { border: 1.5px solid #16a34a; background: linear-gradient(135deg,#f0fdf4,#fff); text-decoration:none; color:inherit; cursor:pointer; transition: box-shadow .15s, transform .1s; }
.kpi-card-invested:hover { box-shadow: 0 4px 16px rgba(22,163,74,.22); transform: translateY(-2px); }

/* ── Lead Score Badge ────────────────────────────────────────── */
.lead-score {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
  white-space: nowrap;
}

/* ── File Attachments ────────────────────────────────────────── */
.files-list { display: flex; flex-direction: column; gap: 8px; }
.file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.file-row:hover { border-color: var(--primary); background: var(--primary-light); }

/* ── Leads toolbar (desktop) ─────────────────────────────────── */
.leads-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
  flex-wrap: wrap;
}
.leads-toolbar-views   { display: flex; gap: 8px; }
.leads-toolbar-actions { display: flex; gap: 8px; align-items: center; }

/* ============================================================
   MOBILE – elements that exist only on mobile (hidden desktop)
   ============================================================ */
.mobile-top-bar,
.mobile-bottom-nav,
.mobile-nav-overlay { display: none !important; }

/* ============================================================
   MOBILE RESPONSIVE  ≤ 768px
   ============================================================ */
@media (max-width: 768px) {

  /* ── Mobile-only elements ─────────────────────────────── */
  .mobile-top-bar    { display: flex    !important; }
  .mobile-bottom-nav { display: flex    !important; }
  .hide-on-mobile    { display: none    !important; }

  /* ── Top bar (fixed) ──────────────────────────────────── */
  .mobile-top-bar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 54px;
    background: #1E1B4B;
    z-index: 450;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
    gap: 10px;
  }
  .mobile-top-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
  }
  .mobile-top-brand span { font-size: 22px; }
  .mobile-page-name {
    flex: 1;
    text-align: center;
    color: rgba(255,255,255,.75);
    font-size: 14px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .mobile-hamburger {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    padding: 8px 6px;
    border-radius: 6px;
    line-height: 1;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-hamburger:active { background: rgba(255,255,255,.12); }

  /* ── Sidebar → off-canvas panel ──────────────────────── */
  .sidebar {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: 260px;
    transform: translateX(110%);
    transition: transform .25s cubic-bezier(.4,0,.2,1);
    z-index: 520;
  }
  .sidebar.mobile-open { transform: translateX(0); }

  /* ── Overlay behind open sidebar ─────────────────────── */
  .mobile-nav-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.52);
    z-index: 510;
    cursor: pointer;
  }

  /* ── Main layout ──────────────────────────────────────── */
  .app-layout { display: block; }
  .main-content {
    margin-right: 0 !important;
    padding-top: 54px;
  }
  .page-header {
    padding: 12px 14px 4px;
    min-height: auto;
    flex-wrap: wrap;
    gap: 8px;
  }
  .page-title { font-size: 18px; }
  .page-body  { padding: 12px 12px 80px; }

  /* ── Bottom navigation bar ────────────────────────────── */
  .mobile-bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 62px;
    background: #1E1B4B;
    z-index: 450;
    align-items: stretch;
    border-top: 1px solid rgba(255,255,255,.1);
  }
  .mob-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: rgba(255,255,255,.5);
    text-decoration: none;
    font-size: 10px;
    font-weight: 600;
    border: none;
    background: none;
    font-family: 'Heebo', sans-serif;
    cursor: pointer;
    padding: 4px 2px;
    transition: color .15s, background .15s;
    -webkit-tap-highlight-color: transparent;
    position: relative;
  }
  .mob-nav-item.active { color: #fff; }
  .mob-nav-item.active::after {
    content: '';
    position: absolute;
    top: 0; left: 20%; right: 20%;
    height: 2px;
    background: var(--primary);
    border-radius: 0 0 4px 4px;
  }
  .mob-nav-item:active { background: rgba(255,255,255,.08); }
  .mob-nav-icon { font-size: 20px; line-height: 1; }

  /* ── Cards ────────────────────────────────────────────── */
  .card { padding: 14px; }

  /* ── KPI grid → 2 columns ─────────────────────────────── */
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi-card { padding: 12px 14px; gap: 10px; }
  .kpi-value { font-size: 22px; }
  .kpi-icon  { width: 40px; height: 40px; font-size: 18px; border-radius: 10px; }

  /* ── Tables → horizontal scroll ──────────────────────── */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .data-table { font-size: 13px; }
  .data-table thead th,
  .data-table tbody td { padding: 9px 10px; }

  /* ── Forms → single column ────────────────────────────── */
  .form-row   { grid-template-columns: 1fr !important; gap: 0 !important; }
  .form-row-3 { grid-template-columns: 1fr !important; gap: 0 !important; }
  .form-control { font-size: 16px; } /* prevent iOS zoom on focus */

  /* ── Filter bar → stacked ─────────────────────────────── */
  .filter-bar { flex-direction: column; align-items: stretch; gap: 8px; }
  .filter-bar .form-control { width: 100% !important; min-width: unset !important; }
  .filter-bar .search-box,
  .filter-bar .search-box .form-control { width: 100%; }

  /* ── Tabs → scrollable ────────────────────────────────── */
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tab-btn { padding: 10px 16px; font-size: 13px; white-space: nowrap; flex-shrink: 0; }

  /* ── Drawer → full-width sheet sliding from bottom ────── */
  /* z-index must be above bottom nav (450) so buttons aren't hidden */
  .drawer-overlay {
    align-items: flex-end !important;
    z-index: 500 !important;
  }
  .drawer {
    width: 100vw !important;
    max-width: 100vw !important;
    max-height: 92vh !important;
    border-radius: 18px 18px 0 0 !important;
    transform: translateY(30px) scale(1) !important;
    opacity: 0;
  }
  .drawer.open {
    transform: translateY(0) scale(1) !important;
    opacity: 1;
  }
  .drawer-header { padding: 14px 16px; }
  .drawer-title  { font-size: 16px; }
  /* Extra bottom padding so last buttons are reachable above bottom nav */
  .drawer-body   { padding: 12px 14px 80px; }

  /* ── Modal → sheet from bottom ────────────────────────── */
  .modal-overlay {
    align-items: flex-end !important;
    z-index: 500 !important;
  }
  .modal {
    width: 100vw !important;
    max-width: 100vw !important;
    max-height: 90vh !important;
    border-radius: 18px 18px 0 0 !important;
  }
  .modal-header { padding: 14px 16px; }
  .modal-body   { padding: 14px 14px 80px; }

  /* ── Grid utilities ───────────────────────────────────── */
  .grid-2 { grid-template-columns: 1fr !important; gap: 10px !important; }
  .grid-3 { grid-template-columns: 1fr 1fr !important; gap: 10px !important; }

  /* ── Page actions ─────────────────────────────────────── */
  .page-actions { flex-wrap: wrap; gap: 6px; }
  .page-actions .btn { font-size: 13px; padding: 7px 12px; }

  /* ── Buttons: bigger touch targets ───────────────────── */
  .btn { min-height: 38px; }
  .btn-sm { min-height: 32px; }

  /* ── Toast → above bottom nav ─────────────────────────── */
  .toast-container {
    bottom: 72px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    align-items: center;
    width: 90vw;
    max-width: 340px;
  }
  .toast { min-width: unset; width: 100%; text-align: center; }

  /* ── Lead chips in drawer ─────────────────────────────── */
  .lh-info-grid { gap: 5px; }
  .lh-chip { font-size: 12px; padding: 3px 9px; }

  /* ── Investment type tabs ─────────────────────────────── */
  .investment-type-tabs { flex-wrap: wrap; gap: 6px; }
  .inv-type-btn { font-size: 12px; padding: 6px 10px; }

  /* ── Kanban ───────────────────────────────────────────── */
  .kanban-col { width: 210px; }

  /* ── Login card ───────────────────────────────────────── */
  .login-card { width: 94vw; padding: 28px 20px; }

  /* ── Settings → hide less-important table columns ─────── */
  .settings-section .data-table th.hide-mobile,
  .settings-section .data-table td.hide-mobile { display: none; }

  /* ── Reminder items ────────────────────────────────────── */
  .reminder-item { flex-wrap: wrap; }
  .reminder-time { min-width: auto; }

  /* ── Prevent horizontal overflow showing sidebar ──────── */
  html, body { overflow-x: hidden; }

  /* ── Filter bar: force 100% width, override inline styles ─ */
  .filter-bar .form-control,
  .filter-bar input,
  .filter-bar select {
    min-width: unset !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  .filter-bar .hide-toggle-label { justify-content: flex-start; }

  /* ── Leads toolbar ────────────────────────────────────── */
  .leads-toolbar {
    padding: 10px 12px;
    gap: 8px;
  }
  .leads-toolbar-views   { flex: 1; }
  .leads-toolbar-actions { flex-wrap: wrap; }

  /* ── Leads table: hide less-important columns ─────────── */
  /* email (col 6), source (col 7), last_interaction (col 9) */
  .data-table thead th:nth-child(6),
  .data-table tbody td:nth-child(6),
  .data-table thead th:nth-child(7),
  .data-table tbody td:nth-child(7),
  .data-table thead th:nth-child(9),
  .data-table tbody td:nth-child(9) {
    display: none;
  }
  /* Let the table auto-fit without a fixed min-width */
  .data-table { min-width: unset; }
}

/* ═══════════════════════════════════════════════
   POVPO CRM – Additional Styles
   ═══════════════════════════════════════════════ */

/* ── Property Status Badges ──────────────────── */
.status-available { background: #D1FAE5; color: #047857; }
.status-exclusive { background: #EDE9FE; color: #6D28D9; }
.status-rented    { background: #DBEAFE; color: #1D4ED8; }
.status-sold      { background: #FEE2E2; color: #B91C1C; }
.status-expired   { background: #F3F4F6; color: #6B7280; }
.status-draft     { background: #FEF3C7; color: #92400E; }

/* ── Properties Grid ──────────────────────────── */
.props-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.prop-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
.prop-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
}
.prop-card-img {
  height: 160px;
  background: #f0f0f5;
  display: flex;
  align-items: center;
  justify-content: center;
}
.prop-card-img img {
  width: 100%; height: 100%;
  object-fit: cover;
}
.prop-card-placeholder {
  font-size: 48px;
  opacity: .3;
}
.prop-card-body { padding: 12px 16px; }
.prop-card-price {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}
.prop-card-address {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}
.prop-card-details {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.prop-card-status { margin-top: 4px; }

/* ── Brand text fallback ──────────────────────── */
.brand-text-mobile {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
}
