/* Arab Dreams Leads — Apple-style with dark nav */
:root {
  --bg: #ffffff;
  --bg-2: #f5f5f7;
  --bg-3: #fafafa;
  --line: #d2d2d7;
  --line-soft: #e5e5ea;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --accent: #0071e3;
  --accent-pressed: #0058b8;
  --danger: #ff3b30;
  --ok: #34c759;
  --warn: #ff9500;
  --purple: #5e5ce6;
  --purple-2: #8e8aff;
  --teal: #30b0c7;
  --indigo: #5856d6;
  --cyan: #32ade6;
  --amber: #ffb340;

  /* matte plum nav palette */
  --nav-bg: #5c3853;
  --nav-bg-rgba: rgba(92,56,83,.88);
  --nav-text: #ffffff;
  --nav-muted: #c9aabf;
  --nav-line: #774962;
  --nav-active-bg: #6e4565;
  --nav-accent: #ffd166;  /* warm gold-ish, reads on plum better than blue */

  --radius: 12px;
  --radius-sm: 10px;
  --radius-lg: 16px;
  --tap: 44px;
  --shadow-card: 0 1px 2px rgba(0,0,0,.04);
  --shadow-pop: 0 8px 24px rgba(0,0,0,.08);
  --shadow-card-hover: 0 4px 12px rgba(0,0,0,.08);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", Inter, system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
html, body { margin: 0; padding: 0; height: 100%; background: var(--bg); }
body {
  font-family: var(--font);
  color: var(--text);
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
button, input, select, textarea {
  font-family: inherit;
  font-size: 15px;
  color: inherit;
}
button { cursor: pointer; border: none; background: none; color: inherit; padding: 0; }
a { color: var(--accent); text-decoration: none; }

.boot {
  display: flex; align-items: center; justify-content: center;
  height: 100vh; color: var(--muted); font-size: 14px;
}

/* ---------- BOOT / SPLASH SCREEN ---------- */
.boot-screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #f5f5f7 100%);
  z-index: 1;
}
.boot-screen .boot-logo {
  width: 84px; height: 84px;
  border-radius: 22%;
  object-fit: cover;
  box-shadow: 0 6px 18px rgba(0,0,0,.08);
  animation: logo-pulse 2s ease-in-out infinite;
}
.boot-screen .boot-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.4px;
}
.boot-dots {
  display: inline-flex; gap: 6px;
}
.boot-dots span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--muted);
  opacity: 0.4;
  animation: dot-bounce 1.2s ease-in-out infinite;
}
.boot-dots span:nth-child(2) { animation-delay: 0.15s; }
.boot-dots span:nth-child(3) { animation-delay: 0.30s; }

@keyframes logo-pulse {
  0%, 100% { transform: scale(1);    opacity: 0.95; }
  50%      { transform: scale(1.04); opacity: 1;    }
}
@keyframes dot-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40%           { transform: translateY(-5px); opacity: 1; }
}

/* Signed-out confirmation */
.signed-out-screen {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px;
  background: #fff;
  color: var(--text);
  animation: fade-in .2s ease both;
}
.signed-out-screen .check {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: rgba(52,199,89,.12);
  color: var(--ok);
  display: inline-flex; align-items: center; justify-content: center;
}
.signed-out-screen .check svg { width: 32px; height: 32px; }
.signed-out-screen .label { font-size: 16px; font-weight: 500; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* SVG icons */
.ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px;
  flex-shrink: 0;
}
.ico svg { width: 100%; height: 100%; display: block; }

