:root {
  --bg: #ffffff;
  --bg-sidebar: #f7f8fb;
  --ink: #0b1220;
  --muted: #5b6578;
  --line: #e6e8ee;
  --brand: #1364E8;
  --brand-2: #071543;
  --rr-azure: #1364E8;
  --rr-navy: #071543;
  --rr-teal: #1364E8;
  --rr-purple: #071543;
  --rr-ink: #0b1220;
  --accent: #c45c26;
  --danger: #9b2c2c;
  --ok: #1f6b3a;
  --warn: #9a6b16;
  --card: #ffffff;
  --shadow: 0 1px 2px rgba(7, 21, 67, 0.04), 0 4px 16px rgba(7, 21, 67, 0.04);
  --radius: 14px;       /* outer cards / panels */
  --radius-sm: 4px;     /* inputs, buttons, small controls */
  --radius-md: 8px;     /* menus, flash, mid elements */
  --font: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "SF Mono", Menlo, Consolas, monospace;
  --nav-h: 3.75rem;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-weight: 500;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
.main { min-width: 0; max-width: 100%; }
.mobile-label { display: none; }

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-2); }

.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
  max-width: 100%;
  overflow-x: clip;
}

.sidebar {
  padding: 1.25rem 1rem;
  border-right: 1px solid var(--line);
  background: var(--bg-sidebar);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.brand {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  padding: 0.2rem 0.35rem 0.55rem;
  color: inherit;
}
.brand-mark {
  width: 2.6rem;
  height: 2.6rem;
  display: block;
  flex-shrink: 0;
  border-radius: 0;
  object-fit: contain;
  background: transparent;
}
.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.brand-title {
  display: block;
  font-family: "Outfit", var(--font);
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--rr-navy);
  line-height: 1.15;
}
.brand-title em {
  font-style: normal;
  color: var(--rr-navy);
}
.brand small,
.brand-sub {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-top: 0.08rem;
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.7rem;
  text-decoration: none;
  margin-bottom: 1.15rem;
}
.auth-brand .brand-mark {
  width: 4.25rem;
  height: 4.25rem;
  border-radius: 0;
}
.auth-brand .brand-title { font-size: 1.7rem; }
.auth-brand .brand-sub { letter-spacing: 0.16em; }

.plan-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.plan-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.1rem 1rem;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.plan-card.is-current {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand);
}
.plan-card h3 {
  margin: 0;
  font-size: 1.05rem;
}
.plan-price {
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
}
.plan-price span {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
}
.plan-features {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: 0.9rem;
  flex: 1;
}
.plan-features li { margin: 0.25rem 0; }

.pill-soon {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #7a5b20;
  background: #f6efd9;
  vertical-align: middle;
}

.coming-soon-panel .coming-soon-badge {
  display: inline-block;
  margin: 0.35rem 0 0.75rem;
  padding: 0.25rem 0.55rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #7a5b20;
  background: #f6efd9;
}

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

.nav { display: flex; flex-direction: column; gap: 0.2rem; flex: 1; }
.nav-core { flex: 1; }
.nav-secondary {
  flex: 0;
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}
.nav-section-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 0.35rem 0.7rem 0.45rem;
}
.more-divider {
  height: 1px;
  background: var(--line);
  margin: 0.35rem 0;
}
.more-section-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 0.35rem 0.35rem 0.15rem;
}
.nav a {
  color: var(--ink);
  padding: 0.5rem 0.7rem 0.5rem 0.85rem;
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.95rem;
  font-weight: 500;
  position: relative;
}
.nav a:hover {
  background: rgba(19, 100, 232, 0.07);
  color: var(--brand);
}
.nav a.active {
  background: #e8f1fe;
  color: var(--brand);
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--brand);
}
.nav a.active:hover {
  background: #dceafd;
  color: var(--brand);
}
.badge {
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  font-size: 0.72rem;
  padding: 0.1rem 0.45rem;
  min-width: 1.2rem;
  text-align: center;
  font-weight: 600;
}
.badge.muted { background: var(--muted); }

.main { padding: 1.25rem 1.5rem 3rem; max-width: 1200px; }

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0 0 0.2rem;
  line-height: 1.2;
}
.breadcrumb a { font-weight: 600; }
.breadcrumb .sep { opacity: 0.5; }

.topbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  margin-bottom: 1.25rem;
}
.topbar-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  min-height: 2.5rem;
}
.topbar h1 {
  font-family: var(--font);
  font-size: 1.65rem;
  margin: 0;
  line-height: 1.2;
  letter-spacing: -0.03em;
  font-weight: 700;
}

