/* Olivv Hub Field — mobile-first app for the sales team, in the Olivv design
   language (olivv-frontend: Inter, ink primary, olive green, square corners). */
:root {
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  --bg: #fbfbf9;
  --surface: #ffffff;
  --text: #111110;
  --text-muted: #5f5f58;
  --text-faint: #8f8f86;
  --border: #eaeae4;
  --input: #d6d6ce;
  --muted: #f6f6f3;
  --ink: #111110;
  --olive: #1a7f4b;
  --olive-soft: #e9f5ee;
  --brand-bright: #2dd736;
  --warn-text: #8a4b00;
  --warn-soft: #fff5e5;
  --warn-line: #f0d3a0;
  --bad: #b42318;
  --bad-soft: #fdeeec;
  --bad-line: #f5c9c3;
  --chip-on-bg: #dcfce7;
  --chip-on-border: #16a34a;
  --chip-on-fg: #14532d;
  --bar-h: 56px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); color: var(--text); background: var(--bg);
  font-size: 16px; line-height: 1.45; -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--ink); text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: 16px; }
.hidden { display: none !important; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); font-size: 13px; }

/* ── App bar ─────────────────────────────────────────────────────────── */
.appbar {
  position: sticky; top: 0; z-index: 20;
  height: calc(var(--bar-h) + env(safe-area-inset-top));
  /* Line the bar up with the 640px content column on wide screens. */
  padding: env(safe-area-inset-top) max(4px, calc((100% - 648px) / 2)) 0;
  display: flex; align-items: center; gap: 4px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.appbar-logo { height: 22px; margin-left: 12px; }
.appbar-title {
  flex: 1; font-size: 17px; font-weight: 600; letter-spacing: -.01em; padding-left: 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.appbar-logo:not(.hidden) + .appbar-title { padding-left: 10px; margin-left: 10px; border-left: 1px solid var(--border); font-weight: 500; color: var(--text-muted); }
#back-btn:not(.hidden) ~ .appbar-title { padding-left: 0; }
.icon-btn {
  width: 48px; height: 48px; border: 0; background: none;
  font-size: 22px; color: var(--text); display: grid; place-items: center;
}
.icon-btn:active { background: var(--muted); }
.menu {
  position: absolute; right: max(8px, calc((100% - 640px) / 2)); top: calc(var(--bar-h) + env(safe-area-inset-top) - 4px);
  background: var(--surface); border: 1px solid var(--border); box-shadow: 0 8px 24px rgba(17,17,16,.08);
  min-width: 220px; padding: 4px 0; z-index: 30;
}
.menu-who { padding: 10px 16px; font-size: 13px; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.menu-item {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 16px;
  border: 0; background: none; color: var(--text); text-align: left; font-size: 15px;
}
.menu-item:hover { background: var(--muted); }
.menu-item i { font-size: 20px; color: var(--text-muted); }
.menu-item.danger, .menu-item.danger i { color: var(--bad); }

/* ── Screen ─────────────────────────────────────────────────────────── */
.screen {
  padding: 12px 12px calc(96px + env(safe-area-inset-bottom));
  max-width: 640px; margin: 0 auto;
}

/* ── Building blocks ─────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  padding: 16px; margin-bottom: 12px;
}
.card h3 { margin: 0 0 10px; font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); padding: 12px 10px; text-align: center; }
.stat b { display: block; font-size: 24px; font-weight: 600; letter-spacing: -.02em; }
.stat span { font-size: 12px; color: var(--text-muted); }

.searchbar { display: flex; gap: 8px; margin-bottom: 10px; }
.input, .select, .textarea {
  width: 100%; min-height: 48px; padding: 10px 14px; border: 1px solid var(--input); border-radius: 0;
  background: var(--surface); color: var(--text); -webkit-appearance: none; appearance: none;
}
.select {
  padding-right: 36px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath stroke='%235f5f58' stroke-width='1.6' d='m1 1.5 5 5 5-5'/%3E%3C/svg%3E") no-repeat right 14px center;
}
.textarea { min-height: 96px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.label { display: block; font-size: 14px; font-weight: 500; margin: 14px 0 6px; }
.label:first-child { margin-top: 0; }
.hint { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.btn {
  min-height: 48px; padding: 0 18px; border: 1px solid var(--input); border-radius: 0;
  background: var(--surface); color: var(--ink); font-weight: 500;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:active { background: var(--muted); }
.btn i { font-size: 20px; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-primary:active { background: #2a2a28; }
.btn-green { background: var(--olive); border-color: var(--olive); color: #fff; }
.btn-green:active { background: #156b3f; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .45; }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }
.sticky-actions {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(rgba(251,251,249,0), var(--bg) 30%);
}
.sticky-actions > div { max-width: 640px; margin: 0 auto; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 40px; padding: 8px 14px; border: 1px solid var(--input); border-radius: 0;
  background: var(--surface); color: var(--text); font-size: 14px;
}
.chip.on { background: var(--chip-on-bg); border-color: var(--chip-on-border); color: var(--chip-on-fg); font-weight: 500; }
/* One swipeable row of filter chips. */
.chips-scroll { flex-wrap: nowrap; overflow-x: auto; margin: 0 -12px 10px; padding: 0 12px 2px; scrollbar-width: none; }
.chips-scroll::-webkit-scrollbar { display: none; }
.chips-scroll .chip { flex: none; }

/* Visit outcome picker */
.outcomes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.outcome {
  min-height: 64px; border: 1px solid var(--input); border-radius: 0;
  background: var(--surface); font-size: 15px; font-weight: 500; color: var(--text);
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.outcome i { font-size: 22px; }
.outcome:last-child { grid-column: 1 / -1; }
.outcome.on { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); background: var(--muted); }
.outcome.on[data-v="signed_up"] { border-color: var(--olive); box-shadow: 0 0 0 1px var(--olive); background: var(--olive-soft); color: var(--olive); }
.outcome.on[data-v="not_interested"] { border-color: var(--bad); box-shadow: 0 0 0 1px var(--bad); background: var(--bad-soft); color: var(--bad); }

.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; }
.toggle input { width: 22px; height: 22px; accent-color: var(--ink); }

/* Business list */
.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  display: block; background: var(--surface); border: 1px solid var(--border);
  padding: 12px 14px; color: var(--text);
}
.item:hover { border-color: var(--input); }
.item:active { background: var(--muted); }

/* Home */
.home-hello { font-size: 20px; font-weight: 600; letter-spacing: -.02em; margin: 6px 0 14px; }
.home-choices { display: grid; gap: 10px; margin-bottom: 16px; }
.choice {
  display: flex; flex-direction: column; gap: 4px; padding: 20px 18px;
  background: var(--ink); border: 1px solid var(--ink); color: #fff;
}
.choice i { font-size: 30px; margin-bottom: 6px; }
.choice b { font-size: 22px; font-weight: 600; letter-spacing: -.02em; }
.choice span { font-size: 14px; opacity: .8; }
.choice:active { opacity: .85; }
.choice-green { background: var(--olive); border-color: var(--olive); }
.flow-hint { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-weight: 500; }
.detail-link { display: inline-flex; align-items: center; gap: 6px; margin: 0 0 10px; font-size: 14px; color: var(--text-muted); }
.task-note { margin: 8px 0 0; padding: 8px 10px; background: var(--muted); font-size: 14px; }
.task-done { opacity: .6; }
/* Home: weekly goals + leaderboard */
.week { margin-bottom: 12px; }
.goal { margin-top: 12px; }
.goal-top { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; margin-bottom: 6px; }
.goal-top b { font-size: 18px; letter-spacing: -.01em; }
.goal-bar { height: 8px; background: var(--muted); border: 1px solid var(--border); }
.goal-bar div { height: 100%; background: var(--ink); }
.goal-bar div.hit { background: var(--olive); }
.goal-none { font-size: 13px; }
.board { width: 100%; border-collapse: collapse; font-size: 14px; }
.board th { text-align: left; font-size: 12px; font-weight: 500; color: var(--text-muted); padding: 0 6px 6px; border-bottom: 1px solid var(--border); }
.board td { padding: 8px 6px; border-bottom: 1px solid var(--border); }
.board th:nth-child(n+3), .board td:nth-child(n+3) { text-align: right; }
.board .rank { width: 28px; text-align: center; }
.board tr.me td { background: var(--olive-soft); font-weight: 600; }

/* Lead score */
.lead { display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px; font-size: 12px; font-weight: 600; border: 1px solid var(--border); background: var(--muted); color: var(--text-muted); }
.lead i { font-size: 14px; }
.lead.hot { background: var(--olive-soft); border-color: #b9dfc9; color: var(--olive); }
.lead.warm { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn-text); }
.sort-chips { align-items: center; margin-bottom: 8px; }
.sort-chips .faint { font-size: 13px; margin-right: 2px; }
.reasons { list-style: none; margin: 0; padding: 0; }
.reasons li { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.reasons li:last-child { border-bottom: 0; }
.reasons li span { flex: 1; }
.reasons li i { font-size: 18px; color: var(--text-faint); }
.reasons li.up i, .reasons li.up b { color: var(--olive); }
.reasons li.down i, .reasons li.down b { color: var(--bad); }

/* Visit check-in proof */
.checkin-line { margin: 0 0 10px; }
.checkin { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; font-size: 13px; font-weight: 500; border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); }
.checkin i { font-size: 15px; }
.checkin.on_site { background: var(--olive-soft); border-color: #b9dfc9; color: var(--olive); }
.checkin.nearby { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn-text); }
.checkin.far { background: var(--bad-soft); border-color: var(--bad-line); color: var(--bad); }
.checkin.pending i { animation: spin 1s linear infinite; }
.visit .checkin, .card .checkin { margin-top: 6px; }
.flow-hint i { font-size: 20px; color: var(--olive); }
.item-top { display: flex; align-items: flex-start; gap: 8px; }
.item-name { flex: 1; font-weight: 600; font-size: 16px; letter-spacing: -.01em; }
.item-meta { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.item-dist { font-size: 13px; color: var(--text-muted); white-space: nowrap; }

.pill {
  display: inline-block; padding: 2px 8px; font-size: 12px; font-weight: 500; border: 1px solid var(--border);
  background: var(--muted); color: var(--text-muted); white-space: nowrap;
}
.pill.not_in { color: var(--text); }
.pill.not_interested, .pill.declined, .pill.overdue, .pill.voided { background: var(--bad-soft); border-color: var(--bad-line); color: var(--bad); }
.pill.interested, .pill.follow_up, .pill.onboarding { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn-text); }
.pill.agreement_sent, .pill.sent, .pill.delivered { background: var(--surface); border-color: var(--ink); color: var(--ink); }
.pill.signed_up, .pill.signed, .pill.completed { background: var(--olive-soft); border-color: #b9dfc9; color: var(--olive); }

/* Business screen */
.flags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.flag { display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; font-size: 12px; font-weight: 500; border: 1px solid var(--border); background: var(--muted); color: var(--text-muted); white-space: nowrap; }
.flag i { font-size: 14px; }
.flag.on { background: var(--olive-soft); border-color: #b9dfc9; color: var(--olive); }
.flag.none { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn-text); }
.contact { display: grid; grid-template-columns: 24px 1fr; gap: 8px 8px; margin: 12px 0 0; font-size: 15px; align-items: center; }
.contact dt { color: var(--text-muted); font-size: 18px; display: flex; }
.contact dd { margin: 0; word-break: break-word; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.contact a { text-decoration: underline; text-underline-offset: 2px; }
.biz-head h2 { margin: 0 0 4px; font-size: 22px; font-weight: 600; letter-spacing: -.02em; }
.biz-sub { color: var(--text-muted); font-size: 14px; }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0 4px; }
.quick a, .quick button {
  min-height: 64px; background: var(--muted); color: var(--ink); border: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 13px; font-weight: 500;
}
.quick i { font-size: 22px; }
.quick .disabled { color: var(--text-faint); pointer-events: none; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; font-size: 14px; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; word-break: break-word; }
.kv a { text-decoration: underline; text-underline-offset: 2px; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 10px 0; border-top: 1px solid var(--border); }
.timeline li:first-child { border-top: 0; padding-top: 0; }
.timeline .when { font-size: 12px; color: var(--text-muted); }
.timeline .remarks { margin-top: 4px; white-space: pre-wrap; }

.agreement { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-top: 1px solid var(--border); flex-wrap: wrap; }
.agreement:first-of-type { border-top: 0; }
.agreement .grow { flex: 1; min-width: 140px; font-size: 14px; }
.small-btn { min-height: 36px; padding: 0 12px; font-size: 14px; }

.empty { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty i { font-size: 44px; color: var(--text-faint); display: block; margin-bottom: 8px; }
.center { text-align: center; }
.spinner {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--border);
  border-top-color: var(--ink); animation: spin .8s linear infinite; margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
.notice { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn-text); }

/* Toasts */
.toasts { position: fixed; left: 12px; right: 12px; bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 50; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 12px 18px; font-size: 14px; max-width: 520px; }
.toast.error { background: var(--bad); }
.toast.success { background: var(--olive); }

/* Install sheet */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(17,17,16,.4); z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--surface); width: 100%; max-width: 640px; padding: 20px 20px calc(20px + env(safe-area-inset-bottom)); }
.sheet h3 { margin: 0 0 12px; font-weight: 600; }
.sheet p { margin: 0 0 10px; }
.sheet b.platform { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin-top: 14px; }