/* ---------- LOGIN ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px;
  background: linear-gradient(180deg, #ffffff 0%, #f5f5f7 100%);
}
.login-card {
  width: 100%; max-width: 380px;
  background: #ffffff;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: 0 10px 40px rgba(0,0,0,.06);
}
.login-logo { display: flex; flex-direction: column; align-items: center; margin-bottom: 28px; }
.login-logo img {
  width: 72px; height: 72px;
  border-radius: 22%;
  object-fit: cover;
  margin-bottom: 14px;
  box-shadow: 0 6px 18px rgba(0,0,0,.08);
  animation: logo-pulse 2s ease-in-out infinite;
}
.login-logo h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.3px;
  color: var(--text);
}
.login-logo .sub {
  color: var(--muted);
  font-size: 13px;
  margin-top: 6px;
}
.login-card .field input { transition: box-shadow .15s ease, border-color .15s ease; }
.login-card .field input:focus {
  border-color: var(--line);
  box-shadow: 0 0 0 3px rgba(0,113,227,.18);
}
.login-card .btn.block { margin-top: 6px; }
.login-foot {
  margin-top: 22px;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.2px;
}
.login-foot a { color: var(--muted); }

/* fields */
.field { display: flex; flex-direction: column; margin-bottom: 16px; }
.field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 6px;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color .15s ease;
  -webkit-appearance: none;
  appearance: none;
}
.field select {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236e6e73' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
  padding-right: 32px;
}
.field textarea { min-height: 88px; resize: vertical; line-height: 1.5; }
.field input:focus,
.field select:focus,
.field textarea:focus { border-color: var(--accent); }
.field input:disabled,
.field select:disabled {
  background: var(--bg-2);
  color: var(--muted);
}
.field .hint { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap);
  padding: 0 18px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 15px;
  background: var(--accent);
  color: #fff;
  transition: background-color .15s ease, transform .05s ease, opacity .15s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--accent-pressed); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.block { width: 100%; display: flex; }
.btn.secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
}
.btn.secondary:hover { background: var(--bg-2); }
.btn.ghost {
  background: transparent;
  color: var(--accent);
  padding: 0 10px;
  min-height: 36px;
}
.btn.ghost:hover { background: var(--bg-2); }
.btn.danger {
  background: var(--bg);
  color: var(--danger);
  border: 1px solid var(--line);
}
.btn.danger:hover { background: rgba(255,59,48,.06); }
.btn.destructive {
  background: var(--danger);
  color: #fff;
  border: none;
}
.btn.destructive:hover { background: #cc2f26; }
.btn.sm {
  min-height: 36px;
  padding: 0 14px;
  font-size: 13px;
  border-radius: 8px;
}
.btn.icon-only {
  min-width: 36px; min-height: 36px;
  padding: 0 8px;
}

.err {
  background: rgba(255,59,48,.06);
  color: var(--danger);
  border: 1px solid rgba(255,59,48,.2);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 12px;
}

/* ---------- APP SHELL ---------- */
.shell {
  display: flex; flex-direction: column;
  min-height: 100vh;
  padding-bottom: 76px;
  background: var(--bg);
}
.shell-main {
  overscroll-behavior-y: contain;
}
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  background: var(--nav-bg-rgba);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid var(--nav-line);
  color: var(--nav-text);
}
.topbar .logo {
  width: 32px; height: 32px;
  border-radius: 50%;
  object-fit: cover;
}
.topbar .title {
  flex: 1;
  font-weight: 600;
  font-size: 15px;
  line-height: 1.15;
  color: var(--nav-text);
}
.topbar .title small {
  display: block;
  color: var(--nav-muted);
  font-size: 12px;
  font-weight: 400;
  margin-top: 2px;
}
.topbar .bell {
  position: relative;
  width: 40px; height: 40px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--nav-text);
}
.topbar .bell:hover { background: rgba(255,255,255,.08); }
.topbar .bell .dot {
  position: absolute;
  top: 8px; right: 8px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--nav-accent);
  display: none;
  border: 1.5px solid var(--nav-bg);
}
.topbar .bell.has .dot { display: block; }

