:root {
  --green: #2e7d32;
  --green-dark: #1b5e20;
  --green-light: #e8f5e9;
  --green-surface: #f0fdf4;
  --bg: #f4f6f4;
  --card: #ffffff;
  --text: #1f2933;
  --muted: #6b7280;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --danger: #c62828;
  --amber: #f9a825;
  --radius: 10px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.15);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

body.nav-open {
  overflow: hidden;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); font-size: 0.85rem; min-height: 1.2em; margin: 0.25rem 0 0; }
.empty { color: var(--muted); text-align: center; padding: 2rem; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--green-dark), var(--green));
  padding: 1.5rem;
}
.login-card {
  background: var(--card);
  padding: 2.5rem 2rem;
  border-radius: 14px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
  width: 360px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  text-align: center;
}
.login-logo { width: 72px; margin: 0 auto; }
.login-card h1 { margin: 0; font-size: 1.5rem; }
.login-card label { text-align: left; }

/* ---------- Layout & Navigation ---------- */
.app { display: flex; min-height: 100vh; position: relative; }

/* Mobile Header (Hidden on Desktop) */
.mobile-header {
  display: none;
}

.sidebar-overlay {
  display: none;
}

.sidebar-close-btn {
  display: none;
}

.sidebar {
  width: 230px;
  background: var(--green-dark);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 1rem 0;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
  flex-shrink: 0;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0 1.25rem 1rem;
  font-weight: 700;
  font-size: 1.15rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}