.user-chip { position: relative; }
.avatar-btn {
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
}
.avatar {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
}
.account-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.4rem);
  min-width: 200px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  padding: 0.4rem;
  z-index: 40;
}
.account-menu-head {
  padding: 0.55rem 0.65rem 0.7rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 0.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.account-menu-head span { color: var(--muted); font-size: 0.8rem; }
.account-menu a, .account-menu .menu-logout, .account-menu .account-menu-action {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius-sm);
  color: var(--ink);
  background: none;
  border: none;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.account-menu a:hover, .account-menu .menu-logout:hover, .account-menu .account-menu-action:hover {
  background: rgba(19, 100, 232,0.08);
}
.menu-logout { color: var(--danger) !important; }

.flash {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
  border: 1px solid var(--line);
  font-weight: 500;
}
.flash.success { background: #e7f6ec; border-color: #b7dfc4; color: var(--ok); }
.flash.error { background: #fdecec; border-color: #f0c2c2; color: var(--danger); }

.toast-host {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: min(360px, calc(100% - 2rem));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.75rem 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  font-weight: 500;
  animation: toast-in 0.2s ease;
}
.toast.success { border-color: #b7dfc4; }
.toast.error { border-color: #f0c2c2; }
.toast-msg { flex: 1; color: var(--ink); }
.toast.success .toast-msg { color: var(--ok); }
.toast.error .toast-msg { color: var(--danger); }
.toast-close {
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  padding: 0;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

.busy-overlay {
  position: fixed;
  inset: 0;
  z-index: 180;
  background: rgba(255,255,255,0.55);
  display: grid;
  place-items: center;
}
.busy-overlay[hidden] { display: none !important; }
.busy-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 0.85rem;
  font-weight: 600;
}
.busy-spinner {
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.progress-track {
  height: 8px;
  background: #f0f0f0;
  border-radius: 99px;
  overflow: hidden;
  margin: 1rem 0 0.75rem;
}
.progress-bar {
  height: 100%;
  background: var(--brand);
  border-radius: 99px;
  transition: width 0.25s ease;
}

body.is-busy { cursor: wait; }
body.is-busy .main { pointer-events: none; user-select: none; }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
  min-width: 0;
}
.panel h2, .panel h3 {
  font-family: var(--font);
  margin: 0 0 0.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.85rem;
}
.stat {
  padding: 1rem;
  border-radius: var(--radius);
  background: #fff;
  border: 1px solid var(--line);
}
.stat .label { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.stat .value { font-family: var(--font); font-size: 1.8rem; margin-top: 0.2rem; color: var(--brand); font-weight: 700; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
table.data th, table.data td {
  text-align: left;
  padding: 0.65rem 0.45rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.data th { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
table.data tr:hover td { background: rgba(19, 100, 232,0.04); }

.stage-pill {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #fff;
  background: var(--brand);
}

.btn, button.btn {
  appearance: none;
  border: 1px solid transparent;
  background: var(--brand);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.9rem;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.btn:hover { background: var(--brand-2); color: #fff; }
.btn.secondary { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.secondary:hover { border-color: var(--brand); color: var(--brand); }
.btn:disabled,
.btn[disabled] {
  opacity: 0.55;
  cursor: default;
  pointer-events: none;
  box-shadow: none;
}
.btn.secondary:disabled,
.btn.secondary[disabled] {
  background: #f3f5f4;
  border-color: var(--line);
  color: var(--muted);
}
.btn.danger { background: var(--danger); }
.btn.danger:hover { filter: brightness(0.95); color: #fff; }
.danger-zone {
  border-color: rgba(176, 68, 68, 0.35);
}
.danger-zone h2 {
  color: var(--danger);
  font-size: 1rem;
}
.btn.ghost { background: transparent; color: var(--brand); padding-left: 0.4rem; padding-right: 0.4rem; }
.btn.sm { padding: 0.35rem 0.65rem; font-size: 0.82rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; }

.plan-cta { margin-top: auto; min-height: 2.4rem; display: flex; align-items: center; }
.plan-current-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--brand);
  background: rgba(19, 100, 232, 0.1);
  border: 1px solid transparent;
  pointer-events: none;
  user-select: none;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}
.form-grid .full { grid-column: 1 / -1; }
label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.25rem;
}
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.7rem;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--ink);
}
input[type="checkbox"],
input[type="radio"] {
  width: 1.05rem;
  height: 1.05rem;
  min-width: 1.05rem;
  padding: 0;
  margin: 0;
  accent-color: var(--brand);
  flex-shrink: 0;
  cursor: pointer;
}
.check-inline {
  display: inline-flex !important;
  gap: 0.5rem;
  align-items: center;
  color: var(--ink) !important;
  font-size: 0.92rem !important;
  font-weight: 500 !important;
  margin: 0 !important;
  cursor: pointer;
}
textarea { min-height: 100px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(19, 100, 232,0.25);
  border-color: var(--brand);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0;
  align-items: end;
}
.filters-panel {
  margin-bottom: 0.85rem;
}
.filters-panel .filters { margin-bottom: 0; }
.filters-search-row {
  display: contents;
}
.btn.filters-toggle { display: none; }
.filters-more {
  display: contents;
}
.filters .field { min-width: 120px; flex: 1; }
.filters .field.grow { flex: 2; min-width: 180px; }
.filters-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.15rem;
  height: 1.15rem;
  margin-left: 0.35rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
}
.lead-card-sub { display: none; }
.lead-tag-more {
  display: none;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  align-self: center;
}

.quick-add-desktop { display: block; }
.quick-add-title { display: flex; align-items: baseline; gap: 0.75rem; flex-wrap: wrap; }
.muted-hint { color: var(--muted); font-size: 0.85rem; font-weight: 500; }
.quick-add-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1.2fr 0.9fr auto auto;
  gap: 0.45rem;
  align-items: center;
}
.list-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.inline-assign { margin: 0; }
.inline-assign select { min-width: 0; max-width: 100%; width: 100%; padding: 0.35rem 0.45rem; font-size: 0.85rem; }

.assign-bar {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
}
.assign-bar label { margin: 0; }
.assign-bar select { width: auto; min-width: 180px; }

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  position: sticky;
  bottom: 0.75rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.65rem;
  box-shadow: var(--shadow);
  z-index: 5;
}

.timeline { display: flex; flex-direction: column; gap: 0.75rem; }
.timeline-item {
  border-left: 3px solid var(--line);
  padding: 0.15rem 0 0.15rem 0.85rem;
}
.timeline-item .meta { color: var(--muted); font-size: 0.8rem; }
.timeline-item .type {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--brand);
  margin-bottom: 0.15rem;
}

.lead-detail-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
}

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: #f7f8f7;
}
.auth-shell {
  width: min(420px, 100%);
}
.auth-card {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.auth-card h1 {
  font-family: var(--font);
  margin: 0 0 0.25rem;
  color: var(--brand);
  font-weight: 700;
}
.auth-card .sub { color: var(--muted); margin-bottom: 1.25rem; }
.auth-card .stack { display: flex; flex-direction: column; gap: 0.75rem; }
.auth-card .links { margin-top: 1rem; font-size: 0.9rem; color: var(--muted); }
.auth-links-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
  font-size: 0.9rem;
}
.auth-links-row a {
  color: var(--brand);
  text-decoration: none;
  font-weight: 600;
}
.auth-links-row a:hover { text-decoration: underline; }
.auth-legal {
  margin-top: 1rem;
  text-align: center;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.7;
}
.auth-legal a {
  color: var(--brand);
  text-decoration: none;
}
.auth-legal a:hover { text-decoration: underline; }
.auth-attribution {
  margin: 0.85rem 0 0;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
}
.auth-attribution a {
  color: var(--brand);
  font-weight: 600;
  text-decoration: none;
}
.auth-attribution a:hover { text-decoration: underline; }
.hp-field {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.pipeline {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.65rem;
}
.pipeline-col {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.65rem;
  min-height: 140px;
}
.pipeline-col h4 {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  display: flex;
  justify-content: space-between;
}
.mini-lead {
  padding: 0.45rem 0.5rem;
  border-radius: var(--radius-sm);
  background: #fff;
  border: 1px solid var(--line);
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
}
.mini-lead a { color: var(--ink); }

.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: auto;
  width: 100%;
  max-width: 100%;
  height: auto;
  min-height: var(--nav-h);
  padding: 0.3rem 0.25rem calc(0.3rem + env(safe-area-inset-bottom, 0px));
  background: #fff;
  border-top: 1px solid var(--line);
  z-index: 200;
  justify-content: stretch;
  align-items: stretch;
  box-sizing: border-box;
  margin: 0;
  gap: 0;
  overflow: hidden;
}
.mobile-nav a, .mobile-more-btn {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
  text-align: center;
  padding: 0.3rem 0.1rem;
  flex: 1 1 0;
  min-width: 0;
  background: none;
  border: none;
  font-family: var(--font);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  overflow: hidden;
}
.mobile-nav .nav-lbl {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mobile-nav a.active, .mobile-more-btn.active {
  color: var(--brand);
  font-weight: 800;
  background: #e8f1fe;
  border-radius: 10px;
}
.nav-ico { font-size: 1.05rem; line-height: 1; }

body.more-open .mobile-nav,
body.more-open .fab-add,
body.pwa-sheet-open .mobile-nav,
body.pwa-sheet-open .fab-add {
  visibility: hidden;
  pointer-events: none;
}

.more-sheet, .quick-add-sheet {
  position: fixed;
  inset: 0;
  z-index: 260;
}
.more-sheet[hidden], .quick-add-sheet[hidden] { display: none !important; }
.more-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(28, 36, 32, 0.45);
}
.more-sheet-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  background: #fff;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 0.75rem 1rem calc(1.5rem + env(safe-area-inset-bottom, 0px));
  max-height: min(88dvh, 88vh);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 -8px 30px rgba(0,0,0,0.12);
}
.more-sheet-handle {
  width: 40px; height: 4px;
  border-radius: 99px;
  background: var(--line);
  margin: 0.15rem auto 0.85rem;
}
.more-sheet-user {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--line);
}
.more-sheet-user .muted { color: var(--muted); font-size: 0.85rem; }
.more-sheet-panel > a, .more-logout, .more-sheet-action {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.85rem 0.35rem;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  background: none;
  border-left: none;
  border-right: none;
  border-top: none;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}