/* bottom tabs */
.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; justify-content: space-around;
  background: var(--nav-bg-rgba);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--nav-line);
  padding: 4px 0 max(4px, env(safe-area-inset-bottom));
}
.tabs .tab {
  flex: 1; position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px;
  min-height: var(--tap);
  color: var(--nav-muted);
  font-size: 11px;
  font-weight: 500;
  transition: color .15s ease;
}
.tabs .tab:hover { color: var(--nav-text); }
.tabs .tab.active { color: var(--nav-accent); }
.tabs .tab.active::before {
  content: '';
  position: absolute;
  top: 0; left: 24%; right: 24%;
  height: 2px;
  background: var(--nav-accent);
  border-radius: 0 0 2px 2px;
}
.tabs .tab .ico { width: 22px; height: 22px; }

/* desktop sidebar (hidden on mobile by default) */
.sidebar { display: none; }

/* page */
.page { padding: 16px; }
.page h2 {
  margin: 0 0 16px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.3px;
  color: var(--text);
}
.page h3 {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  margin: 24px 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* search & filter bar */
.searchbar {
  position: sticky; top: 53px; z-index: 9;
  padding: 10px 16px;
  background: rgba(255,255,255,.96);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid var(--line-soft);
  box-shadow: 0 1px 0 var(--line-soft);
  display: flex; gap: 8px; align-items: center;
}
.search-input {
  flex: 1;
  position: relative;
  display: flex; align-items: center;
}
.search-input .ico {
  position: absolute; left: 10px; pointer-events: none;
  color: var(--muted);
  width: 18px; height: 18px;
}
.search-input input {
  width: 100%;
  min-height: 38px;
  padding: 0 36px 0 36px;
  border-radius: 10px;
  background: var(--bg-2);
  border: 1px solid transparent;
  color: var(--text);
  outline: none;
  font-size: 14px;
}
.search-input input:focus { background: var(--bg); border-color: var(--line); }
.search-input .clear {
  position: absolute; right: 4px;
  width: 30px; height: 30px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted);
}
.search-input .clear:hover { color: var(--text); background: var(--line-soft); }
.btn-filter {
  position: relative;
  display: inline-flex; align-items: center; gap: 4px;
  min-height: 38px;
  padding: 0 12px;
  background: var(--bg-2);
  color: var(--text);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
}
.btn-filter:hover { background: var(--line-soft); }
.btn-filter .count {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  min-width: 18px; height: 18px;
  padding: 0 5px;
  margin-left: 2px;
}

