/* =============================================================
   Leads page (leads.html) — phone first. Builds on style.css.
============================================================= */
input, select, textarea { font-size: 16px; } /* 16px+ stops iOS zooming on focus */

.ld-app { min-height: 100vh; padding-bottom: 6rem; }
.ld-top {
  position: sticky; top: 0; z-index: 10; background: var(--bg);
  border-bottom: 1px solid var(--border); padding-top: env(safe-area-inset-top);
}
.ld-top-row {
  max-width: 760px; margin: 0 auto; padding: 0.7rem 1rem 0.3rem;
  display: flex; align-items: center; gap: 0.6rem;
}
.ld-back { color: var(--muted); text-decoration: none; font-size: 1.2rem; padding: 0.2rem 0.4rem; }
.ld-title { flex: 1; font-size: 1.15rem; }
.ld-tabs { max-width: 760px; margin: 0 auto; display: flex; padding: 0 0.5rem; }
.ld-tabs button {
  flex: 1; background: none; border: none; color: var(--muted); font-weight: 600;
  font-size: 0.92rem; padding: 0.7rem 0.3rem; border-bottom: 2px solid transparent; cursor: pointer;
}
.ld-tabs button.is-on { color: var(--text); border-bottom-color: var(--primary); }

.ld-main { max-width: 760px; margin: 0 auto; padding: 1rem; }