.more-logout { color: var(--danger); border-bottom: none; }
.quick-add-form { display: flex; flex-direction: column; gap: 0.55rem; }
.quick-add-sheet h3 { margin: 0 0 0.75rem; font-weight: 700; }

.fab-add {
  display: none;
  position: fixed;
  right: 1rem;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 0.85rem);
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 50%;
  border: none;
  background: var(--brand);
  color: #fff;
  font-size: 1.75rem;
  font-weight: 500;
  line-height: 1;
  box-shadow: 0 8px 24px rgba(19, 100, 232, 0.35);
  z-index: 90;
  cursor: pointer;
}

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; overflow-x: clip; max-width: 100%; }
  .sidebar { display: none; }
  .main {
    padding: 1rem 0.85rem calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 1.5rem);
    overflow-x: clip;
    max-width: 100%;
  }
  .form-grid, .grid-3 { grid-template-columns: 1fr; }
  .mobile-nav { display: flex; }
  .topbar h1 { font-size: 1.35rem; }
  .quick-add-desktop { display: none; }
  .fab-add { display: flex; align-items: center; justify-content: center; }
  .quick-actions {
    bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 0.5rem);
    z-index: 50;
  }
  .lead-detail-grid { grid-template-columns: 1fr; }
  .quick-add-row { grid-template-columns: 1fr; }

  .account-menu {
    position: fixed;
    right: 0.75rem;
    top: calc(3.5rem + env(safe-area-inset-top, 0px));
    width: min(260px, calc(100% - 1.5rem));
    min-width: 0;
    max-width: calc(100% - 1.5rem);
    z-index: 130;
  }

  .filters .field,
  .filters .field.grow {
    min-width: 0;
    flex: 1 1 100%;
  }
  .filters select,
  .filters input {
    max-width: 100%;
  }

  .filters-panel {
    padding: 0.65rem 0.75rem;
  }
  .filters-panel .filters {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    align-items: stretch;
  }
  .filters-search-row {
    display: flex;
    gap: 0.45rem;
    align-items: center;
    width: 100%;
  }
  .filters-search-row .field {
    flex: 1;
    min-width: 0;
    margin: 0;
  }
  .filters-search-row .field label,
  .filters-desktop-label {
    display: none;
  }
  .btn.filters-toggle {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    white-space: nowrap;
  }
  .filters-more {
    display: none;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
    padding-top: 0.15rem;
  }
  .filters-panel:not(.is-collapsed) .filters-more {
    display: flex;
  }
  .filters-panel:not(.is-collapsed) .filters-toggle {
    border-color: var(--brand);
    color: var(--brand);
  }

  .list-head .btn-row {
    width: 100%;
  }
  .list-head .btn-row .btn,
  .list-head .btn-row a.btn {
    flex: 1 1 auto;
    justify-content: center;
    min-width: 0;
  }
  .list-head-hint { display: none; }
  .page-leads .list-head .muted-hint { display: none; }

  .bulk-bar-inner {
    align-items: stretch;
  }
  .bulk-bar select {
    width: 100%;
    max-width: 100%;
    flex: 1 1 100%;
  }
  .bulk-select-opts {
    width: 100%;
  }
  .bulk-select-opts .btn {
    flex: 1 1 auto;
  }

  .filter-chips {
    flex-wrap: wrap;
  }
  .filter-chips .btn {
    flex: 1 1 auto;
    justify-content: center;
  }

  .pipeline {
    grid-template-columns: 1fr;
  }

  .table-wrap {
    overflow-x: hidden;
    max-width: 100%;
  }
  .main, .panel {
    overflow-x: clip;
    max-width: 100%;
  }

  .leads-table,
  .leads-table tbody,
  .followups-table,
  .followups-table tbody,
  .attention-table,
  .attention-table tbody,
  .team-table,
  .team-table tbody,
  .import-page .data,
  .import-page .data tbody {
    display: block;
    width: 100%;
    max-width: 100%;
  }

  .leads-table thead,
  .followups-table thead,
  .attention-table thead,
  .team-table thead,
  .import-page .data thead {
    display: none;
  }

  .leads-table tr.lead-row,
  .followups-table tr.lead-row,
  .attention-table tr.attention-row,
  .team-table tr.team-row,
  .import-page .data tbody tr {
    display: grid;
    gap: 0.35rem 0.65rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 0.75rem 0.8rem;
    margin-bottom: 0.55rem;
    background: #fff;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .leads-table tr.lead-row td,
  .followups-table tr.lead-row td,
  .attention-table tr.attention-row td,
  .team-table tr.team-row td,
  .import-page .data tbody tr td {
    border: none;
    padding: 0;
    background: transparent !important;
    min-width: 0;
  }

  .leads-table tr.empty-row,
  .followups-table tr.empty-row {
    display: block;
    border: none;
    padding: 0.5rem 0;
    margin: 0;
  }
  .leads-table tr.empty-row td,
  .followups-table tr.empty-row td {
    border: none;
    padding: 0.35rem 0;
  }

  /* Leads cards — flex row so name can use remaining width (grid+table was clipping) */
  .leads-table tr.lead-row {
    display: flex !important;
    flex-direction: row;
    align-items: center;
    gap: 0.55rem 0.65rem;
    padding: 0.65rem 0.7rem;
  }
  .leads-table tr.lead-row > td {
    display: none !important;
  }
  .leads-table tr.lead-row > td.col-check,
  .leads-table tr.lead-row > td.col-lead,
  .leads-table tr.lead-row > td.col-actions {
    display: block !important;
  }
  .leads-table .col-check {
    flex: 0 0 auto;
    width: auto !important;
    max-width: none !important;
    padding-top: 0;
  }
  .leads-table .col-lead {
    flex: 1 1 0;
    min-width: 0 !important;
    width: auto !important;
    max-width: none !important;
  }
  .leads-table .lead-cell {
    min-width: 0;
    width: 100%;
    max-width: 100%;
  }
  .leads-table .lead-pipeline-meta,
  .leads-table .lead-cell-meta { display: none; }
  .leads-table .lead-card-sub {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.28rem;
    min-width: 0;
    overflow: hidden;
  }
  .leads-table .lead-card-sub .stage-pill {
    flex-shrink: 0;
    max-width: 9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .leads-table .lead-card-due {
    font-size: 0.75rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
  }
  .leads-table .col-actions {
    flex: 0 0 auto;
    width: auto !important;
    max-width: none !important;
    align-self: center;
    text-align: right;
    padding-right: 0;
  }
  .leads-table .col-actions .lead-actions {
    flex-direction: row;
  }
  .leads-table .lead-row-name {
    display: block;
    width: 100%;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.98rem;
    line-height: 1.25;
  }
  .leads-table .lead-cell-tags {
    margin-top: 0.28rem;
    flex-wrap: nowrap;
    overflow: hidden;
    max-width: 100%;
  }
  .leads-table .lead-tag-overflow { display: none !important; }
  .leads-table .lead-tag-more { display: inline-flex; }

  .page-leads .leads-list-actions { display: none !important; }

  /* Follow-ups cards */
  .followups-table tr.lead-row {
    grid-template-columns: 1fr;
    grid-template-areas:
      "due"
      "lead"
      "note"
      "actions";
  }
  .followups-table .col-due {
    grid-area: due;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted);
  }
  .followups-table .col-lead { grid-area: lead; }
  .followups-table .col-note {
    grid-area: note;
    font-size: 0.85rem;
    color: var(--muted);
    white-space: normal;
    word-break: break-word;
  }
  .followups-table .col-note:empty { display: none; }
  .followups-table .col-actions { grid-area: actions; }
  .followups-table .col-actions .btn-row {
    width: 100%;
  }
  .followups-table .col-actions .btn {
    flex: 1;
    justify-content: center;
  }

  /* Dashboard attention cards */
  .attention-table tr.attention-row {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "lead actions"
      "stage actions"
      "followup actions";
    align-items: start;
  }
  .attention-table .col-lead { grid-area: lead; font-weight: 700; }
  .attention-table .col-stage { grid-area: stage; }
  .attention-table .col-followup {
    grid-area: followup;
    font-size: 0.8rem;
    color: var(--muted);
  }
  .attention-table .col-actions {
    grid-area: actions;
    align-self: center;
  }
  .attention-table .col-actions .lead-actions {
    flex-direction: column;
  }

  /* Team cards */
  .team-table tr.team-row {
    grid-template-columns: 1fr;
    grid-template-areas:
      "name"
      "email"
      "actions";
  }
  .team-table .col-name {
    grid-area: name;
    font-weight: 700;
  }
  .team-table .col-email {
    grid-area: email;
    font-size: 0.85rem;
    color: var(--muted);
    word-break: break-all;
  }
  .team-table .col-role,
  .team-table .col-status { display: none; }
  .team-table .col-actions { grid-area: actions; }
  .team-edit-form {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
  }
  .team-edit-form select {
    width: 100%;
    min-width: 0;
  }
  .team-edit-form .btn {
    grid-column: 1 / -1;
  }

  /* Tags — stack edit fields fully on small screens */
  .tag-edit-form {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
  }
  .tag-edit-colors { grid-column: auto; }

  /* Import history / sync rows */
  .import-page .data tbody tr {
    grid-template-columns: 1fr;
  }
  .import-page .data tbody tr td {
    font-size: 0.88rem;
    word-break: break-word;
  }
  .import-page .lead-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
  }
  .import-url {
    max-width: 100%;
    white-space: normal;
  }

  .list-head select {
    max-width: 100%;
  }
}