/* view toggle */
.view-toggle {
  display: inline-flex;
  background: var(--bg-2);
  border-radius: 8px;
  padding: 2px;
  gap: 0;
}
.view-toggle button {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 4px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  border-radius: 6px;
  min-height: 32px;
}
.view-toggle button.active {
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.view-toggle button .ico { width: 16px; height: 16px; }

.leads-header {
  padding: 14px 16px 6px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
}
.leads-header h2 { margin: 0; }

/* ---------- LEAD LIST (Apple list style) ---------- */
.lead-list {
  margin: 8px 16px 120px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.lead-list .lead {
  display: flex; align-items: stretch; gap: 12px;
  padding: 14px 14px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--bg);
  cursor: pointer;
  transition: background-color .12s ease, transform .15s ease, box-shadow .15s ease;
  animation: leadFadeIn .35s ease both;
}
.lead-list .lead:last-child { border-bottom: none; }
.lead-list .lead:hover,
.lead-list .lead:active { background: var(--bg-2); }
.lead-list .lead .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.lead-list .lead .id-row {
  display: flex; align-items: center; gap: 8px;
  justify-content: space-between;
}
.lead-list .lead .seq-id {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  display: inline-block;
  letter-spacing: 0;
}
.lead-list .lead .title {
  font-size: 16px; font-weight: 600;
  color: var(--text);
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.lead-list .lead .meta-row {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px;
  color: var(--muted);
  min-width: 0;
}
.lead-list .lead .meta-row .ico { width: 14px; height: 14px; flex-shrink: 0; }
.lead-list .lead .meta-row .txt {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.lead-list .lead .meta-row a {
  color: var(--text);
  font-weight: 500;
}
.lead-list .lead .badge-row {
  display: flex; flex-wrap: wrap; gap: 6px;
  align-items: center;
  margin-top: 2px;
}
.lead-list .lead .note-preview {
  margin-top: 4px;
  padding: 8px 10px;
  border-left: 3px solid var(--line);
  background: var(--bg-2);
  border-radius: 6px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.lead-list .lead .right {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  flex-shrink: 0;
  color: var(--muted);
}
.lead-list .lead .right .ico { width: 18px; height: 18px; }
.lead-list .lead .collab-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0,113,227,.08);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
}
.lead-list .lead .collab-badge .ico { width: 12px; height: 12px; }

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

/* table view */
.lead-table-wrap {
  margin: 8px 0 120px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  background: var(--bg);
}
.lead-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.lead-table th,
.lead-table td {
  padding: 10px 14px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--line-soft);
}
.lead-table th {
  background: var(--bg-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  position: sticky; top: 0;
  z-index: 1;
}
.lead-table th:first-child,
.lead-table td:first-child {
  position: sticky; left: 0;
  background: var(--bg);
  z-index: 2;
  border-right: 1px solid var(--line-soft);
  font-weight: 500;
}
.lead-table th:first-child { background: var(--bg-2); z-index: 3; }
.lead-table tbody tr { cursor: pointer; }
.lead-table tbody tr:nth-child(even) td { background: var(--bg-2); }
.lead-table tbody tr:nth-child(even) td:first-child { background: var(--bg-2); }
.lead-table tbody tr:hover td,
.lead-table tbody tr:hover td:first-child { background: var(--line-soft); }

/* badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.2px;
  background: rgba(110,110,115,.1);
  color: var(--muted);
  white-space: nowrap;
}
.badge .ico { width: 12px; height: 12px; }
.badge .bdot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.badge.status-new                 { background: rgba(0,113,227,.1); color: var(--accent); }
.badge.status-contacted           { background: rgba(255,149,0,.12); color: var(--warn); }
.badge.status-qualified           { background: rgba(48,176,199,.14); color: var(--teal); }
.badge.status-proposal_sent       { background: rgba(88,86,214,.14); color: var(--indigo); }
.badge.status-negotiating         { background: rgba(255,179,64,.18); color: #c97a00; }
.badge.status-company_formation   { background: rgba(94,92,230,.14); color: var(--purple); }
.badge.status-license_application { background: rgba(142,138,255,.18); color: var(--purple-2); }
.badge.status-documentation       { background: rgba(50,173,230,.14); color: var(--cyan); }
.badge.status-on_hold             { background: rgba(110,110,115,.12); color: var(--muted); }
.badge.status-won                 { background: rgba(52,199,89,.12); color: #1f8c3b; }
.badge.status-lost                { background: rgba(255,59,48,.1); color: var(--danger); }
.badge.overdue                    { background: rgba(255,59,48,.1); color: var(--danger); }
.badge.due-today                  { background: rgba(255,149,0,.12); color: var(--warn); }
.badge.upcoming                   { background: rgba(0,113,227,.1); color: var(--accent); }

/* tag (replaces role-pill) */
.tag {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  background: var(--bg-2);
  color: var(--muted);
  letter-spacing: 0;
  text-transform: none;
}
.tag.admin { background: rgba(0,113,227,.1); color: var(--accent); }
.tag.user  { background: var(--bg-2); color: var(--muted); }
.tag.inactive { background: rgba(255,59,48,.1); color: var(--danger); }
.tag.req { background: rgba(0,113,227,.1); color: var(--accent); }

/* FAB */
.fab {
  position: fixed; right: 18px; bottom: 86px; z-index: 11;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--bg);
  color: var(--accent);
  border: 1.5px solid var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,.08);
  transition: transform .12s ease, background-color .12s ease;
  will-change: transform;
}
.fab:hover { background: rgba(0,113,227,.06); }
.fab:active { transform: scale(.95); }
.fab .ico { width: 26px; height: 26px; }

