:root {
  --bg: #f7f7f5;
  --card: #ffffff;
  --ink: #1a1a1a;
  --muted: #767672;
  --line: #e3e3df;
  --accent: #1a56db;
  --hot: #c2410c;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
}
main { max-width: 1100px; margin: 0 auto; padding: 1rem 1.5rem 4rem; }

.topnav {
  display: flex; gap: 1.25rem; align-items: center;
  padding: 0.75rem 1.5rem; background: var(--card);
  border-bottom: 1px solid var(--line);
}
.topnav a { color: var(--ink); text-decoration: none; }
.topnav a:hover { color: var(--accent); }
.topnav .brand { font-weight: 700; margin-right: 1rem; }

h1 { font-size: 1.5rem; } h2 { font-size: 1.1rem; margin-top: 1.75rem; }
a { color: var(--accent); }
.muted { color: var(--muted); }

.flash { max-width: 1100px; margin: 0.75rem auto 0; padding: 0.6rem 1rem; border-radius: 6px; }
.flash-success { background: #e7f4ea; border: 1px solid #b7dfc0; }
.flash-error { background: #fdecec; border: 1px solid #f2bcbc; }

.stat-row { display: flex; gap: 0.75rem; flex-wrap: wrap; margin: 0.75rem 0; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  padding: 0.6rem 1rem; text-decoration: none; color: var(--ink);
}
.stat-num { font-size: 1.3rem; font-weight: 700; margin-right: 0.3rem; }

table { width: 100%; border-collapse: collapse; background: var(--card);
        border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
th, td { text-align: left; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--line);
         vertical-align: top; }
th { background: var(--bg); font-size: 0.8rem; text-transform: uppercase;
     letter-spacing: 0.04em; color: var(--muted); }
tr:last-child td { border-bottom: 0; }

.score { font-weight: 700; color: var(--hot); }
.flag {
  display: inline-block; font-size: 0.72rem; background: #fff3e9;
  border: 1px solid #f5cfae; border-radius: 4px; padding: 0 0.35rem;
  margin: 0.1rem 0.15rem 0.1rem 0; white-space: nowrap;
}
.flag-franchise { background: #eef1ff; border-color: #c3cdf5; }
.flag-blocked { background: #fdf3d0; border-color: #ecd382; }

.badge {
  display: inline-block; font-size: 0.75rem; border-radius: 999px;
  padding: 0.1rem 0.6rem; background: #ececea; text-transform: uppercase;
  letter-spacing: 0.03em;
}
.status-new { background: #ececea; }
.status-contacted { background: #dbeafe; }
.status-replied { background: #fef3c7; }
.status-meeting { background: #ede9fe; }
.status-sold { background: #dcfce7; }
.status-lost { background: #fee2e2; }
.status-skip { background: #f3f4f6; color: var(--muted); }

.filters { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 1rem 0; }
.filters select, .filters input { padding: 0.4rem 0.5rem; border: 1px solid var(--line);
                                  border-radius: 6px; background: var(--card); }
.filters input[type="number"] { width: 7rem; }

button {
  background: var(--accent); color: #fff; border: 0; border-radius: 6px;
  padding: 0.45rem 1rem; cursor: pointer; font-size: 0.9rem;
}
button:hover { filter: brightness(1.1); }
a.btn { display: inline-flex; align-items: center; justify-content: center; background: var(--accent);
        color: #fff; border-radius: 6px; padding: 0.45rem 1rem; font-size: 0.9rem; text-decoration: none; }
a.btn:hover { filter: brightness(1.1); }
button:disabled { opacity: 0.5; cursor: not-allowed; filter: none; }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; }
@media (max-width: 800px) { .detail-grid { grid-template-columns: 1fr; } }

dl { display: grid; grid-template-columns: auto 1fr; gap: 0.35rem 1rem; }
dt { color: var(--muted); font-size: 0.85rem; }
dd { margin: 0; }

label { display: block; margin: 0.6rem 0; }
label select, label textarea, form input[type="text"] {
  display: block; width: 100%; margin-top: 0.25rem; padding: 0.45rem 0.5rem;
  border: 1px solid var(--line); border-radius: 6px; background: var(--card);
  font: inherit;
}
form select { padding: 0.45rem 0.5rem; border: 1px solid var(--line);
              border-radius: 6px; background: var(--card); font: inherit; }

.events { list-style: none; padding: 0; }
.events li { padding: 0.4rem 0; border-bottom: 1px solid var(--line); }

/* --- Targeting (radius map) --- */
.targeting-layout {
  display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  gap: 1.5rem; align-items: start; margin-top: 1rem;
}
@media (max-width: 900px) { .targeting-layout { grid-template-columns: 1fr; } }
#map { height: 480px; border: 1px solid var(--line); border-radius: 8px; background: #e9eef2; }
.zip-search { display: flex; gap: 0.5rem; align-items: center; margin: 0 0 0.75rem; flex-wrap: wrap; }
.zip-search input { width: 12rem; padding: 0.45rem 0.6rem; border: 1px solid var(--line);
                    border-radius: 6px; background: var(--card); font: inherit; }
.radius-row { display: flex; gap: 0.75rem; align-items: center; margin: 0.75rem 0; flex-wrap: wrap; }
.radius-row input[type="range"] { flex: 1; min-width: 160px; accent-color: var(--accent); }
.radius-row input[type="number"] { width: 4.5rem; padding: 0.35rem 0.4rem; border: 1px solid var(--line);
                                   border-radius: 6px; background: var(--card); font: inherit; }
.radius-tooltip { font-weight: 600; }

.side-card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 1rem 1.25rem; }
.side-card h2.first, dialog h2.first { margin-top: 0; }
.side-card input[type="text"] { display: block; width: 100%; margin-top: 0.25rem; padding: 0.45rem 0.5rem;
                                border: 1px solid var(--line); border-radius: 6px; font: inherit; }
.niche-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.1rem 0.75rem; margin: 0.5rem 0 0.75rem; }
.niche-grid label { display: flex; gap: 0.4rem; align-items: center; margin: 0.15rem 0; }
.inline-flash { margin: 0.75rem 0 0; }

.run-panel { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.btn-row { display: flex; gap: 0.75rem; align-items: center; margin-top: 0.5rem; }
.small { font-size: 0.8rem; }
button.secondary { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
button.small { padding: 0.25rem 0.6rem; font-size: 0.78rem; }
td.actions { white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; }
.status-pending { background: #fef3c7; }
.status-scraped { background: #dcfce7; }

dialog { border: 1px solid var(--line); border-radius: 10px; padding: 1.25rem 1.5rem; max-width: 460px;
         color: var(--ink); background: var(--card); }
dialog::backdrop { background: rgba(0, 0, 0, 0.35); }
dialog dl { margin: 0.5rem 0 1rem; }

/* --- Server-side scrape jobs --- */
.job-cell { min-width: 180px; max-width: 320px; }
.progress-bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden;
                margin: 0.2rem 0 0.3rem; }
.progress-bar span { display: block; height: 100%; background: var(--accent);
                     transition: width 0.4s ease; }
.text-error { color: #b42318; }
.local-run { margin-top: 1rem; }
.local-run summary { cursor: pointer; color: var(--accent); font-size: 0.85rem; }
.local-run pre { background: #1c1c1c; color: #ececec; padding: 0.75rem 0.9rem; border-radius: 6px;
                 font-size: 0.8rem; white-space: pre-wrap; word-break: break-all; margin: 0.5rem 0; }

/* --- Prospect selection + route planning --- */
.select-col { width: 2.2rem; text-align: center; }
.select-col input { width: 1.15rem; height: 1.15rem; cursor: pointer; }
tr.row-selected td { background: #eef3ff; }
tr.row-last-viewed td { background-color: #fde68a; }                 /* just-viewed: amber */
tr.row-last-viewed.row-fade td { background-color: transparent; transition: background-color 3s ease-out; }
.flag-nogeo { background: #f3f4f6; border-color: #d1d5db; color: var(--muted); }
.selection-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 900;
  display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap;
  padding: 0.75rem 1.5rem; background: var(--card); border-top: 1px solid var(--line);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
}
.selection-bar[hidden] { display: none; }
.selection-bar .grow { flex: 1; }
.selection-row { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; width: 100%; }
.selection-bar #planner-name { width: 11rem; padding: 0.5rem 0.6rem; border: 1px solid var(--line);
                               border-radius: 6px; font: inherit; }
.selection-bar #selection-status { width: 100%; }
.geo-help { width: 100%; display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap;
            background: #fff8e1; border: 1px solid #f5d98a; border-radius: 6px; padding: 0.5rem 0.75rem; }
.geo-help[hidden] { display: none; }
.flag-route { background: #e0f2fe; border-color: #a5d8f5; color: #075985; text-decoration: none; }
.start-marker { background: none; border: none; }
.start-marker span { display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 24px;
                     border-radius: 12px; background: #15803d; color: #fff; font-weight: 700; font-size: 0.75rem;
                     border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35); }
.tap { min-height: 44px; min-width: 44px; padding: 0.55rem 1rem; font-size: 1rem; }
.tap-link { display: inline-flex; align-items: center; min-height: 44px; padding: 0.2rem 0; font-size: 1.05rem; }
.table-scroll { overflow-x: auto; }

.route-header h1 { margin-bottom: 0.25rem; }
.route-stats { display: flex; gap: 1.25rem; flex-wrap: wrap; color: var(--muted); margin-bottom: 0.5rem; }
.route-stats strong { color: var(--ink); }
.route-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 440px);
                gap: 1.5rem; align-items: start; }
#route-map { height: 70vh; min-height: 320px; border: 1px solid var(--line); border-radius: 8px;
             background: #e9eef2; position: sticky; top: 1rem; }
.stop-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.75rem; }
.stop-card { background: var(--card); border: 1px solid var(--line); border-radius: 10px;
             padding: 0.9rem 1rem; display: grid; gap: 0.6rem; }
.stop-card.stop-last-viewed { background: #fde68a; }
.stop-card.stop-last-viewed.row-fade { background: var(--card); transition: background 3s ease-out; }
.stop-card.stop-visited { opacity: 0.6; background: #f4fbf5; }
.stop-card.stop-skipped { opacity: 0.55; background: #f5f5f4; }
.stop-head { display: flex; gap: 0.75rem; align-items: flex-start; }
.stop-title { flex: 1; min-width: 0; }
.stop-title a { font-weight: 600; font-size: 1.05rem; }
.stop-num, .num-marker span {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: #fff;
  font-weight: 700; font-size: 0.95rem; flex-shrink: 0;
}
.stop-state { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.stop-body .tap-link { font-weight: 600; }
.stop-leg { margin-top: 0.15rem; }
.stop-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.stop-actions .btn { display: inline-flex; align-items: center; justify-content: center;
                     background: var(--accent); color: #fff; border-radius: 6px; text-decoration: none; }
.stop-outcome select.tap, .stop-note textarea.tap { width: 100%; font: inherit; border: 1px solid var(--line);
                                                    border-radius: 6px; padding: 0.55rem; background: var(--card); }
.stop-note { margin: 0; }
.num-marker { background: none; border: none; }
.num-marker span { border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35); }
.num-marker-visited span { background: #15803d; }
.num-marker-skipped span { background: #9ca3af; }
.leaflet-popup-content { font: inherit; }

@media (max-width: 800px) {
  .topnav { flex-wrap: wrap; gap: 0.5rem 1rem; padding: 0.6rem 1rem; }
  .route-layout { grid-template-columns: 1fr; }
  #route-map { height: 45vh; position: static; }
  .stop-actions .tap { flex: 1 1 auto; }
  .selection-bar { padding: 0.75rem 1rem; }
  main { padding: 1rem 0.75rem 6rem; }
  h1 { font-size: 1.3rem; }
}


/* --- Agreements (prospect page) --- */
.agreements { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: 0.6rem; }
.agreement { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 0.75rem 0.9rem; }
.agreement-signed { background: #f4fbf5; }
.agreement-head { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.agreement-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.5rem; align-items: center; }
.agreement-actions form.inline { display: contents; }
.btn.small-btn, button.small-btn { min-height: 40px; padding: 0.4rem 0.8rem; font-size: 0.9rem; }
.agreement-form { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 0.9rem 1rem; }
.service-picks { display: grid; gap: 0.4rem; margin: 0.5rem 0 0.75rem; }
.service-pick { display: flex; align-items: center; gap: 0.75rem; margin: 0; padding: 0.55rem 0.7rem;
                border: 1px solid var(--line); border-radius: 8px; min-height: 52px; cursor: pointer; }
.service-pick input[type="checkbox"] { width: 1.35rem; height: 1.35rem; flex-shrink: 0; }
.service-pick .service-name { flex: 1; font-weight: 600; font-size: 1.05rem; }
.service-pick .service-price { display: inline-flex; align-items: center; gap: 0.2rem; color: var(--muted); }
.service-pick .service-price input { width: 4.5rem; padding: 0.45rem 0.4rem; border: 1px solid var(--line);
                                      border-radius: 6px; font: inherit; text-align: right; color: var(--ink); }
.bundle-pick .service-name { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; }
.bundle-select { padding: 0.4rem 0.5rem; border: 1px solid var(--line); border-radius: 6px; font: inherit; font-weight: 600;
                 background: #fff; color: var(--ink); min-height: 40px; }
.bundle-contents { margin: -0.15rem 0 0.2rem; padding: 0.55rem 0.75rem; border: 1px dashed var(--line); border-radius: 8px;
                   background: #fafaf7; color: var(--ink); }
.bundle-contents .bundle-group { margin-top: 0.3rem; color: var(--muted); }
.bundle-contents .bundle-group em { font-style: normal; font-weight: 600; color: var(--ink); }
.custom-details { margin: -0.15rem 0 0.2rem; padding: 0.55rem 0.75rem; border: 1px dashed var(--line); border-radius: 8px; background: #fafaf7; }
.custom-details textarea { display: block; width: 100%; margin-top: 0.3rem; padding: 0.55rem 0.6rem; border: 1px solid var(--line);
                           border-radius: 6px; font: inherit; }
.sign-fee { white-space: nowrap; }
.contact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.contact-grid label { margin: 0.4rem 0; }
.contact-grid input { display: block; width: 100%; margin-top: 0.25rem; padding: 0.55rem 0.6rem;
                      border: 1px solid var(--line); border-radius: 6px; font: inherit; }
.btn-row.wrap { flex-wrap: wrap; }
.inline-name { display: inline-flex; gap: 0.4rem; align-items: center; }
.inline-name input { width: 9rem; padding: 0.35rem 0.5rem; border: 1px solid var(--line); border-radius: 6px; font: inherit; }
@media (max-width: 600px) { .contact-grid { grid-template-columns: 1fr; } }

/* --- Public signing page --- */
.sign-body { background: var(--bg); }
.sign-wrap { max-width: 680px; margin: 0 auto; padding: 1rem 1rem 4rem; }
.sign-header { margin: 0.5rem 0 1rem; }
.sign-logo { display: block; height: 48px; width: auto; max-width: 100%; }
.sign-header h1 { margin: 0.5rem 0 0; font-size: 1.6rem; }
.sign-card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.1rem; margin-bottom: 0.9rem; }
.sign-card h2 { margin: 0 0 0.6rem; font-size: 1.05rem; }
.sign-services { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.6rem; }
.sign-service-row { display: flex; justify-content: space-between; gap: 1rem; font-size: 1.05rem; }
.sign-total { border-top: 1px solid var(--line); padding-top: 0.6rem; }
.sign-bundle { margin-top: 0.5rem; padding: 0.6rem 0.75rem; border: 1px solid var(--line); border-radius: 8px; background: #fafaf7; }
.sign-bundle p { margin: 0; }
.sign-bundle-title { margin-top: 0.5rem !important; font-weight: 600; color: var(--muted); }
.sign-bundle-items { list-style: none; margin: 0.2rem 0 0; padding: 0; display: grid; gap: 0.15rem; font-size: 0.95rem; }
.sign-bundle-items li { padding-left: 1.4rem; position: relative; }
.sign-bundle-items li::before { content: "\2713"; position: absolute; left: 0.1rem; color: #15803d; font-weight: 700; }
.sign-terms { padding-left: 1.2rem; margin: 0; display: grid; gap: 0.5rem; font-size: 0.95rem; }
.sign-card input[type="text"] { display: block; width: 100%; margin-top: 0.3rem; padding: 0.7rem 0.75rem;
                                border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 1.1rem; }
.sign-consent { display: flex; gap: 0.7rem; align-items: flex-start; margin: 1rem 0; }
.sign-consent input { width: 1.4rem; height: 1.4rem; flex-shrink: 0; margin-top: 0.15rem; }
.sign-btn { width: 100%; font-size: 1.1rem; min-height: 52px; }
.sign-signature { font-family: "Snell Roundhand", "Brush Script MT", cursive; font-size: 2rem; margin: 0.25rem 0; }
.sign-card .btn { display: inline-flex; align-items: center; justify-content: center; background: var(--accent);
                  color: #fff; border-radius: 8px; text-decoration: none; }

.agreement-billing { margin-top: 0.4rem; }
.sign-card-fields { margin: 1rem 0; }
.sign-card-fields label { font-weight: 600; margin: 0 0 0.2rem; }
#card-element { margin: 0.5rem 0; }

/* Add-ons: addenda nested under their agreement, plus the Add service form. */
.addenda { list-style: none; padding: 0; margin: 0.6rem 0 0 0.6rem; border-left: 3px solid var(--line); display: grid; gap: 0.5rem; }
.addendum { padding: 0.35rem 0 0.35rem 0.75rem; }
.addendum.agreement-signed { background: transparent; }
details.addon { margin-top: 0.6rem; }
details.addon > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; font-weight: 600; }
details.addon > summary::-webkit-details-marker { display: none; }
details.addon[open] > summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.addon-form { padding: 0.75rem 0.9rem; border: 1px dashed var(--line); border-radius: 0 8px 8px 8px; }

/* Pending agreements: swipe left (touch) to reveal Void; a plain button on wide screens. */
.swipeable { position: relative; overflow: hidden; padding: 0; }
.swipeable > .swipe-content { position: relative; z-index: 1; padding: 0.75rem 0.9rem; background: var(--card);
  border-radius: 8px; transition: transform 0.18s ease; touch-action: pan-y; }
.addendum.swipeable > .swipe-content { padding: 0.35rem 0 0.35rem 0.75rem; background: #f4fbf5; border-radius: 0; }
.swipe-void { position: absolute; top: 0; right: 0; bottom: 0; width: 96px; margin: 0; display: flex; }
.swipe-void button { width: 100%; height: 100%; min-height: 0; border-radius: 0 8px 8px 0; background: #b42318; color: #fff;
  font-weight: 700; font-size: 1rem; }
.agreement-actions form.void-inline { display: none; }
button.danger { color: #b42318; border-color: #f2bcbc; }
@media (min-width: 700px) {
  .swipe-void { display: none; }
  .agreement-actions form.void-inline { display: contents; }
}

/* Competition snapshot reports. */
.report-box { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 0.9rem 1rem; margin-bottom: 1rem; }
.report-form { display: flex; gap: 0.75rem; align-items: flex-end; flex-wrap: wrap; }
.report-form label { margin: 0; flex: 1 1 200px; }
.report-form input { display: block; width: 100%; margin-top: 0.25rem; padding: 0.55rem 0.6rem; border: 1px solid var(--line); border-radius: 6px; font-size: 1rem; }
.report-list { list-style: none; padding: 0; margin: 0.6rem 0 0; display: grid; gap: 0.4rem; }
.report-item { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; padding: 0.45rem 0; border-top: 1px solid var(--line); }
.stop-report { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; margin-top: 0.5rem; }

/* --- accounts ------------------------------------------------------------ */
.topnav .nav-user { margin-left: auto; display: inline-flex; align-items: center; gap: 0.6rem; white-space: nowrap; }
.topnav .linklike { background: none; border: 0; padding: 0; font: inherit; color: inherit; text-decoration: underline; cursor: pointer; }
.login-wrap { max-width: 26rem; margin: 3rem auto; padding: 0 1rem; }
.login-wrap h1 { margin: 0.5rem 0 1rem; }
.login-card { display: grid; gap: 0.75rem; padding: 1.1rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.login-card label { display: grid; gap: 0.25rem; font-weight: 600; }
.login-card input { padding: 0.7rem 0.75rem; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 1.05rem; }
.login-btn { width: 100%; min-height: 52px; font-size: 1.05rem; }
.team-form input[type="password"] { width: 9rem; padding: 0.4rem 0.5rem; border: 1px solid var(--line); border-radius: 6px; font: inherit; }
.team-add { margin-top: 0.5rem; }
.team-add .contact-grid { grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); }
.team-add select { width: 100%; margin-top: 0.25rem; padding: 0.55rem 0.6rem; border: 1px solid var(--line); border-radius: 6px; font: inherit; }