@media (min-width: 861px) {
  .fab-add, .more-sheet { display: none !important; }
}

/* ——— Lead tags ——— */
.lead-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: color-mix(in srgb, var(--tag-color, #1364E8) 16%, #fff);
  color: var(--tag-color, #1364E8);
  border: 1px solid color-mix(in srgb, var(--tag-color, #1364E8) 35%, #fff);
  white-space: nowrap;
}
.tag-list { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.tags-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.tag-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  background: #fff;
  max-width: 100%;
  box-sizing: border-box;
}
.tag-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
  min-width: 0;
}
.tag-card-head .lead-tag {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tag-edit-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.55rem 0.65rem;
  align-items: center;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}
.tag-edit-form > label { min-width: 0; }
.tag-edit-form input {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
.tag-edit-colors {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  grid-column: 1 / -1;
}
.tag-edit-form > .btn {
  justify-self: start;
}
.tag-check-grid { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.tag-check { display: inline-flex; align-items: center; gap: 0.35rem; cursor: pointer; margin: 0; }
.tag-check input { width: auto; margin: 0; }
.tag-color-picker { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.35rem; }
.tag-swatch { cursor: pointer; margin: 0; }
.tag-swatch input { position: absolute; opacity: 0; pointer-events: none; }
.tag-swatch span {
  display: block;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.35);
  outline: 2px solid transparent;
}
.tag-swatch input:checked + span { outline-color: var(--ink); }

/* ——— Lead detail actions ——— */
.lead-detail-name { margin: 0.2rem 0 0.45rem; font-size: 1.45rem; }
.lead-detail-top { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.lead-meta-row { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; margin-top: 0.35rem; }
.lead-contact-line, .lead-followup-line { margin: 0.55rem 0 0; color: var(--muted); }
.lead-action-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.65rem;
  margin: 0.85rem 0;
}
.lead-action-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem;
}
.lead-action-card header {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.55rem;
}
.lead-action-card h3 { margin: 0; font-size: 0.85rem; font-weight: 700; }
.lead-action-form { flex-wrap: wrap; }
.info-tip {
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #f4f7f5;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
  cursor: help;
  padding: 0;
}
.tip-popover {
  position: fixed;
  z-index: 200;
  max-width: 16rem;
  padding: 0.55rem 0.7rem;
  background: #163528;
  color: #fff;
  border-radius: 8px;
  font-size: 0.82rem;
  line-height: 1.35;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  pointer-events: none;
}

/* ——— Clickable rows + bulk ——— */
tr.lead-row { cursor: pointer; }
tr.lead-row.is-active td { background: rgba(19, 100, 232,0.08); }
.col-check { width: 2rem; }
.col-check input { width: auto; cursor: pointer; }

.leads-table { table-layout: fixed; }
.leads-table th, .leads-table td { vertical-align: middle; }
@media (min-width: 861px) {
  .leads-table .col-lead { width: 28%; }
  .leads-table .col-stage { width: 16%; }
  .leads-table .col-followup { width: 14%; white-space: nowrap; }
  .leads-table .col-owner { width: 16%; }
  .leads-table .col-interest { width: 14%; }
  .leads-table .col-actions {
    width: 5.5rem;
    text-align: right;
    padding-right: 0.35rem;
  }
}
.lead-cell { min-width: 0; }
.lead-row-name {
  display: block;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lead-cell-meta {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 0.12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lead-cell-tags { margin-top: 0.35rem; }
.lead-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.3rem;
  vertical-align: middle;
}
.icon-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--brand);
  flex-shrink: 0;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.icon-action svg {
  display: block;
  flex-shrink: 0;
}
.icon-action:hover {
  background: rgba(19, 100, 232, 0.08);
  border-color: rgba(19, 100, 232, 0.35);
  color: var(--brand);
}
.icon-action-wa { color: #128C7E; }
.icon-action-wa:hover {
  background: rgba(18, 140, 126, 0.1);
  border-color: rgba(18, 140, 126, 0.35);
  color: #075E54;
}

.bulk-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(19, 100, 232, 0.1);
  color: var(--brand);
  border: 1px solid rgba(19, 100, 232, 0.22);
  border-radius: var(--radius);
  padding: 0.65rem 0.85rem;
  margin-bottom: 0.75rem;
}
.bulk-bar[hidden] { display: none !important; }
.bulk-bar-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.bulk-bar select, .bulk-bar .btn { margin: 0; }
.bulk-bar select {
  background: #fff;
  color: var(--ink);
  border-color: rgba(19, 100, 232, 0.28);
}
.bulk-bar input.bulk-field[type="datetime-local"],
.bulk-bar input.bulk-field[type="text"] {
  background: #fff;
  color: var(--ink);
  border: 1px solid rgba(19, 100, 232, 0.28);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.55rem;
  font: inherit;
  max-width: 12.5rem;
  min-width: 9rem;
  margin: 0;
}
.bulk-bar .btn.secondary {
  background: #fff;
  border-color: rgba(19, 100, 232, 0.35);
  color: var(--brand);
}
.bulk-bar .btn.secondary:hover {
  background: rgba(19, 100, 232, 0.08);
  border-color: var(--brand);
  color: var(--brand);
}
.bulk-bar .btn.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.bulk-bar .btn.danger:hover {
  filter: brightness(0.95);
  color: #fff;
}
.bulk-count { font-weight: 700; margin-right: 0.25rem; color: var(--brand); }
.bulk-select-opts { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.list-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.tag-create-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.55rem;
  align-items: center;
}
.tag-create-inline input {
  flex: 1;
  min-width: 10rem;
  margin: 0;
}
.tag-picker { margin-top: 0.25rem; }

.bulk-add-wrap { max-height: min(60vh, 520px); overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.bulk-add-table th, .bulk-add-table td { padding: 0.35rem 0.4rem; vertical-align: middle; }
.bulk-add-table input {
  width: 100%;
  min-width: 6rem;
  margin: 0;
  padding: 0.4rem 0.45rem;
  font-size: 0.88rem;
  border-radius: 6px;
}
.bulk-add-table .bulk-row-num { color: var(--muted); font-size: 0.8rem; width: 2rem; text-align: center; }
.lead-drawer[data-mode="form"] .drawer-nav,
.lead-drawer[data-mode="bulk"] .drawer-nav { display: none; }
.lead-drawer[data-mode="form"] .lead-drawer-panel,
.lead-drawer[data-mode="bulk"] .lead-drawer-panel { width: min(720px, 100%); }
.lead-drawer[data-mode="bulk"] .lead-drawer-panel { width: min(960px, 100%); }
.lead-drawer-chrome-title { display: flex; flex-direction: column; align-items: center; gap: 0.1rem; }
.lead-drawer-chrome-title strong { font-size: 0.95rem; }

.lead-pipeline-form { display: flex; flex-direction: column; gap: 0.25rem; }
.pipeline-admin-card h3 { font-weight: 700; }

.stage-pick-modal[hidden] { display: none !important; }
.stage-pick-modal {
  position: fixed;
  inset: 0;
  z-index: 220;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.stage-pick-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 30, 24, 0.4);
}
.stage-pick-card {
  position: relative;
  background: #fff;
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
  width: min(420px, 100%);
  box-shadow: 0 16px 40px rgba(0,0,0,0.18);
}
.stage-pick-card h3 { margin: 0 0 0.35rem; }

/* ——— Pipelines admin ——— */
.pipelines-intro { margin: 0 0 1rem; }
.pipeline-create { margin-bottom: 1rem; }
.pipeline-create-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
}
.pipeline-create-row input { flex: 1; min-width: 14rem; margin: 0; }
.pipeline-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}
.pipeline-tab {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}
.pipeline-tab.is-active {
  background: rgba(19, 100, 232, 0.12);
  border-color: rgba(19, 100, 232, 0.35);
  color: var(--brand);
}
.pipeline-tab .tab-default {
  margin-left: 0.35rem;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.pipeline-board[hidden] { display: none !important; }
.pipeline-board-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--line);
}
.pipeline-name-input {
  font-size: 1.15rem;
  font-weight: 700;
  border: 1px solid transparent;
  background: transparent;
  padding: 0.25rem 0.4rem;
  margin: 0;
  min-width: 10rem;
  flex: 1;
  border-radius: 8px;
}
.pipeline-name-input:hover,
.pipeline-name-input:focus {
  border-color: var(--line);
  background: #fff;
}
.pipeline-board-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.save-pill {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--brand);
  opacity: 0;
  transition: opacity 0.2s;
}
.save-pill.is-visible { opacity: 1; }
.btn-icon-danger {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  opacity: 0.55;
}
.btn-icon-danger:hover:not(:disabled) {
  background: rgba(138, 79, 79, 0.12);
  color: var(--danger);
  opacity: 1;
}
.btn-icon-danger:disabled { opacity: 0.25; cursor: not-allowed; }