/* empty */
.empty {
  text-align: center;
  color: var(--muted);
  padding: 60px 24px;
}
.empty .ico-lg {
  width: 56px; height: 56px;
  margin: 0 auto 12px;
  color: var(--line);
}
.empty .ico-lg svg { width: 100%; height: 100%; }
.empty .pri { font-size: 16px; font-weight: 500; color: var(--text); margin-bottom: 4px; }
.empty .sec { font-size: 13px; color: var(--muted); }

/* ---------- MODAL / SHEET ---------- */
.sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0;
  transition: opacity .2s ease;
}
.sheet-backdrop.open { opacity: 1; }
.sheet {
  width: 100%;
  max-width: 560px;
  background: var(--bg);
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  max-height: 92vh;
  overflow-y: auto;
  display: flex; flex-direction: column;
  transform: translateY(20px);
  transition: transform .25s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 -4px 30px rgba(0,0,0,.12);
  will-change: transform;
}
.sheet-backdrop.open .sheet { transform: translateY(0); }
.sheet-head {
  position: sticky; top: 0;
  background: rgba(255,255,255,.92);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: 10px;
  z-index: 2;
}
.sheet-head h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  flex: 1;
  color: var(--text);
  text-transform: none;
  letter-spacing: -0.2px;
}
.sheet-body { padding: 16px; }
.sheet-foot {
  position: sticky; bottom: 0;
  background: rgba(255,255,255,.92);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  padding: 12px 16px max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line-soft);
  display: flex; gap: 8px;
}
.sheet-foot .btn { flex: 1; }

@media (min-width: 560px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 16px; max-height: 86vh; }
}

/* action-sheet style confirm */
.action-sheet {
  width: 100%;
  max-width: 360px;
  background: var(--bg);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  transform: scale(0.96);
  opacity: 0;
  transition: transform .18s ease, opacity .18s ease;
}
.sheet-backdrop.open .action-sheet { transform: scale(1); opacity: 1; }
.action-sheet .ah-head {
  padding: 18px 18px 12px;
  text-align: center;
}
.action-sheet .ah-title {
  font-size: 15px; font-weight: 600; color: var(--text);
  margin-bottom: 4px;
}
.action-sheet .ah-msg {
  font-size: 13px; color: var(--muted); line-height: 1.45;
}
.action-sheet .ah-actions {
  display: flex; flex-direction: column;
  border-top: 1px solid var(--line-soft);
}
.action-sheet .ah-actions button {
  width: 100%;
  padding: 14px;
  font-size: 15px;
  font-weight: 500;
  color: var(--accent);
  border-bottom: 1px solid var(--line-soft);
}
.action-sheet .ah-actions button:last-child { border-bottom: none; }
.action-sheet .ah-actions button:hover { background: var(--bg-2); }
.action-sheet .ah-actions button.destructive { color: var(--danger); }
.action-sheet .ah-actions button.cancel { color: var(--text); font-weight: 600; }

@media (min-width: 560px) {
  .sheet-backdrop > .action-sheet { margin: auto; }
}

/* ---------- LIST / ROW CARDS (admin etc) ---------- */
.row-list {
  display: flex; flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.row-list .row-card {
  background: var(--bg);
  padding: 14px 16px;
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--line-soft);
  transition: background-color .12s ease;
}
.row-list .row-card:last-child { border-bottom: none; }
.row-list .row-card.clickable { cursor: pointer; }
.row-list .row-card.clickable:hover { background: var(--bg-2); }
.row-card .grow { flex: 1; min-width: 0; }
.row-card .grow .pri {
  font-size: 15px; font-weight: 500; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.row-card .grow .sec {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis;
}
.row-card .actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ---------- REMINDERS ---------- */
.rem-section { margin-bottom: 20px; }
.rem-section .hdr {
  font-size: 13px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 8px;
  display: flex; align-items: center; gap: 8px;
  font-weight: 600;
}
.rem-section .hdr .dot {
  display: inline-block;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted);
}
.rem-section.overdue .hdr .dot { background: var(--danger); }
.rem-section.today .hdr .dot { background: var(--warn); }
.rem-section.upcoming .hdr .dot { background: var(--accent); }
.rem-section .hdr .count {
  background: var(--bg-2);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
}
.rem-section.overdue .hdr .count { background: rgba(255,59,48,.1); color: var(--danger); }
.rem-section.today .hdr .count   { background: rgba(255,149,0,.12); color: var(--warn); }