/* Scrollable row of status filter chips */
.ld-chips { display: flex; gap: 0.4rem; overflow-x: auto; padding-bottom: 0.4rem; margin-bottom: 0.6rem; scrollbar-width: none; }
.ld-chips::-webkit-scrollbar { display: none; }
.ld-chip {
  flex-shrink: 0; border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  border-radius: 999px; padding: 0.45rem 0.8rem; font-size: 0.85rem; font-weight: 600; cursor: pointer;
}
.ld-chip.is-on { background: var(--primary); border-color: var(--primary); color: #fff; }
.ld-chip-wrap { flex-wrap: wrap; overflow: visible; }

.ld-search { width: 100%; margin-bottom: 0.7rem; }


.ld-section-title { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin: 1.2rem 0 0.5rem; }
.ld-empty { text-align: center; color: var(--muted); padding: 2.5rem 1rem; }

.badge-blue   { color: #8fb0ff; border-color: rgba(79,124,255,0.45); background: rgba(79,124,255,0.1); }
.badge-purple { color: #c9a2ff; border-color: rgba(167,112,255,0.45); background: rgba(167,112,255,0.1); }

/* Floating add button */
.ld-fab {
  position: fixed; right: 1.2rem; bottom: calc(1.2rem + env(safe-area-inset-bottom));
  width: 60px; height: 60px; border-radius: 50%; border: none; z-index: 15;
  background: var(--primary); color: #fff; font-size: 1.8rem; cursor: pointer;
  box-shadow: 0 8px 24px rgba(79,124,255,0.4);
}

/* Sheet: full screen on a phone, centred card on a wider screen */
.ld-sheet {
  position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,0.6);
  display: flex; align-items: flex-end; justify-content: center;
}
.ld-sheet-card {
  background: var(--surface); width: 100%; max-width: 560px; max-height: 100%;
  border-radius: 18px 18px 0 0; display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}
.ld-sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.9rem 1rem; border-bottom: 1px solid var(--border);
}
.ld-sheet-head h3 { margin: 0; font-size: 1.05rem; }
.ld-sheet-body { padding: 1rem; overflow-y: auto; }
@media (max-width: 600px) {
  .ld-sheet-card { height: 100%; border-radius: 0; padding-top: env(safe-area-inset-top); }
}
@media (min-width: 601px) {
  .ld-sheet { align-items: center; padding: 2rem 1rem; }
  .ld-sheet-card { border-radius: 16px; border: 1px solid var(--border); max-height: calc(100vh - 4rem); }
}

.ld-phone-row { display: flex; gap: 0.5rem; }
.ld-phone-row input { flex: 1; font-size: 1.2rem; letter-spacing: 0.03em; }
.ld-hint { font-size: 0.82rem; margin-top: 0.35rem; }
.ld-hint a { color: var(--primary); cursor: pointer; }
.ld-more { margin: 0.4rem 0 0.9rem; }
.ld-more summary { color: var(--muted); font-size: 0.85rem; cursor: pointer; padding: 0.3rem 0; }
.ld-actions { display: flex; gap: 0.6rem; margin-top: 1rem; }
.ld-actions .btn { flex: 1; padding: 0.8rem; }

.ld-detail-actions { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.ld-detail-actions .btn { flex: 1; padding: 0.7rem; text-align: center; }
.ld-org {
  border: 1px solid var(--border); border-radius: 12px; padding: 0.7rem 0.8rem; margin-bottom: 1rem;
  background: var(--surface-2); font-size: 0.88rem;
}
.ld-org b { font-size: 0.95rem; }
.ld-templates { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 1rem; }
.ld-templates a {
  display: block; padding: 0.6rem 0.75rem; border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); text-decoration: none; font-size: 0.88rem;
}
.ld-templates a span { display: block; color: var(--muted); font-size: 0.78rem; margin-top: 0.15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ld-log { white-space: pre-wrap; font-size: 0.86rem; color: var(--muted); background: var(--bg); border-radius: 10px; padding: 0.6rem 0.7rem; margin-top: 0.5rem; }
.ld-note-row { display: flex; gap: 0.5rem; }
.ld-note-row input { flex: 1; }

.ld-report { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
.ld-report th, .ld-report td { padding: 0.5rem 0.3rem; border-bottom: 1px solid var(--border); text-align: right; }
.ld-report th:first-child, .ld-report td:first-child { text-align: left; }
.ld-pct { display: block; color: var(--muted); font-size: 0.72rem; }
.ld-report td { vertical-align: top; }
.ld-report th { color: var(--muted); font-weight: 600; font-size: 0.75rem; }
.ld-report-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 0.3rem 0.6rem; }

/* ---- Sheet tab: the spreadsheet view ---- */
.ld-main.is-wide { max-width: none; }
.ld-g-bar { display: flex; gap: 0.5rem; }
.ld-g-bar .ld-search { flex: 1; }
.ld-g-bar .btn { margin-bottom: 0.7rem; }
.ld-g-wrap {
  overflow: auto; max-height: calc(100vh - 230px);
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
}
.ld-grid { border-collapse: separate; border-spacing: 0; font-size: 0.86rem; min-width: 100%; }
.ld-grid th {
  position: sticky; top: 0; z-index: 2; background: var(--surface-2); color: var(--muted);
  font-weight: 600; font-size: 0.76rem; text-align: left; white-space: nowrap;
  padding: 0.55rem 0.5rem; border-bottom: 1px solid var(--border); cursor: pointer; user-select: none;
}
.ld-grid th:hover, .ld-grid th.is-sorted { color: var(--text); }
.ld-grid td { border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); padding: 0; vertical-align: middle; }
.ld-grid td:last-child { border-right: none; }
.ld-grid tr:hover td { background: rgba(255,255,255,0.02); }
/* First column stays put while the rest scrolls sideways. */
.ld-grid th:first-child, .ld-grid td:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); }
.ld-grid th:first-child { z-index: 3; background: var(--surface-2); }
.ld-grid input, .ld-grid select {
  width: 100%; border: 1px solid transparent; border-radius: 0; background: transparent;
  padding: 0.5rem; font-size: 0.86rem; color: var(--text); min-width: 0;
}
.ld-grid input:focus, .ld-grid select:focus { border-color: var(--primary); background: var(--bg); }
.ld-grid input.is-saved { border-color: var(--green); }
.ld-grid input[type="date"] { color-scheme: dark; }
.ld-grid .c-phone { min-width: 8.5rem; }
.ld-grid .c-name, .ld-grid .c-business { min-width: 9rem; }
.ld-grid .c-city, .ld-grid .c-campaign { min-width: 7rem; }
.ld-grid .c-machines { width: 5.5rem; }
.ld-grid .c-source { min-width: 7.5rem; }
.ld-grid .c-status { min-width: 12.5rem; }
.ld-grid .c-follow_up { min-width: 9rem; }
.ld-grid .c-note { min-width: 15rem; }
.ld-grid .c-account { min-width: 8rem; }
.ld-grid .c-act { white-space: nowrap; padding: 0 0.4rem; }
.ld-g-ro { display: block; padding: 0.5rem; color: var(--muted); white-space: nowrap; }
.ld-g-status { display: flex; align-items: center; gap: 0.2rem; padding-left: 0.3rem; }
.ld-g-status .badge { white-space: nowrap; }
.ld-g-new td { background: rgba(79,124,255,0.06); border-bottom: 2px solid var(--primary); }
.ld-g-new td:first-child { background: #1a2030; }
.ld-g-new input::placeholder { color: #8fa6e0; }
#g-count { margin: 0.5rem 0 0; }

/* ---- Excel look ---- */
.ld-top-row, .ld-tabs { max-width: none; }
.ld-tabs { justify-content: flex-start; padding: 0 1rem; }
.ld-tabs button { flex: 0 0 auto; padding: 0.7rem 1.2rem; }
.btn-wa { background: #1fa855; color: #fff; text-decoration: none; }
a.btn { text-decoration: none; display: inline-block; }
.ld-grid { font-size: 0.85rem; }
.ld-grid td, .ld-grid th { border-right: 1px solid var(--border); }
.ld-grid input, .ld-grid select { padding: 0.42rem 0.5rem; }
/* Row numbers, pinned like Excel's; the phone column is pinned beside them. */
.ld-grid .c-rn {
  position: sticky; left: 0; z-index: 2; width: 2.6rem; min-width: 2.6rem; max-width: 2.6rem;
  text-align: center; color: var(--muted); font-size: 0.75rem; background: var(--surface-2);
}
.ld-grid th.c-rn { z-index: 4; }
.ld-grid th:first-child, .ld-grid td:first-child { left: 0; }
.ld-grid th:nth-child(2), .ld-grid td:nth-child(2) { position: sticky; left: 2.6rem; z-index: 1; background: var(--surface); }
.ld-grid th:nth-child(2) { z-index: 3; background: var(--surface-2); }
.ld-g-new td:nth-child(2) { background: #1a2030; }
.ld-grid input.is-late { color: var(--red); font-weight: 700; }
.ld-grid input.is-today { color: var(--amber); font-weight: 700; }
.ld-chip-due { border-color: rgba(245,166,35,0.5); color: var(--amber); }
.ld-chip-due.is-on { background: var(--amber); border-color: var(--amber); color: #1a1200; }
.ld-g-wrap { max-height: calc(100vh - 200px); }
/* The ＋ form is for phones; on a computer the sheet's top row is the way in. */
@media (min-width: 761px) { .ld-fab { display: none; } }