.brand-logo { width: 32px; height: 32px; background: #fff; border-radius: 6px; padding: 2px; }

.nav { display: flex; flex-direction: column; padding: 0.75rem 0; flex: 1; overflow-y: auto; }
.nav a {
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  padding: 0.7rem 1.25rem;
  border-left: 3px solid transparent;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: background 0.12s, color 0.12s;
}
.nav a:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.nav a.active { background: rgba(255, 255, 255, 0.16); border-left-color: #fff; color: #fff; font-weight: 600; }

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.current-user { font-size: 0.85rem; opacity: 0.95; font-weight: 500; margin-bottom: 0.25rem; word-break: break-word; }

.main { flex: 1; padding: 1.5rem 2rem; width: 100%; min-width: 0; }
.page-head { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head h2 { margin: 0; flex: 1; font-size: 1.45rem; font-weight: 700; }

/* ---------- Cards & Stats ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.card h3 { margin: 0 0 0.75rem; font-size: 1.05rem; font-weight: 600; }

.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  padding: 1rem 1.2rem;
  border-top: 4px solid var(--green);
}
.stat-card .num { font-size: 1.8rem; font-weight: 700; color: var(--text); }
.stat-card .lbl { color: var(--muted); font-size: 0.85rem; font-weight: 500; margin-top: 0.2rem; }

.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.25rem; }

/* ---------- Forms & Inputs ---------- */
label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; color: var(--muted); flex: 1; font-weight: 500; }
input, select, textarea {
  font: inherit;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  width: 100%;
  transition: border-color 0.12s, box-shadow 0.12s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.15);
}
.form-row { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.stack-form { display: flex; flex-direction: column; gap: 0.7rem; margin-bottom: 1rem; }
.inline-form { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.inline-form input, .inline-form select { width: auto; }

/* ---------- Buttons ---------- */
.btn {
  font: inherit;
  padding: 0.55rem 1.05rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  color: var(--text);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: all 0.12s ease;
  text-decoration: none;
}
.btn:hover { background: #f8faf8; border-color: var(--border-strong); }
.btn-primary { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--green-dark); border-color: var(--green-dark); }
.btn-danger { background: #fff; border-color: var(--danger); color: var(--danger); font-weight: 600; }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: inherit; }
.sidebar .btn-ghost { color: rgba(255, 255, 255, 0.85); text-align: left; padding-left: 0; justify-content: flex-start; }
.sidebar .btn-ghost:hover { color: #fff; background: transparent; text-decoration: underline; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.85rem; border-radius: 6px; }
.btn-block { width: 100%; }

/* ---------- Filters & Tables ---------- */
.filters { display: flex; gap: 0.6rem; margin-bottom: 1.15rem; flex-wrap: wrap; }
.filters input[type="search"] { flex: 2; min-width: 220px; }
.filters select { flex: 1; min-width: 140px; width: auto; }

.table-wrap { background: var(--card); border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow-sm); overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 0.75rem 0.95rem; border-bottom: 1px solid var(--border); }
.table th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 700; background: #fafafa; }
.table tbody tr { cursor: pointer; transition: background 0.12s; }
.table tbody tr:hover { background: var(--green-light); }
.table td .sub { display: block; font-size: 0.8rem; color: var(--muted); margin-top: 0.15rem; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: capitalize;
  letter-spacing: 0.02em;
  line-height: 1.2;
}
.badge-new { background: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; }
.badge-contacted { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }
.badge-qualified { background: #f3e8ff; color: #7e22ce; border: 1px solid #e9d5ff; }
.badge-proposal { background: #ccfbf1; color: #0f766e; border: 1px solid #99f6e4; }
.badge-won { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.badge-lost { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.badge-overdue { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.badge-today { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }

/* ---------- Lists & Feeds ---------- */
.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { padding: 0.6rem 0; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; gap: 0.5rem; align-items: baseline; }
.mini-list li:last-child { border-bottom: none; }
.mini-list a { color: var(--green-dark); font-weight: 600; text-decoration: none; }
.mini-list a:hover { text-decoration: underline; }
.mini-list .when { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.mini-list .none { color: var(--muted); justify-content: center; }

.activity-list { list-style: none; margin: 0; padding: 0; }
.activity-list li {
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.activity-list li:last-child { border-bottom: none; }
.activity-list .meta { font-size: 0.82rem; color: var(--muted); margin-bottom: 0.35rem; display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.activity-list .body-text { white-space: pre-wrap; font-size: 0.98rem; line-height: 1.5; color: var(--text); }
.activity-list .note-body {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-left: 4px solid #f59e0b;
  border-radius: 8px;
  padding: 0.75rem 0.95rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.activity-list .del { position: absolute; top: 0.7rem; right: 0; color: var(--muted); background: none; border: none; cursor: pointer; font-size: 0.85rem; opacity: 0; transition: opacity 0.15s; }
.activity-list li:hover .del { opacity: 1; }
.activity-list .del:hover { color: var(--danger); }
.activity-list .done-toggle { margin-right: 0.4rem; }
.activity-list .is-done .body-text, .activity-list .is-done .title { text-decoration: line-through; opacity: 0.6; }

/* Card head & Collapsible Forms */
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.75rem; }
.card-head h3 { margin: 0; display: flex; align-items: center; gap: 0.4rem; }
.card-head .count { color: var(--muted); font-weight: 500; font-size: 0.85rem; }
.add-form { border-top: 1px dashed var(--border); padding-top: 0.9rem; margin-top: 0.9rem; }
.add-form.collapsed { display: none; }
.add-form-actions { display: flex; gap: 0.5rem; }

/* =========================================================
   LEAD DETAIL VIEW: VIBRANT & DISTINCT FIELD CARDS
   ========================================================= */
.lead-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
  padding-bottom: 0.5rem;
}
.lead-head-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
}
.lead-title-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.lead-title-box h2 {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--text);
}
.lead-head-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.btn-quick-action {
  background: var(--green-light);
  color: var(--green-dark);
  border-color: #a7f3d0;
  font-weight: 600;
  border-radius: 8px;
}
.btn-quick-action:hover {
  background: #d1fae5;
  color: var(--green-dark);
}

.contact-hint-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: #4b5563;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.85rem;
  margin-bottom: 1.15rem;
}
.hint-icon { font-size: 1rem; }

.lead-overview-section {
  margin-bottom: 1.5rem;
}

.contact-grid-sections {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

/* Section Card */
.section-card {
  background: var(--card);
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  padding: 1.25rem 1.4rem;
  margin-bottom: 0;
}
.section-card-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.15rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #f1f5f9;
}
.sec-icon {
  font-size: 1.35rem;
  background: #f1f5f9;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  flex-shrink: 0;
}
.section-card-head h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}
.sec-desc {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

/* Group Specific Color Tweaks */
.sec-pipeline .sec-icon { background: #ecfdf5; }
.sec-contact .sec-icon { background: #eff6ff; }
.sec-custom .sec-icon { background: #fefce8; }

/* Grid of Field Tiles */
.contact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 1rem;
}

/* Field Item / Tile (Noticeably distinct) */
.cf-item {
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-height: 76px;
  justify-content: space-between;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
  outline: none;
}
.cf-item:hover {
  border-color: var(--green);
  background: #f9fdfa;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(46, 125, 50, 0.1);
}
.cf-item:focus-visible {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.2);
}

/* Field Color Accents on left border */
.cf-tile-status { border-left: 4.5px solid var(--green); background: #fafdfa; }
.cf-tile-value { border-left: 4.5px solid #10b981; background: #f0fdf4; }
.cf-tile-phone { border-left: 4.5px solid #3b82f6; background: #f8faff; }
.cf-tile-email { border-left: 4.5px solid #8b5cf6; background: #faf8ff; }
.cf-tile-source { border-left: 4.5px solid #f59e0b; background: #fffdf5; }
.cf-tile-owner { border-left: 4.5px solid #059669; background: #f0fdf4; }
.cf-tile-company { border-left: 4.5px solid #64748b; }
.cf-tile-tags { border-left: 4.5px solid #06b6d4; }
.cf-tile-name { border-left: 4.5px solid #2563eb; background: #f8faff; }

/* Agriculture Form Field Specific Colors */
.cf-tile-cf_region, .cf-tile-region { border-left: 4.5px solid #0284c7; background: #f0f9ff; }
.cf-tile-cf_stremmata, .cf-tile-cf_stremata, .cf-tile-stremmata { border-left: 4.5px solid #16a34a; background: #f0fdf4; }
.cf-tile-cf_crops, .cf-tile-crops { border-left: 4.5px solid #65a30d; background: #f7fee7; }
.cf-tile-cf_equipment, .cf-tile-equipment { border-left: 4.5px solid #d97706; background: #fffbeb; }
.cf-tile-cf_message, .cf-tile-message, .cf-tile-wide {
  border-left: 4.5px solid #8b5cf6;
  background: #faf5ff;
  grid-column: 1 / -1;
}

.cf-body-multiline {
  flex-direction: column;
  align-items: flex-start !important;
  gap: 0.5rem;
}
.cf-body-multiline .cf-display {
  white-space: pre-wrap;
  font-size: 0.95rem;
  font-weight: 500;
  color: #334155;
  line-height: 1.5;
  background: rgba(255, 255, 255, 0.7);
  padding: 0.6rem 0.85rem;
  border-radius: 8px;
  border: 1px solid #e9d5ff;
  width: 100%;
}

.val-strem {
  font-size: 1.1rem;
  font-weight: 700;
  color: #166534;
}

/* Custom field tiles */
.cf-item[class*="cf_"] { border-left: 4.5px solid #84cc16; background: #fafdf7; }

/* Tile Header */
.cf-header {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}
.cf-icon { font-size: 1rem; }
.cf-label {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #4b5563;
  flex: 1;
}
.cf-edit-hint {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--green);
  opacity: 0;
  transition: opacity 0.15s;
  background: var(--green-light);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}
.cf-item:hover .cf-edit-hint { opacity: 1; }

/* Tile Body & Value */
.cf-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-height: 28px;
  flex-wrap: wrap;
}
.cf-display {
  font-size: 0.98rem;
  font-weight: 600;
  color: #0f172a;
  word-break: break-word;
  line-height: 1.35;
}
.val-money {
  font-size: 1.18rem;
  font-weight: 800;
  color: #166534;
  letter-spacing: -0.01em;
}
.val-phone, .val-email {
  font-weight: 600;
  color: #1e293b;
}

/* Empty State */
.cf-empty-tag {
  color: #94a3b8;
  font-size: 0.82rem;
  font-weight: 500;
  border: 1px dashed #cbd5e1;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  display: inline-block;
  background: #f8fafc;
}

/* Action buttons inside field */
.cf-action-group {
  display: flex;
  gap: 0.35rem;
  margin-left: auto;
}
.cf-action-btn {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.55rem;
  border-radius: 6px;
  text-decoration: none;
  border: 1px solid var(--border);
  transition: all 0.12s;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}
.cf-call-btn { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.cf-call-btn:hover { background: #dbeafe; }
.cf-wa-btn { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.cf-wa-btn:hover { background: #d1fae5; }
.cf-email-btn { background: #f5f3ff; color: #6d28d9; border-color: #ddd6fe; }
.cf-email-btn:hover { background: #ede9fe; }

.tag-pill {
  display: inline-block;
  background: #e0f2fe;
  color: #0369a1;
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  margin: 0.1rem;
}

.lead-field-editor {
  width: 100%;
  padding: 0.45rem 0.65rem;
  border: 2px solid var(--green);
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.cf-item.ro {
  cursor: default;
}
.cf-item.ro:hover {
  transform: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
  border-color: #e2e8f0;
}

/* Assignee Card */
.assignee-card {
  margin-top: 1.25rem;
}
.assignee-picker { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.assignee-chip {
  flex-direction: row;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
  background: #fff;
  transition: all 0.12s;
}
.assignee-chip:hover {
  border-color: var(--green);
  background: var(--green-surface);
}
.assignee-chip input { width: auto; margin: 0; cursor: pointer; }
.assignee-chip.on {
  background: var(--green-light);
  border-color: var(--green);
  color: var(--green-dark);
  font-weight: 700;
}

.readonly-banner {
  background: #fff8e1;
  border: 1px solid #fde68a;
  color: #854d0e;
  padding: 0.55rem 0.95rem;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
}

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.25rem; align-items: start; }
.detail-grid .card:first-child { grid-row: span 2; }

/* ---------- Modals ---------- */
.modal {
  border: none;
  border-radius: 14px;
  padding: 1.75rem;
  width: 560px;
  max-width: 92vw;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
.modal::backdrop { background: rgba(0, 0, 0, 0.45); backdrop-filter: blur(2px); }
.modal h3 { margin-top: 0; font-size: 1.25rem; font-weight: 700; }
.modal form { display: flex; flex-direction: column; gap: 0.85rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.5rem; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: #1e293b;
  color: #fff;
  padding: 0.75rem 1.35rem;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  font-weight: 500;
  font-size: 0.92rem;
}
.toast.err { background: var(--danger); }

/* ---------- View Toggle & Column Picker ---------- */
.view-toggle { display: flex; gap: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.view-toggle .btn { border: none; border-radius: 0; background: #fff; padding: 0.4rem 0.8rem; }
.view-toggle .btn.active { background: var(--green); color: #fff; }
.view-toggle .btn + .btn { border-left: 1px solid var(--border); }

.cols-picker-wrap { position: relative; }
.popover {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: 0.85rem;
  z-index: 60;
  width: 240px;
  max-height: 60vh;
  overflow-y: auto;
}
.pop-title { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 700; margin-bottom: 0.5rem; }
.pop-item {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.3rem;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text);
  font-size: 0.9rem;
}
.pop-item:hover { background: var(--green-light); }
.pop-item input { width: auto; }
.pop-item.locked { opacity: 0.6; cursor: default; }
#cols-reset { margin-top: 0.5rem; width: 100%; text-align: center; }

/* ---------- Lead Cards (Grid View) ---------- */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.15rem;
}
.lead-card {
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  border: 1.5px solid var(--border);
  padding: 1.1rem 1.25rem;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.lead-card:hover {
  border-color: var(--green);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(46, 125, 50, 0.12);
}
.lead-card-top { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.lead-card-name { font-weight: 700; font-size: 1.05rem; color: #0f172a; }
.lead-card-company { color: var(--muted); font-size: 0.88rem; font-weight: 500; }
.lead-card-fields { display: flex; flex-direction: column; gap: 0.35rem; margin-top: 0.2rem; }
.lead-card-field { display: flex; justify-content: space-between; gap: 0.75rem; font-size: 0.85rem; }
.lead-card-field .k { color: var(--muted); font-weight: 500; }
.lead-card-field .v { text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.lead-card-foot { margin-top: auto; padding-top: 0.65rem; border-top: 1px solid #f1f5f9; color: var(--muted); font-size: 0.82rem; font-weight: 500; }

/* ---------- Spreadsheet Grid ---------- */
.grid-wrap {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
  padding-bottom: 0.5rem;
}
.grid-table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
.grid-table th, .grid-table td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.7rem;
  text-align: left;
  white-space: nowrap;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.grid-table th { background: #f8faf8; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 700; position: sticky; top: 0; }
.col-head { white-space: nowrap; }
.col-head-label { padding-right: 0.25rem; }
.col-filter-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  line-height: 1;
}
.col-filter-btn:hover { background: var(--green-light); color: var(--green-dark); }
.col-filter-btn.has-filter { color: var(--green); font-weight: 700; }

.filter-dropdown {
  position: absolute;
  z-index: 70;
  width: 250px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.filter-dropdown .f-search { width: 100%; }
.filter-dropdown .f-actions { display: flex; justify-content: space-between; }
.filter-dropdown .f-list {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0.25rem;
}
.f-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-direction: row;
  padding: 0.3rem 0.35rem;
  border-radius: 5px;
  cursor: pointer;
  color: var(--text);
  font-size: 0.88rem;
}
.f-item:hover { background: var(--green-light); }
.f-item input { width: auto; }
.f-item .f-val { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.f-item .f-count { color: var(--muted); font-size: 0.76rem; }
.filter-dropdown .f-foot { display: flex; justify-content: flex-end; }
.grid-table tbody tr:nth-child(even) { background: #fbfdfb; }
.grid-table tbody td { cursor: cell; }
.grid-table tbody td:hover { background: var(--green-light); }
.grid-table .grid-open { cursor: pointer; text-align: center; color: var(--muted); font-weight: 700; }
.grid-table .grid-open:hover { color: var(--green-dark); background: var(--green-light); }
.grid-hint { padding: 0.5rem 1rem 0; font-size: 0.8rem; }

.cell-editor {
  width: 100%;
  min-width: 110px;
  padding: 0.3rem 0.45rem;
  border: 2px solid var(--green);
  border-radius: 6px;
  font: inherit;
  background: #fff;
}
.cell-editor:focus { outline: none; }

/* =========================================================
   RESPONSIVE & MOBILE DESIGN (Max-width 860px / 600px)
   ========================================================= */
@media (max-width: 900px) {
  .dash-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  /* Prevent iOS automatic zoom by ensuring 16px font size on inputs */
  input, select, textarea {
    font-size: 16px !important;
  }

  .app {
    flex-direction: column;
  }

  /* Mobile Topbar */
  .mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    padding: 0 1rem;
    background: var(--green-dark);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  }

  .mobile-menu-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 8px;
    width: 40px;
    height: 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    padding: 0;
  }
  .mobile-menu-btn:hover { background: rgba(255, 255, 255, 0.25); }
  .menu-bar {
    width: 20px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
  }

  .mobile-brand {
    display: flex;
    align-items: center;
    gap: 0.55rem;
  }
  .mobile-brand .brand-logo {
    width: 28px;
    height: 28px;
  }
  .mobile-brand-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.01em;
  }

  .mobile-user-badge {
    background: rgba(255, 255, 255, 0.18) !important;
    color: #fff !important;
    border: 1px solid rgba(255, 255, 255, 0.25) !important;
    border-radius: 50% !important;
    width: 38px;
    height: 38px;
    font-weight: 700;
    font-size: 0.85rem;
    padding: 0;
  }

  /* Backdrop Overlay */
  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(3px);
    z-index: 190;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }
  .sidebar-overlay.open {
    opacity: 1;
    pointer-events: auto;
  }

  /* Off-canvas Collapsible Sidebar */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    max-width: 85vw;
    height: 100vh;
    z-index: 200;
    transform: translateX(-100%);
    box-shadow: none;
    padding: 1.25rem 0;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 10px 0 40px rgba(0, 0, 0, 0.35);
  }

  .sidebar-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
  }
  .sidebar-close-btn:hover {
    background: rgba(255, 255, 255, 0.25);
  }

  /* Main Container */
  .main {
    padding: 1rem 0.85rem;
  }

  .page-head {
    gap: 0.6rem;
    margin-bottom: 1rem;
  }
  .page-head h2 {
    font-size: 1.3rem;
  }

  .stat-cards {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }
  .stat-card {
    padding: 0.85rem 1rem;
  }
  .stat-card .num {
    font-size: 1.5rem;
  }

  .filters {
    flex-direction: column;
    gap: 0.5rem;
  }
  .filters input[type="search"] {
    width: 100%;
    min-width: unset;
  }
  .filters select {
    width: 100%;
    min-width: unset;
  }

  .cards-grid {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }

  .contact-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .section-card {
    padding: 1rem 1.05rem;
  }

  .modal {
    width: 95vw;
    padding: 1.25rem;
  }
}