/* ---------- NOTIFICATIONS DROPDOWN ---------- */
.notif-pop {
  position: fixed;
  top: 60px; right: 12px;
  width: min(92vw, 360px);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  z-index: 30;
  max-height: 60vh;
  overflow-y: auto;
}
.notif-pop .item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 14px;
  cursor: pointer;
  color: var(--text);
}
.notif-pop .item:last-child { border-bottom: none; }
.notif-pop .item:hover { background: var(--bg-2); }
.notif-pop .item .when { color: var(--muted); font-size: 12px; margin-top: 4px; }
.notif-pop .item.unread { background: rgba(0,113,227,.04); }
.notif-pop .empty-row {
  padding: 30px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ---------- TOAST ---------- */
#toast {
  position: fixed; bottom: 96px; left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--bg);
  color: var(--text);
  padding: 12px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-pop);
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
  z-index: 100;
  max-width: 90vw;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
#toast.ok  { color: var(--ok); border-color: rgba(52,199,89,.3); }
#toast.err { color: var(--danger); border-color: rgba(255,59,48,.3); }
#toast.info { color: var(--accent); border-color: rgba(0,113,227,.3); }

/* offline bar */
#offline-bar {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 200;
  text-align: center;
  font-size: 12px;
  font-weight: 500;
  background: var(--warn);
  color: #fff;
  padding: 6px 12px;
}

/* install banner */
#install-banner {
  margin: 12px 16px;
  padding: 14px 16px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex; align-items: center; gap: 12px;
  font-size: 13px;
}
#install-banner .grow { flex: 1; }
#install-banner .grow .pri { font-weight: 500; color: var(--text); font-size: 14px; }
#install-banner .grow .sec { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* push toggle row */
.push-row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 10px;
}
.push-row .grow { flex: 1; }
.push-row .grow .pri { font-weight: 500; font-size: 15px; color: var(--text); }
.push-row .grow .sec { color: var(--muted); font-size: 13px; margin-top: 2px; line-height: 1.4; }
.push-row .actions { display: flex; gap: 6px; }

/* chips (for filter sheet) */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px;
  cursor: pointer;
  transition: background-color .12s ease, color .12s ease, border-color .12s ease;
  min-height: 36px;
}
.chip:hover { background: var(--line-soft); }
.chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* skeletons */
.skeleton {
  background: linear-gradient(90deg, var(--bg-2) 0%, var(--line-soft) 50%, var(--bg-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: 8px;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skel-line { height: 14px; margin: 6px 0; }
.skel-row {
  display: flex; flex-direction: column; gap: 6px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
}
.skel-row:last-child { border-bottom: none; }

/* misc */
.muted { color: var(--muted); }
.spacer { height: 14px; }
.spacer.lg { height: 24px; }
.divider { height: 1px; background: var(--line-soft); margin: 24px 0; }
.right { margin-left: auto; }
.flex { display: flex; gap: 8px; align-items: center; }
.kv {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 14px;
}
.kv:last-child { border: none; }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 500; text-align: right; word-break: break-word; color: var(--text); }
.note-block {
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--bg-2);
  border-left: 3px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  color: var(--muted);
  white-space: pre-wrap;
  line-height: 1.4;
}

/* status pills used inline */
.inline-status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--muted);
}
.inline-status .ico { width: 14px; height: 14px; }

