/* ============================================================
   SK LEAD CRM — Design System v9.0
   Full responsive, dark glassmorphism
   ============================================================ */

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  --primary:        #2563eb;
  --primary-light:  #3b82f6;
  --primary-dark:   #1d4ed8;
  --success:        #10b981;
  --warning:        #f59e0b;
  --danger:         #ef4444;
  --info:           #06b6d4;

  --surface-0:      #0a0f1e;
  --surface-1:      #0f172a;
  --surface-2:      #1e293b;
  --border:         rgba(255,255,255,0.08);

  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted:     #64748b;
  --text-accent:    #3b82f6;

  --sidebar-w:      220px;
  --topbar-h:       52px;
  --tabbar-h:       58px;
  --radius:         8px;
  --radius-lg:      12px;

  --font-sans:      'Plus Jakarta Sans', 'DM Sans', system-ui, sans-serif;
  --font-mono:      'JetBrains Mono', monospace;

  --shadow-sm:      0 1px 3px rgba(0,0,0,.4);
  --shadow:         0 4px 16px rgba(0,0,0,.5);
  --shadow-lg:      0 8px 32px rgba(0,0,0,.6);
}

/* ── Reset ─────────────────────────────────────────────────── */
*,*::before,*::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--surface-0);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  /* App-like touch feel: no flash on tap, no accidental long-press menu */
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none; /* stop the whole page rubber-banding like a webpage */
}
a { color: var(--primary-light); text-decoration: none; }
a:hover { color: var(--primary); }
img { max-width: 100%; }

/* Buttons, nav items, and icons behave like native controls, not selectable text */
.btn, .nav-link, .tab-item, .topbar-btn, .sidebar-toggle, .card-header, .page-header,
.badge, .table thead th {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.btn:active, .tab-item:active, .topbar-btn:active, .nav-link:active {
  transform: scale(0.96);
  transition: transform .08s ease;
}
@media (prefers-reduced-motion: reduce) {
  .btn:active, .tab-item:active, .topbar-btn:active, .nav-link:active { transform: none; }
}

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.2); }

/* ═══════════════════════════════════════════════════════════
   LAYOUT — CRM Shell
   ════════════════════════════════════════════════════════════ */
.crm-shell {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  min-height: 100dvh;
  background: #080d1a;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 1040;
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  overflow-y: auto;
  overflow-x: hidden;
  flex-shrink: 0;
}

.sidebar-logo {
  padding: calc(14px + env(safe-area-inset-top, 0px)) 14px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-h);
  flex-shrink: 0;
}

.sidebar-nav {
  flex: 1;
  padding: 6px 0;
  overflow-y: auto;
}

.nav-section {
  padding: 12px 10px 2px;
  font-size: 9.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  margin: 1px 6px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 500;
  color: #94a3b8;
  text-decoration: none;
  transition: background .12s, color .12s;
  white-space: nowrap;
  cursor: pointer;
}

.nav-link i { width: 16px; font-size: 13px; flex-shrink: 0; }

.nav-link:hover {
  background: rgba(255,255,255,.05);
  color: #e2e8f0;
}

.nav-link.active {
  background: rgba(37,99,235,.18);
  color: #60a5fa;
}