/* Already on Olivv */
.flag.olivv { background: #fff; border-color: #b9dfc9; color: var(--ink); }
.flag.olivv img { width: 13px; height: 13px; }
.olivv-note { display: flex; gap: 10px; align-items: flex-start; margin-top: 12px; padding: 10px 12px; border: 1px solid #b9dfc9; background: var(--olive-soft); }
.olivv-note img { width: 22px; height: 22px; flex: none; }
.olivv-note b { display: block; font-size: 14px; }
.olivv-note span { font-size: 13px; color: var(--text-muted); }

/* Bottom tab bar (Home · Clients · Customers) */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: center;
  background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1; max-width: 214px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  height: 58px; color: var(--text-muted); font-size: 12px; font-weight: 500; border-top: 2px solid transparent; margin-top: -1px;
}
.tabbar a i { font-size: 24px; }
.tabbar a.active { color: var(--olive); border-top-color: var(--olive); font-weight: 600; }
.tabbar a:active { background: var(--muted); }
body.has-tabs .screen { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
.appbar-title:empty { display: none; }

/* Home: work lists (need attention / follow-ups / reminders) */
.work h3 { display: flex; align-items: center; gap: 6px; }
.work h3 i { font-size: 16px; }
.work .count { min-width: 22px; padding: 1px 7px; text-align: center; font-size: 12px; font-weight: 600; background: var(--ink); color: #fff; }
.work:first-of-type .count { background: var(--bad); }
.work .list { margin-top: 10px; }
.work .item { padding: 12px; }
.work .item-name { font-size: 15px; }
.work-empty { display: flex; align-items: center; gap: 6px; margin: 10px 0 0; }
.work-empty i { font-size: 18px; color: var(--olive); }
.see-all { display: flex; align-items: center; justify-content: center; gap: 2px; margin-top: 10px; padding: 8px; font-size: 14px; font-weight: 500; color: var(--text-muted); }

/* Home tiles: Calendar + My Clients */
.home-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.tile { display: flex; flex-direction: column; gap: 2px; padding: 16px; background: var(--surface); border: 1px solid var(--border); }
.tile i { font-size: 26px; color: var(--olive); margin-bottom: 8px; }
.tile b { font-size: 17px; letter-spacing: -.01em; }
.tile span { font-size: 13px; color: var(--text-muted); }
.tile:active { background: var(--muted); }
/* Calendar */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow span { text-align: center; font-size: 12px; font-weight: 600; color: var(--text-faint); padding: 4px 0; }
.cal-day { position: relative; height: 42px; border: 1px solid transparent; background: none; font-size: 15px; color: var(--text); }
.cal-day.today { border-color: var(--border); font-weight: 700; }
.cal-day.sel { background: var(--ink); color: #fff; }
.cal-day i { position: absolute; left: 50%; bottom: 5px; width: 6px; height: 6px; margin-left: -3px; border-radius: 50%; background: var(--olive); }
.cal-day i.late { background: var(--bad); }
.cal-day.sel i { background: #fff; }

/* My Clients */
.chip b { margin-left: 4px; font-weight: 600; opacity: .7; }
.chip-alert:not(.on) { border-color: var(--bad-line); color: var(--bad); background: var(--bad-soft); }
.item-alert { border-left: 3px solid var(--bad); }
.item-flag { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 13px; font-weight: 500; color: var(--warn-text); }
.item-flag.bad { color: var(--bad); }

/* Visits picker */
.search-field { position: relative; flex: 1; }
.search-field > i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-faint); font-size: 18px; pointer-events: none; }
.search-field .input { padding-left: 38px; }
.filter-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 2px 0 10px; }
.btn-link { display: inline-flex; align-items: center; gap: 6px; padding: 6px 0; border: 0; background: none; font-size: 14px; font-weight: 600; color: var(--ink); cursor: pointer; }
.btn-link i { font-size: 18px; }
.badge-n { min-width: 18px; padding: 0 5px; text-align: center; font-size: 11px; font-weight: 700; background: var(--ink); color: #fff; }
.filters { padding: 4px 14px 14px; }
.filters .label:first-child { margin-top: 10px; }
.add-biz { display: flex; align-items: center; gap: 12px; margin: 16px 0 0; padding: 14px; border: 1px dashed var(--ink); background: var(--surface); color: var(--ink); }
.add-biz > i:first-child { font-size: 26px; color: var(--olive); }
.add-biz span { flex: 1; display: flex; flex-direction: column; }
.add-biz small { font-size: 13px; color: var(--text-muted); }
.add-biz:active { background: var(--muted); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.loc-box { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; padding: 12px; background: var(--muted); }