/* status chip row — horizontal scrollable selector in lead form */
.status-chip-row {
  display: flex; gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 2px 6px;
  margin: 0 -2px;
  scrollbar-width: none;
}
.status-chip-row::-webkit-scrollbar { display: none; }
.status-chip-row .chip {
  flex-shrink: 0;
  min-height: 34px;
  padding: 6px 14px;
  font-size: 13px;
}

/* pill row for multiselect */
.pill-row {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color .12s ease, color .12s ease, border-color .12s ease;
  min-height: 32px;
}
.pill:hover { background: var(--bg-2); }
.pill.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.add-other {
  display: inline-flex; align-items: center; gap: 4px;
  background: none;
  color: var(--accent);
  font-size: 13px;
  font-weight: 500;
  padding: 4px 8px;
  margin-top: 6px;
}
.add-other:hover { text-decoration: underline; }
.add-other-input {
  margin-top: 8px;
  display: flex; gap: 6px;
}
.add-other-input input {
  flex: 1;
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  outline: none;
}
.add-other-input input:focus { border-color: var(--accent); }

/* sequential id label */
.seq-id {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0;
}
.lead-table .seq-id-cell {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}
.sheet-head .seq-id { margin-right: 8px; }

/* lead cards grid — only takes effect when .lead-list is given .lead-grid class on wide screens */
.lead-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}

/* reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0s !important;
    transition-duration: 0s !important;
  }
  .skeleton { animation: none; background: var(--bg-2); }
}

/* ---------------- DESKTOP / RESPONSIVE ---------------- */
@media (min-width: 768px) {
  .shell {
    padding-bottom: 0;
  }
  .shell {
    display: grid;
    grid-template-columns: 240px 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "top  top"
      "side main";
    min-height: 100vh;
  }
  .topbar {
    grid-area: top;
  }
  #main {
    grid-area: main;
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
    padding: 0 8px;
    overscroll-behavior-y: contain;
  }
  .sidebar {
    display: flex;
    flex-direction: column;
    grid-area: side;
    background: var(--nav-bg);
    color: var(--nav-text);
    border-right: 1px solid var(--nav-line);
    padding: 12px 0;
    position: sticky;
    top: 53px;
    align-self: start;
    height: calc(100vh - 53px);
    overflow-y: auto;
  }
  .sidebar .stab {
    position: relative;
    display: flex; align-items: center; gap: 12px;
    padding: 12px 18px;
    color: var(--nav-muted);
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    border-left: 4px solid transparent;
    transition: background-color .12s ease, color .12s ease;
    width: 100%;
    cursor: pointer;
  }
  .sidebar .stab:hover { color: var(--nav-text); background: rgba(255,255,255,.04); }
  .sidebar .stab.active {
    background: var(--nav-active-bg);
    color: var(--nav-text);
    border-left-color: var(--nav-accent);
  }
  .sidebar .stab .ico { width: 20px; height: 20px; }

  .tabs { display: none; }

  /* card view becomes grid */
  .lead-list.lead-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 12px;
    border: none;
    overflow: visible;
    background: transparent;
    margin: 8px 16px 40px;
  }
  .lead-list.lead-grid .lead {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    background: var(--bg);
  }
  .lead-list.lead-grid .lead:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-card-hover);
    background: var(--bg);
  }
  .lead-list.lead-grid .lead:last-child { border-bottom: 1px solid var(--line); }

  /* table view: no horizontal scroll on wide screens */
  .lead-table-wrap {
    overflow-x: visible;
    margin: 8px 16px 40px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
  }
  .lead-table {
    width: 100%;
    min-width: 0;
  }
  .lead-table th, .lead-table td { white-space: normal; }
  .lead-table th:first-child, .lead-table td:first-child { position: static; }

  /* lead sheet becomes centered modal */
  .sheet-backdrop {
    align-items: center;
  }
  .sheet {
    border-radius: 16px;
    max-height: 86vh;
    max-width: 560px;
  }

  /* push FAB up off the (now hidden) bottom tabs */
  .fab { bottom: 28px; }

  .searchbar { top: 53px; }
}