.nav-badge {
  margin-left: auto;
  background: rgba(239,68,68,.2);
  color: #f87171;
  font-size: 9.5px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.sidebar-user {
  padding: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Sidebar overlay (mobile) ──────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 1039;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

/* ── Bottom tab bar (mobile / installed-app navigation) ────────
   Hidden on desktop; becomes the primary nav on phones so the
   product reads as an app, not a scaled-down website. */
.bottom-tabbar {
  display: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 1035;
  background: rgba(8,13,26,.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
  align-items: stretch;
  justify-content: space-around;
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 4px 2px;
  border: none;
  background: none;
  color: var(--text-muted);
  text-decoration: none;
  font-family: inherit;
  cursor: pointer;
  min-width: 0;
}

.tab-icon {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: background .15s, color .15s;
}

.tab-label {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
}

.tab-item.active { color: #60a5fa; }
.tab-item.active .tab-icon { background: rgba(37,99,235,.18); color: #60a5fa; }

/* "Find leads" gets a filled accent chip even when inactive — it's the
   signature action of this CRM, worth making visually distinct. */
.tab-icon-primary { background: rgba(37,99,235,.12); color: var(--primary-light); }
.tab-item.active .tab-icon-primary { background: var(--primary); color: #fff; }

/* ── Main wrap ──────────────────────────────────────────────── */
.main-wrap {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  min-width: 0;
}

/* ── Topbar ─────────────────────────────────────────────────── */
.topbar {
  height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  background: rgba(8,13,26,.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding-left: 14px;
  padding-right: 14px;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 1030;
  flex-shrink: 0;
}

.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 17px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: color .15s;
  flex-shrink: 0;
}
.sidebar-toggle:hover { color: var(--text-primary); }

.topbar-search {
  flex: 1;
  max-width: 280px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 10px;
  height: 32px;
  position: relative;
}

.topbar-search input {
  background: none;
  border: none;
  outline: none;
  font-size: 12.5px;
  color: var(--text-primary);
  flex: 1;
  width: 100%;
  min-width: 0;
}
.topbar-search input::placeholder { color: var(--text-muted); }

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.topbar-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, color .15s;
  position: relative;
  flex-shrink: 0;
}
.topbar-btn:hover { background: rgba(255,255,255,.08); color: var(--text-primary); }

.notif-dot {
  position: absolute;
  top: 3px; right: 3px;
  min-width: 14px;
  height: 14px;
  border-radius: 7px;
  background: var(--danger);
  color: #fff;
  font-size: 8.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  border: 1.5px solid var(--surface-0);
}

.topbar-avatar { text-decoration: none; }

/* Search dropdown */
.search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  max-height: 320px;
  overflow-y: auto;
  display: none;
}
.search-dropdown.show { display: block; }
.search-result-item {
  padding: 8px 12px;
  font-size: 12.5px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}
.search-result-item:hover { background: rgba(255,255,255,.04); color: var(--text-primary); }
.search-result-item:last-child { border-bottom: none; }

/* ── Flash messages ─────────────────────────────────────────── */
.flash-message {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  flex-shrink: 0;
}
.flash-success { background: rgba(16,185,129,.12); color: #34d399; border-bottom: 1px solid rgba(16,185,129,.2); }
.flash-error   { background: rgba(239,68,68,.12);  color: #f87171; border-bottom: 1px solid rgba(239,68,68,.2); }
.flash-warning { background: rgba(245,158,11,.12); color: #fbbf24; border-bottom: 1px solid rgba(245,158,11,.2); }

/* ── Page content ───────────────────────────────────────────── */
.page-content {
  flex: 1;
  padding: 20px 18px;
  overflow-x: hidden;
}

/* ── Page header ────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}
.page-title  { font-size: 19px; font-weight: 700; color: var(--text-primary); margin: 0; line-height: 1.3; }
.page-subtitle { font-size: 12.5px; color: var(--text-muted); margin: 2px 0 0; }

/* Breadcrumb */
.breadcrumb { background: none; padding: 0; margin: 0 0 4px; display: flex; flex-wrap: wrap; }
.breadcrumb-item { font-size: 11.5px; color: var(--text-muted); }
.breadcrumb-item a { color: var(--text-muted); }
.breadcrumb-item a:hover { color: var(--text-secondary); }
.breadcrumb-item.active { color: var(--text-secondary); }
.breadcrumb-item + .breadcrumb-item::before { content: '/'; color: var(--text-muted); padding: 0 6px; }

/* ═══════════════════════════════════════════════════════════
   COMPONENTS
   ════════════════════════════════════════════════════════════ */

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: none;
  flex-wrap: wrap;
}
.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}
.card-body { padding: 16px; }
.card-footer { padding: 12px 16px; border-top: 1px solid var(--border); background: none; }

/* Stat cards */
.stat-card {
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--stat-color, var(--primary));
  opacity: .5;
}
.stat-icon {
  width: 42px; height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  background: var(--stat-icon-bg, rgba(37,99,235,.12));
  color: var(--stat-color, var(--primary));
}
.stat-info { flex: 1; min-width: 0; }
.stat-value { font-size: 22px; font-weight: 700; color: var(--text-primary); line-height: 1.1; }
.stat-label { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  line-height: 1.4;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn:disabled { opacity: .55; pointer-events: none; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }

.btn-secondary {
  background: rgba(255,255,255,.05);
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-secondary:hover { background: rgba(255,255,255,.09); color: var(--text-primary); }

.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #059669; color: #fff; }
.btn-danger  { background: var(--danger);  color: #fff; border-color: var(--danger); }
.btn-danger:hover  { background: #dc2626; color: #fff; }
.btn-warning { background: var(--warning); color: #fff; border-color: var(--warning); }

.btn-sm  { padding: 4px 10px; font-size: 12px; }
.btn-lg  { padding: 10px 20px; font-size: 14px; }
.btn-icon { width: 32px; height: 32px; padding: 0; justify-content: center; border-radius: var(--radius); }

/* ── Forms ──────────────────────────────────────────────────── */
.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
  display: block;
  letter-spacing: .01em;
}

.form-control,
.form-select {
  width: 100%;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 13px;
  padding: 8px 12px;
  transition: border-color .15s, box-shadow .15s;
  font-family: var(--font-sans);
}
.form-control:focus,
.form-select:focus {
  outline: none;
  border-color: rgba(37,99,235,.6);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
  background: rgba(255,255,255,.06);
  color: var(--text-primary);
}
.form-control::placeholder { color: var(--text-muted); }
.form-select option { background: var(--surface-1); }
.form-select { appearance: auto; }

.form-control-sm,
.form-select-sm { padding: 5px 9px; font-size: 12px; }

textarea.form-control { resize: vertical; min-height: 80px; }

.input-group { display: flex; }
.input-group .form-control { border-radius: 0 var(--radius) var(--radius) 0; }
.input-group-text {
  display: flex; align-items: center;
  padding: 0 11px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: var(--radius) 0 0 var(--radius);
  color: var(--text-muted);
  font-size: 13px;
  white-space: nowrap;
  flex-shrink: 0;
}

.form-check-input {
  background-color: rgba(255,255,255,.06);
  border-color: var(--border);
  cursor: pointer;
}
.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }
.form-check-label { font-size: 13px; color: var(--text-secondary); cursor: pointer; }

.form-switch .form-check-input { background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='rgba%28255,255,255,.5%29'/%3e%3c/svg%3e"); }
.form-switch .form-check-input:checked { background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e"); }

/* ── Tables ─────────────────────────────────────────────────── */
.table { color: var(--text-primary); border-color: var(--border); width: 100%; margin: 0; }
.table > :not(caption) > * > * { background: transparent; border-color: var(--border); padding: 10px 14px; }
.table thead th {
  background: rgba(255,255,255,.02);
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  padding: 9px 14px;
}
.table tbody td { font-size: 13px; color: var(--text-secondary); border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: rgba(255,255,255,.025); }
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 10.5px;
  font-weight: 600;
  white-space: nowrap;
}
/* status badges used in views */
.badge-new,.b-new           { background: rgba(99,102,241,.15); color: #818cf8; }
.badge-contacted,.b-contact { background: rgba(59,130,246,.15); color: #60a5fa; }
.badge-qualified            { background: rgba(139,92,246,.15); color: #a78bfa; }
.badge-proposal_sent,.b-neg { background: rgba(245,158,11,.15); color: #fbbf24; }
.badge-negotiation          { background: rgba(249,115,22,.15); color: #fb923c; }
.badge-won,.b-won           { background: rgba(16,185,129,.15); color: #34d399; }
.badge-lost,.b-lost         { background: rgba(239,68,68,.15);  color: #f87171; }
.badge-on_hold,.b-on_hold   { background: rgba(100,116,139,.15);color: #94a3b8; }
.badge-active               { background: rgba(16,185,129,.15); color: #34d399; }
.badge-inactive,.b-inactive { background: rgba(100,116,139,.15);color: #94a3b8; }
.badge-draft                { background: rgba(100,116,139,.12);color: #94a3b8; border: 1px solid var(--border); }
.badge-sent                 { background: rgba(59,130,246,.15); color: #60a5fa; }
.badge-viewed               { background: rgba(245,158,11,.15); color: #fbbf24; }
.badge-accepted,.badge-paid { background: rgba(16,185,129,.15); color: #34d399; }
.badge-declined,.badge-overdue,.badge-lost { background: rgba(239,68,68,.15); color: #f87171; }
.badge-cancelled            { background: rgba(100,116,139,.15);color: #94a3b8; }
.badge-partial              { background: rgba(245,158,11,.15); color: #fbbf24; }
.badge-expired              { background: rgba(239,68,68,.15);  color: #f87171; }
.badge-contact,.badge-status { background: rgba(59,130,246,.15); color: #60a5fa; }
/* project status */
.badge-in_progress          { background: rgba(59,130,246,.15); color: #60a5fa; }
.badge-review               { background: rgba(245,158,11,.15); color: #fbbf24; }
.badge-done                 { background: rgba(16,185,129,.15); color: #34d399; }
.badge-blocked              { background: rgba(239,68,68,.15);  color: #f87171; }
.badge-todo                 { background: rgba(100,116,139,.12);color: #94a3b8; }

/* ── Modals ─────────────────────────────────────────────────── */
.modal-content {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  color: var(--text-primary);
}
.modal-header { border-bottom: 1px solid var(--border); padding: 16px 20px; }
.modal-title  { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.modal-body   { padding: 20px; }
.modal-footer { border-top: 1px solid var(--border); padding: 12px 20px; }
.btn-close { filter: invert(1) opacity(.5); }
.btn-close:hover { opacity: 1; }
.modal-backdrop { background: rgba(0,0,0,.7); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }

/* ── Pagination ─────────────────────────────────────────────── */
.pagination { display: flex; gap: 3px; list-style: none; padding: 0; margin: 0; }
.page-item.active .page-link { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-item.disabled .page-link { opacity: .4; pointer-events: none; }
.page-link {
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius) !important;
  font-size: 12.5px;
  padding: 5px 10px;
  transition: all .15s;
}
.page-link:hover { background: rgba(255,255,255,.08); color: var(--text-primary); border-color: rgba(255,255,255,.15); }

/* ── Avatar ─────────────────────────────────────────────────── */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; font-weight: 600; flex-shrink: 0; overflow: hidden;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  color: #fff;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-xs { width: 24px; height: 24px; font-size: 9.5px; }
.avatar-sm { width: 30px; height: 30px; font-size: 11px; }
.avatar-md { width: 40px; height: 40px; font-size: 14px; }
.avatar-lg { width: 52px; height: 52px; font-size: 18px; }
.avatar-xl { width: 72px; height: 72px; font-size: 24px; }

/* ── Empty state ────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 20px; }
.empty-state-icon { font-size: 40px; color: var(--text-muted); opacity: .4; margin-bottom: 12px; }
.empty-state-title { font-size: 16px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state-text { font-size: 13px; color: var(--text-muted); max-width: 320px; margin: 0 auto 16px; }

/* ── Progress ───────────────────────────────────────────────── */
.progress { height: 6px; background: rgba(255,255,255,.06); border-radius: 10px; overflow: hidden; }
.progress-bar { background: var(--primary); border-radius: 10px; }

/* ── Alerts ─────────────────────────────────────────────────── */
.alert { border-radius: var(--radius); padding: 10px 14px; font-size: 13px; display: flex; align-items: center; gap: 8px; border: none; }
.alert-success { background: rgba(16,185,129,.1); color: #34d399; }
.alert-danger  { background: rgba(239,68,68,.1);  color: #f87171; }
.alert-warning { background: rgba(245,158,11,.1); color: #fbbf24; }
.alert-info    { background: rgba(6,182,212,.1);  color: #22d3ee; }

/* ── Dropdown ───────────────────────────────────────────────── */
.dropdown-menu {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 5px;
  min-width: 170px;
}
.dropdown-item { color: var(--text-secondary); border-radius: 5px; font-size: 13px; padding: 7px 11px; transition: all .12s; display: flex; align-items: center; gap: 7px; }
.dropdown-item:hover { background: rgba(255,255,255,.05); color: var(--text-primary); }
.dropdown-item.text-danger:hover { background: rgba(239,68,68,.1); color: var(--danger); }
.dropdown-divider { border-color: var(--border); margin: 3px 0; }

/* ── Auth layout ────────────────────────────────────────────── */
.auth-wrapper {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-0); padding: 24px;
}
.auth-card {
  width: 100%; max-width: 420px;
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 32px;
  box-shadow: var(--shadow-lg);
}

/* ── Kanban ─────────────────────────────────────────────────── */
.kanban-board {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 16px;
  /* Without this, a horizontal swipe near the edge of the board can get
     misread by the phone's browser as "swipe back to previous page"
     instead of scrolling the board — exactly the jarring, unpredictable
     feel this was reported as. */
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  /* Makes a swipe settle on a column boundary instead of stopping
     wherever the finger happened to lift — otherwise a column can be
     left cut off halfway across the screen, which reads as "broken". */
  scroll-snap-type: x proximity;
}
.kanban-column {
  min-width: 260px; max-width: 260px;
  background: rgba(255,255,255,.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex; flex-direction: column;
  max-height: calc(100vh - 180px);
  max-height: calc(100dvh - 180px);
  scroll-snap-align: start;
}
.kanban-column-header {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: rgba(15,23,42,.9);
}
.kanban-column-title { font-size: 12.5px; font-weight: 600; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; }
.kanban-count { background: rgba(255,255,255,.06); color: var(--text-muted); font-size: 11px; padding: 1px 6px; border-radius: 10px; }
.kanban-cards { flex: 1; padding: 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 7px; }
.kanban-card {
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 13px;
  cursor: grab; transition: transform .15s, box-shadow .15s;
}
.kanban-card:hover { transform: translateY(-1px); box-shadow: var(--shadow); border-color: rgba(255,255,255,.12); }
.kanban-card.dragging { opacity: .5; cursor: grabbing; }

/* ── Timeline ───────────────────────────────────────────────── */
.timeline { position: relative; padding-left: 28px; }
.timeline::before { content: ''; position: absolute; left: 10px; top: 0; bottom: 0; width: 1px; background: var(--border); }
.timeline-item { position: relative; margin-bottom: 16px; }
.timeline-dot {
  position: absolute; left: -24px; top: 3px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--surface-2); border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
}
.timeline-dot.active { background: var(--primary); border-color: var(--primary); }

/* ── Misc ───────────────────────────────────────────────────── */
code, .font-mono { font-family: var(--font-mono); font-size: .9em; }
.text-danger { color: var(--danger) !important; }
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-info { color: var(--info) !important; }
.cursor-pointer { cursor: pointer; }
.border-0 { border: none !important; }
.overflow-hidden { overflow: hidden; }

/* ─────────────────────────────────────────────────────────────
   RESPONSIVE
   ──────────────────────────────────────────────────────────── */

/* Tablet */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.show { display: block; }
  .main-wrap { margin-left: 0; }
  .sidebar-toggle { display: flex; }
  .page-content { padding: 14px 12px; }
  .stat-card { padding: 12px; }
  .stat-value { font-size: 20px; }
}

/* Mobile landscape */
@media (max-width: 767.98px) {
  .bottom-tabbar { display: flex; }
  .main-wrap { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px)); }
  /* "More" tab in the bottom bar now opens the menu — one clear control, not two */
  .sidebar-toggle { display: none; }
  .page-content { padding: 12px 10px; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .page-header > div:last-child { width: 100%; }
  .page-header .btn { width: 100%; justify-content: center; }
  .card-header { flex-direction: column; align-items: flex-start; }
  .card-header .btn { align-self: flex-start; }
  .topbar-search { max-width: 160px; }
  .table thead th { font-size: 10px; padding: 7px 10px; }
  .table tbody td { padding: 8px 10px; font-size: 12.5px; }
  .kanban-board { padding-bottom: 72px; }
  .modal-body { padding: 14px; }
  .auth-card { padding: 24px 18px; }
}

/* Mobile portrait */
@media (max-width: 575.98px) {
  :root { --topbar-h: 48px; }
  .page-title { font-size: 17px; }
  .stat-card { flex-direction: row; }
  .topbar-search { display: none; }
  .table-responsive { font-size: 12px; }
  /* Stack rows into single column on xs */
  .row > [class*="col-"] { flex: 0 0 100%; max-width: 100%; }
  .row > .col-md-3, .row > .col-md-4, .row > .col-md-6,
  .row > .col-lg-4, .row > .col-lg-8,
  .row > .col-xl-4, .row > .col-xl-8 {
    flex: 0 0 100%; max-width: 100%;
  }
}

/* ── Bootstrap overrides ────────────────────────────────────── */
.row { --bs-gutter-x: 14px; --bs-gutter-y: 0; }
.container-fluid { padding-left: 0; padding-right: 0; }
.d-flex { display: flex !important; }
.align-items-center { align-items: center !important; }
.justify-content-between { justify-content: space-between !important; }
.justify-content-center { justify-content: center !important; }
.justify-content-end { justify-content: flex-end !important; }
.flex-wrap { flex-wrap: wrap !important; }
.flex-column { flex-direction: column !important; }
.gap-1 { gap: 4px !important; }
.gap-2 { gap: 8px !important; }
.gap-3 { gap: 12px !important; }
.gap-4 { gap: 16px !important; }
.ms-auto { margin-left: auto !important; }
.me-auto { margin-right: auto !important; }
.mt-auto { margin-top: auto !important; }
.mb-0 { margin-bottom: 0 !important; }
.mb-2 { margin-bottom: 8px !important; }
.mb-3 { margin-bottom: 12px !important; }
.mb-4 { margin-bottom: 16px !important; }
.mt-2 { margin-top: 8px !important; }
.mt-3 { margin-top: 12px !important; }
.mt-4 { margin-top: 16px !important; }
.p-0 { padding: 0 !important; }
.p-3 { padding: 12px !important; }
.p-4 { padding: 16px !important; }
.px-3 { padding-left: 12px !important; padding-right: 12px !important; }
.px-4 { padding-left: 16px !important; padding-right: 16px !important; }
.py-3 { padding-top: 12px !important; padding-bottom: 12px !important; }
.py-4 { padding-top: 16px !important; padding-bottom: 16px !important; }
.py-5 { padding-top: 32px !important; padding-bottom: 32px !important; }
.ps-3 { padding-left: 12px !important; }
.pe-3 { padding-right: 12px !important; }
.w-100 { width: 100% !important; }
.h-100 { height: 100% !important; }
.text-end { text-align: right !important; }
.text-center { text-align: center !important; }
.text-start { text-align: left !important; }
.text-muted { color: var(--text-muted) !important; }
.small { font-size: 11.5px !important; }
.fw-bold { font-weight: 700 !important; }
.fw-600 { font-weight: 600 !important; }
.d-none { display: none !important; }
.d-block { display: block !important; }
.d-inline { display: inline !important; }
.d-inline-block { display: inline-block !important; }
.d-inline-flex { display: inline-flex !important; }
.position-relative { position: relative !important; }
.position-absolute { position: absolute !important; }
.overflow-hidden { overflow: hidden !important; }
.flex-shrink-0 { flex-shrink: 0 !important; }
.flex-grow-1 { flex-grow: 1 !important; }
.min-width-0 { min-width: 0 !important; }
.text-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Additional aliases used in inline styles ───────────────── */
:root {
  /* Aliases for legacy var names used in inline view styles */
  --bg-base:         var(--surface-0);
  --bg-surface:      var(--surface-1);
  --bg-card:         rgba(255,255,255,.03);
  --bg-card-hover:   rgba(255,255,255,.05);
  --bg-input:        rgba(255,255,255,.04);
  --bg-input-focus:  rgba(255,255,255,.07);
  --border-radius:   var(--radius);
  --border-radius-sm:var(--radius);
  --border-radius-lg:var(--radius-lg);
  --font-body:       var(--font-sans);
  --font-display:    var(--font-sans);

  /* Colors also used inline */
  --success-bg:      rgba(16,185,129,.12);
  --warning-bg:      rgba(245,158,11,.12);
  --danger-bg:       rgba(239,68,68,.12);
  --info-bg:         rgba(6,182,212,.12);
  --primary-glow:    rgba(37,99,235,.2);
}

/* ── b-* badge aliases (used in proposal/invoice views) ─────── */
.b-won        { background: rgba(16,185,129,.15); color: #34d399; }
.b-lost       { background: rgba(239,68,68,.15);  color: #f87171; }
.b-contact    { background: rgba(59,130,246,.15); color: #60a5fa; }
.b-inactive   { background: rgba(100,116,139,.15);color: #94a3b8; }
.b-neg        { background: rgba(245,158,11,.15); color: #fbbf24; }
.b-on_hold    { background: rgba(100,116,139,.15);color: #94a3b8; }
.b-proposal_sent { background: rgba(245,158,11,.15); color: #fbbf24; }

/* ── Mobile: keep real table markup, scroll horizontally instead ──
   (data-label/::before "card list" pattern was dropped — no view in
   this codebase actually sets data-label on <td>, so it silently
   showed unlabeled rows. .table-responsive + tighter sizing below is
   what every table view actually relies on.) */
@media (max-width: 767.98px) {
  .card { border-radius: 8px; }
  .card-header { padding: 10px 12px; }
  .card-body   { padding: 12px; }
  .table-responsive {
    border-radius: 8px;
    /* subtle edge fade hints that the table scrolls */
    -webkit-mask-image: linear-gradient(to right, transparent, black 8px, black calc(100% - 8px), transparent);
            mask-image: linear-gradient(to right, transparent, black 8px, black calc(100% - 8px), transparent);
  }
  .table { min-width: 560px; } /* forces scroll instead of illegible squeeze */
  .table thead th { white-space: nowrap; }
  .table tbody td { white-space: nowrap; }
  .table tbody td.wrap { white-space: normal; } /* opt-in for cells that should wrap (names, notes) */

  /* Page header button full width */
  .page-header .btn { width: 100%; justify-content: center; }

  /* Stats row single column */
  .row.g-3 > .col-md-3,
  .row.g-3 > .col-md-4 { flex: 0 0 50%; max-width: 50%; }
}

@media (max-width: 479.98px) {
  .row.g-3 > .col-md-3,
  .row.g-3 > .col-md-4 { flex: 0 0 100%; max-width: 100%; }

  .topbar-btn { width: 28px; height: 28px; }
  .btn-icon   { width: 28px; height: 28px; }
}

/* ── Print ───────────────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .page-header .btn, .flash-message,
  .card-header .btn, #pwaInstallBtn, #pwaFloatPrompt { display: none !important; }
  .main-wrap  { margin-left: 0 !important; }
  .page-content { padding: 0 !important; }
  body { background: #fff !important; color: #000 !important; }
  .card { border: 1px solid #ddd !important; background: #fff !important; page-break-inside: avoid; }
}

/* ── Priority badges ─────────────────────────────────────────── */
.badge-low      { background: rgba(100,116,139,.15); color: #94a3b8; }
.badge-medium   { background: rgba(59,130,246,.15);  color: #60a5fa; }
.badge-high     { background: rgba(245,158,11,.15);  color: #fbbf24; }
.badge-critical { background: rgba(239,68,68,.15);   color: #f87171; }

/* ── Status badge aliases for dynamic badge-{status} pattern ── */
.badge-new           { background: rgba(99,102,241,.15);  color: #818cf8; }
.badge-contacted     { background: rgba(59,130,246,.15);  color: #60a5fa; }
.badge-qualified     { background: rgba(139,92,246,.15);  color: #a78bfa; }
.badge-proposal_sent { background: rgba(245,158,11,.15);  color: #fbbf24; }
.badge-negotiation   { background: rgba(249,115,22,.15);  color: #fb923c; }
.badge-won           { background: rgba(16,185,129,.15);  color: #34d399; }
.badge-lost          { background: rgba(239,68,68,.15);   color: #f87171; }
.badge-on_hold       { background: rgba(100,116,139,.15); color: #94a3b8; }
.badge-status        {} /* parent wrapper — no styling needed */