.stage-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.stage-row {
  display: grid;
  grid-template-columns: auto auto minmax(8rem, 1fr) auto auto;
  gap: 0.45rem;
  align-items: center;
  padding: 0.45rem 0.5rem;
  background: rgba(19, 100, 232, 0.04);
  border: 1px solid transparent;
  border-radius: 10px;
  transition: box-shadow 0.15s, border-color 0.15s, background 0.15s;
}
.stage-row:hover { border-color: var(--line); background: #fff; }
.stage-row.is-dragging {
  opacity: 0.55;
  border-color: rgba(19, 100, 232, 0.35);
  box-shadow: var(--shadow);
}
.stage-row.is-drag-over {
  border-color: var(--brand);
  background: rgba(19, 100, 232, 0.08);
}
.stage-handle {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: grab;
  padding: 0.25rem 0.2rem;
  letter-spacing: -0.12em;
  font-size: 0.85rem;
  line-height: 1;
}
.stage-handle:active { cursor: grabbing; }
.stage-name-input {
  margin: 0;
  border: 1px solid transparent;
  background: transparent;
  font-weight: 600;
  padding: 0.35rem 0.45rem;
  border-radius: 8px;
}
.stage-name-input:hover,
.stage-name-input:focus {
  border-color: var(--line);
  background: #fff;
}
.stage-swatch {
  position: relative;
  width: 1.65rem;
  height: 1.65rem;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.stage-swatch-dot {
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  background: var(--swatch, #5b8a72);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.35), 0 0 0 1px rgba(0,0,0,0.08);
}
.stage-swatch-pop {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 30;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  width: 8.5rem;
  padding: 0.45rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0,0,0,0.12);
}
.stage-swatch-pop[hidden] { display: none !important; }
.swatch-opt {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  border: 2px solid transparent;
  background: var(--swatch);
  cursor: pointer;
  padding: 0;
}
.swatch-opt.is-selected { border-color: var(--ink); }
.stage-outcome {
  display: inline-flex;
  gap: 0.2rem;
  background: rgba(0,0,0,0.04);
  padding: 0.15rem;
  border-radius: 999px;
}
.outcome-chip {
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  cursor: pointer;
}
.outcome-chip.is-on { background: #fff; color: var(--brand); box-shadow: 0 1px 2px rgba(0,0,0,0.06); }
.outcome-chip.is-on.won { color: #2f7d4a; }
.outcome-chip.is-on.lost { color: #8a4f4f; }
.stage-delete {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.25rem 0.4rem;
  border-radius: 6px;
  opacity: 0;
  transition: opacity 0.15s;
}
.stage-row:hover .stage-delete,
.stage-row:focus-within .stage-delete { opacity: 0.7; }
.stage-delete:hover { opacity: 1 !important; background: rgba(138, 79, 79, 0.12); color: var(--danger); }

.stage-add-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--line);
}
.stage-add-row input[name="name"] { flex: 1; min-width: 10rem; margin: 0; }
.stage-add-row select { width: auto; margin: 0; }

@media (max-width: 860px) {
  .stage-row {
    grid-template-columns: auto auto 1fr auto;
    grid-template-areas:
      "handle swatch name del"
      "handle swatch outcome del";
  }
  .stage-handle { grid-area: handle; }
  .stage-swatch { grid-area: swatch; }
  .stage-name-input { grid-area: name; }
  .stage-outcome { grid-area: outcome; }
  .stage-delete { grid-area: del; opacity: 0.55; }
}


/* ——— Lead side drawer ——— */
.lead-drawer[hidden] { display: none !important; }
.lead-drawer {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  justify-content: flex-end;
}
.lead-drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 30, 24, 0.35);
}
.lead-drawer-panel {
  position: relative;
  width: min(560px, 100%);
  height: 100%;
  background: var(--bg, #f3f6f4);
  box-shadow: -8px 0 32px rgba(0,0,0,0.12);
  display: flex;
  flex-direction: column;
  animation: drawer-in 0.2s ease-out;
}
@keyframes drawer-in {
  from { transform: translateX(18px); opacity: 0.6; }
  to { transform: none; opacity: 1; }
}
.lead-drawer-chrome {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.65rem 0.75rem;
  background: #fff;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.lead-drawer-chrome-title { flex: 1; text-align: center; }
.lead-drawer-body {
  flex: 1;
  overflow: auto;
  padding: 0.85rem;
  -webkit-overflow-scrolling: touch;
}
.lead-drawer-body .lead-detail-grid { grid-template-columns: 1fr; }
.lead-drawer-body .lead-action-groups { grid-template-columns: 1fr 1fr; }

@media (max-width: 860px) {
  .lead-drawer-panel {
    width: 100%;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .lead-drawer-chrome {
    padding-top: calc(0.55rem + env(safe-area-inset-top));
    position: sticky;
    top: 0;
    z-index: 2;
  }
  .lead-drawer-body .lead-action-groups { grid-template-columns: 1fr; }
  .bulk-bar { position: sticky; top: 0; }
  .bulk-select-opts .btn { font-size: 0.75rem; }
}

/* ——— Import method picker ——— */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.import-methods {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.65rem;
  margin: 1rem 0 1.1rem;
}
.import-method {
  appearance: none;
  text-align: left;
  cursor: pointer;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius);
  padding: 0.85rem 0.95rem;
  font-family: var(--font);
  color: var(--ink);
  transition: border-color 0.12s, background 0.12s, box-shadow 0.12s;
}
.import-method:hover {
  border-color: rgba(19, 100, 232, 0.35);
  background: rgba(19, 100, 232, 0.04);
}
.import-method.is-active {
  border-color: var(--brand);
  background: rgba(19, 100, 232, 0.08);
  box-shadow: inset 0 0 0 1px var(--brand);
}
.import-method-title {
  display: block;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--brand);
  margin-bottom: 0.25rem;
}
.import-method-desc {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.35;
  font-weight: 500;
}
.import-panel[hidden] { display: none !important; }
.import-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 36rem;
}
.import-file {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.85rem 1rem;
  border: 1px dashed rgba(19, 100, 232, 0.35);
  border-radius: var(--radius-sm);
  background: rgba(19, 100, 232, 0.03);
  color: var(--muted);
  font-size: 0.85rem;
}
.import-file input[type="file"] {
  font-size: 0.9rem;
  color: var(--ink);
}
.import-url {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (max-width: 860px) {
  .import-methods { grid-template-columns: 1fr; }
}


/* ——— Notification settings ——— */
.notif-fieldset {
  border: none;
  margin: 0 0 1.25rem;
  padding: 0;
}
.notif-fieldset legend {
  display: block;
  width: 100%;
  margin: 0 0 0.55rem;
  padding: 0;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.notif-toggle {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin: 0 0 0.5rem;
  background: #fff;
  cursor: pointer;
  color: var(--ink);
}
.notif-toggle:hover {
  border-color: rgba(19, 100, 232, 0.35);
  background: rgba(19, 100, 232, 0.03);
}
.notif-toggle input[type="checkbox"] {
  margin-top: 0.15rem;
}
.notif-toggle-text {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}
.notif-toggle-text strong {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
}
.notif-toggle-desc {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.35;
}
.notif-schedule {
  margin-top: 0.65rem;
}
.settings-page .settings-lead {
  margin: 0 0 0.85rem;
}
.settings-tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.35rem;
  margin: 0 0 1rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0.15rem;
}
.settings-tab {
  appearance: none;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 0.45rem 0.95rem;
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.settings-tab:hover {
  border-color: rgba(19, 100, 232, 0.35);
  background: rgba(19, 100, 232, 0.04);
}
.settings-tab.is-active {
  border-color: var(--brand);
  background: rgba(19, 100, 232, 0.1);
  color: var(--brand);
}
.settings-panel[hidden] {
  display: none !important;
}
.settings-panel.is-active {
  display: block;
}

/* ——— PWA install ——— */
.pwa-install-banner {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 1rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid rgba(19, 100, 232, 0.25);
  border-radius: var(--radius);
  background: rgba(19, 100, 232, 0.07);
}
.pwa-install-banner[hidden] { display: none !important; }
.pwa-install-banner-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}
.pwa-install-banner-text strong {
  font-size: 0.92rem;
  color: var(--brand);
}
.pwa-install-banner-text span {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 500;
}
.pwa-install-banner-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}
.pwa-install-sheet {
  position: fixed;
  inset: 0;
  z-index: 220;
}
.pwa-install-sheet[hidden] { display: none !important; }
.pwa-install-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 20, 0.45);
}
.pwa-install-sheet-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: min(85vh, 32rem);
  overflow: auto;
  padding: 0.5rem 1.15rem calc(1.25rem + env(safe-area-inset-bottom));
  background: #fff;
  border-radius: 1rem 1rem 0 0;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.12);
}
.pwa-install-sheet-panel h2 {
  margin: 0.25rem 0 0.35rem;
  font-size: 1.15rem;
}
.pwa-install-steps {
  margin: 0.85rem 0 0;
  padding: 0 0 0 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.4;
}
.pwa-install-steps[hidden] {
  display: none !important;
}
.pwa-install-steps li { padding-left: 0.15rem; }
.pwa-share-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: -0.25em;
  color: var(--brand);
  margin: 0 0.15rem;
}