@media (min-width: 1024px) {
  #main { padding: 0 16px; }
}

/* ---------- TOAST polish (overrides earlier) ---------- */
#toast {
  box-shadow: 0 12px 32px rgba(0,0,0,.14);
  transform: translateX(-50%) translateY(20px);
  border-radius: 12px;
}
#toast.show {
  transform: translateX(-50%) translateY(0);
}

/* ---------- REPORTS TAB ---------- */
.reports {
  padding: 16px;
  display: flex; flex-direction: column; gap: 16px;
}
.reports .period-row {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.reports .summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.reports .sum-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  display: flex; flex-direction: column; gap: 6px;
  box-shadow: var(--shadow-card);
}
.reports .sum-card .lbl {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.reports .sum-card .num {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.5px;
  color: var(--text);
}
.reports .sum-card .extra {
  font-size: 12px;
  color: var(--muted);
}
.reports .sum-card.danger .num { color: var(--danger); }
.reports .sum-card.ok .num    { color: var(--ok); }
.reports .charts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.reports .chart-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: var(--shadow-card);
}
.reports .chart-card h4 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0;
  text-transform: none;
}
.reports .chart-wrap {
  position: relative;
  height: 240px;
  width: 100%;
}
.reports .placeholder {
  padding: 60px 20px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--bg-2);
  color: var(--muted);
}

@media (min-width: 768px) {
  .reports .summary-grid { grid-template-columns: repeat(4, 1fr); }
  .reports .charts-grid  { grid-template-columns: 1fr 1fr; }
}

/* ---------- COLLABORATORS ---------- */
.collab-section {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}
.collab-section .ch-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 10px;
}
.collab-section .ch-head h4 {
  margin: 0; flex: 1;
  font-size: 13px; font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.collab-list {
  display: flex; flex-direction: column; gap: 6px;
}
.collab-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: var(--bg);
}
.collab-row .grow { flex: 1; min-width: 0; }
.collab-row .nm { font-weight: 500; font-size: 14px; color: var(--text); }
.collab-row .em { font-size: 12px; color: var(--muted); }
.collab-row .x-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted);
}
.collab-row .x-btn:hover { background: var(--bg-2); color: var(--danger); }
.collab-empty {
  padding: 12px 12px;
  font-size: 13px;
  color: var(--muted);
  background: var(--bg-2);
  border-radius: 10px;
}
.collab-picker {
  margin-top: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  max-height: 240px;
  overflow-y: auto;
}
.collab-picker .pick-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.collab-picker .pick-row:hover { background: var(--bg-2); }
.collab-picker .pick-row .nm { font-weight: 500; }
.collab-picker .pick-row .em { font-size: 12px; color: var(--muted); }

/* owner reassign confirm strip */
.owner-confirm {
  margin-top: 8px;
  padding: 10px 12px;
  border: 1px solid rgba(255,149,0,.35);
  background: rgba(255,149,0,.07);
  border-radius: 10px;
  font-size: 13px;
  color: var(--text);
  display: flex; flex-wrap: wrap; gap: 8px;
  align-items: center;
}
.owner-confirm .msg { flex: 1; min-width: 200px; }

/* Greet line on Me */
.me-greet {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.3px;
  color: var(--text);
  margin-bottom: 4px;
}
.me-greet small {
  display: block;
  font-size: 13px;
  color: var(--muted);
  font-weight: 400;
  margin-top: 4px;
}

/* Empty leads with Clear filters button */
.empty .actions { margin-top: 14px; display: flex; justify-content: center; gap: 8px; }

@media (min-width: 768px) {
  /* avoid grid item shadows being clipped on big screens */
  .reports { padding: 16px 16px 40px; }
}
