:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-2: rgba(245, 245, 247, 0.88);
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: rgba(0, 0, 0, 0.10);
  --teal: #0071e3;
  --teal-2: #0066cc;
  --blue: #007aff;
  --amber: #ff9f0a;
  --rose: #ff3b30;
  --shadow: 0 16px 42px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.button {
  border: 0;
  border-radius: 8px;
  min-height: 40px;
  padding: 0 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition:
    transform 0.16s ease,
    background 0.16s ease,
    border-color 0.16s ease;
}

button:active,
.button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.primary {
  background: var(--teal);
  color: #fff;
}

.primary:hover {
  background: var(--teal-2);
}

.secondary {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
}

.secondary:hover {
  border-color: var(--teal);
}

.full {
  width: 100%;
}

.icon-button {
  width: 40px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

.app-shell {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--teal);
  color: #fff;
  font-weight: 900;
}

.brand span,
.sidebar-footer {
  color: #86868b;
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav button,
.mobile-nav button {
  background: transparent;
  color: inherit;
  justify-content: flex-start;
}

.language-switcher {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.language-switcher button {
  min-height: 38px;
  padding: 0 8px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
}

.language-switcher button.active {
  background: rgba(0, 113, 227, 0.12);
  border-color: rgba(0, 113, 227, 0.24);
  color: var(--teal);
}

.nav button.active {
  background: rgba(255, 255, 255, 0.12);
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 10px;
}

.sidebar-account-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  line-height: 1.4;
}

.sidebar-language-switcher {
  width: 100%;
}

.main {
  padding: 28px;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 24px;
}

.topbar h1 {
  margin: 4px 0 0;
  font-size: clamp(28px, 3.2vw, 42px);
  line-height: 1.05;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0;
  color: var(--teal);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 12px;
}

.topbar-actions,
.inline-controls,
.button-row,
.route-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  min-height: 40px;
  padding: 9px 11px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  outline: 3px solid rgba(0, 113, 227, 0.18);
  outline-offset: 2px;
  box-shadow: none;
}

input:disabled,
select:disabled,
textarea:disabled {
  background: #f2f5f3;
  color: var(--muted);
  cursor: not-allowed;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(120deg, rgba(0, 113, 227, 0.08), rgba(255, 159, 10, 0.06)),
    var(--bg);
}

.auth-card {
  width: min(100%, 420px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 26px;
  display: grid;
  gap: 16px;
}

.auth-card h1,
.auth-card p {
  margin: 0;
}

.auth-card p,
.auth-card small {
  color: var(--muted);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.kpi,
.lead-card,
.candidate-card,
.rep-card,
.team-card,
.visit-card,
.activity-item,
.city-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.kpi {
  padding: 18px;
  min-height: 132px;
  display: grid;
  align-content: space-between;
  box-shadow: var(--shadow);
}

.kpi span,
.kpi small,
.lead-card p,
.candidate-card p,
.visit-card p,
.route-list small,
.team-card span,
.rep-card span,
.activity-item span,
.activity-item small {
  color: var(--muted);
}

.kpi strong {
  font-size: 30px;
  letter-spacing: 0;
}

.dashboard-grid,
.workspace {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.dashboard-grid {
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.85fr);
}

.clock-location-board {
  display: grid;
  gap: 18px;
}

.clock-location-list {
  display: grid;
  gap: 18px;
}

.clock-location-card {
  display: grid;
  gap: 22px;
  min-height: 164px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.clock-location-card strong {
  color: var(--text);
  font-size: 24px;
  line-height: 1.2;
}

.clock-location-card a {
  color: var(--teal);
  font-size: 26px;
  font-weight: 800;
  line-height: 1.18;
  text-decoration: none;
}

.clock-location-card time {
  color: var(--muted);
  font-size: 20px;
  line-height: 1.25;
}

.filter-panel-head {
  display: grid;
  grid-template-columns: minmax(160px, auto) minmax(0, 1fr);
  align-items: center;
  gap: 18px;
}

.filter-row {
  display: grid;
  align-items: end;
  gap: 12px;
  width: 100%;
}

.lead-filter-row {
  grid-template-columns: minmax(260px, 1fr) minmax(150px, 190px) max-content max-content;
}

.filter-row > input,
.filter-row > select,
.filter-row > button {
  width: 100%;
}

.filter-row > button {
  white-space: nowrap;
}

.two-col {
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
}

.route-workspace {
  grid-template-columns: minmax(384px, 420px) minmax(0, 1fr);
  align-items: start;
  gap: 18px;
}

.team-workspace {
  grid-template-columns: 1fr;
}

.tool-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.wide {
  grid-column: 1 / -1;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-head h2 {
  margin: 0;
  font-size: 18px;
}

.funnel {
  display: grid;
  gap: 12px;
}

.funnel-row {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr) 30px;
  gap: 10px;
  align-items: center;
}

.bar {
  height: 10px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--amber));
}

.city-list,
.activity-list,
.lead-list,
.collector-list,
.visit-list,
.rep-grid,
.route-lead-picker {
  display: grid;
  gap: 12px;
}

.city-item,
.activity-item {
  padding: 12px;
  display: grid;
  gap: 4px;
}

.rep-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.rep-card,
.team-card {
  padding: 16px;
  display: grid;
  gap: 10px;
}

.rep-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
}

.metric-line,
.lead-meta,
.route-stats,
.metric-grid {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.metric-line small {
  color: var(--muted);
}

.lead-card,
.candidate-card,
.visit-card {
  padding: 16px;
}

.lead-main,
.candidate-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
}

.lead-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.lead-heading {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.lead-index {
  flex: 0 0 auto;
  min-width: 34px;
  height: 32px;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  background: rgba(0, 113, 227, 0.10);
  color: #0057a8;
  font-size: 13px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.lead-title-row h3 {
  margin: 0;
  font-size: 17px;
}

.score {
  min-width: 42px;
  height: 32px;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  background: #fff7ed;
  color: var(--amber);
  font-weight: 900;
}

.tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.tags span,
.mode-pill,
.status {
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status.arrived {
  background: #dbeafe;
  color: var(--blue);
}

.status.done {
  background: #dcfce7;
  color: var(--teal);
}

.lead-controls {
  width: 168px;
  display: grid;
  gap: 8px;
}

.lead-detail-toggle {
  width: 100%;
  min-height: 44px;
  margin-top: 12px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-color: rgba(0, 113, 227, 0.18);
  background: rgba(0, 113, 227, 0.055);
  color: #0057a8;
  text-align: left;
}

.lead-detail-toggle span {
  flex: 0 0 auto;
  font-weight: 900;
}

.lead-detail-toggle small {
  min-width: 0;
  flex: 1 1 auto;
  color: #476a8f;
  font-size: 12px;
  font-weight: 800;
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lead-detail-toggle::after {
  content: "";
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.16s ease;
}

.lead-detail-toggle[aria-expanded="true"]::after {
  transform: rotate(225deg);
}

.lead-meta {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.lead-meta a,
.activity-item a,
.timeline-item a,
.arrival-proof a {
  color: var(--teal);
  font-weight: 800;
  text-decoration: none;
}

.lead-workflow {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.lead-workflow-summary,
.lead-visit-summary,
.lead-visit-actions {
  display: flex;
  align-items: center;
}

.lead-workflow-summary {
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  cursor: pointer;
  color: #0057a8;
  font-weight: 900;
}

.lead-workflow[open] .lead-workflow-summary {
  margin-bottom: 2px;
}

.lead-workflow-summary > span:last-child,
.lead-tabs button span {
  min-width: 28px;
  height: 24px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  background: rgba(0, 113, 227, 0.1);
  color: #0057a8;
  font-size: 12px;
  font-weight: 900;
}

.lead-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.lead-workflow-tabs {
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.lead-tabs button {
  min-height: 38px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}

.lead-workflow-tabs button {
  flex: 0 0 auto;
  white-space: nowrap;
}

.lead-tabs button.active {
  background: rgba(0, 113, 227, 0.12);
  border-color: rgba(0, 113, 227, 0.26);
  color: #0057a8;
}

.lead-workflow-content {
  min-width: 0;
}

.lead-visit-list {
  display: grid;
  gap: 8px;
}

.lead-visit-row {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  background: rgba(248, 250, 252, 0.78);
}

.lead-visit-summary {
  gap: 10px;
  justify-content: space-between;
}

.lead-visit-summary > .status {
  flex: 0 0 auto;
}

.lead-visit-summary > div:not(.lead-visit-actions) {
  min-width: 0;
  flex: 1 1 auto;
}

.lead-visit-row small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.lead-visit-actions {
  flex: 0 0 auto;
  gap: 8px;
}

.lead-visit-evidence {
  margin: 0;
  padding-top: 8px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.arrival-evidence-links {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  min-width: 0;
}

.arrival-record-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.team-action-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.timeline-list {
  display: grid;
  gap: 10px;
}

.timeline-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(210px, auto);
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.64);
}

.timeline-item > div,
.timeline-location {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.timeline-item span,
.timeline-item time {
  color: var(--muted);
}

.timeline-location {
  justify-items: end;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

form.tool-panel,
.sticky-form {
  align-content: start;
  display: grid;
  gap: 14px;
}

.side-stack {
  display: grid;
  gap: 16px;
  align-content: start;
}

.sticky-form {
  position: sticky;
  top: 24px;
}

.input-with-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.file-button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.file-button input {
  display: none;
}

.lead-details {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.lead-details[hidden] {
  display: none;
}

.lead-detail-tags {
  margin-top: 0;
}

.lead-details .lead-meta,
.lead-details .lead-workflow {
  margin-top: 0;
}

.lead-details summary {
  cursor: pointer;
  font-weight: 900;
  color: var(--teal);
}

.followup-editor,
.followup-history,
.modal-form,
.visit-records {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.visit-records {
  margin-top: 0;
}

.visit-records summary {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  color: #0057a8;
  font-weight: 850;
}

.visit-records summary > span:last-child {
  min-width: 24px;
  height: 24px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  background: rgba(0, 113, 227, 0.1);
  color: #0057a8;
  font-size: 12px;
}

.visit-record-list {
  display: grid;
  gap: 8px;
}

.mini-record {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  display: grid;
  gap: 4px;
  background: #fbfdfc;
}

.mini-record span,
.mini-record small,
.mini-record a {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.mini-record a {
  color: var(--teal);
  font-weight: 800;
  text-decoration: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(245, 245, 247, 0.68);
}

.modal-card {
  width: min(100%, 760px);
  max-height: min(92vh, 820px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.map-modal {
  width: min(100%, 1040px);
}

.map-mode-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.map-picker-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 16px;
  align-items: start;
}

.map-picker-map {
  position: relative;
  min-height: 460px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-2);
}

.map-picker-map iframe,
.map-draw-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.map-picker-map iframe {
  border: 0;
  pointer-events: none;
}

.map-draw-layer {
  cursor: crosshair;
  background: rgba(0, 113, 227, 0.025);
}

.map-hint {
  position: absolute;
  left: 12px;
  top: 12px;
  max-width: calc(100% - 24px);
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(29, 29, 31, 0.78);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.center-pin {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--rose);
  border: 3px solid #fff;
  transform: translate(-50%, -50%);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
}

.radius-ring {
  position: absolute;
  left: 24%;
  top: 18%;
  width: 52%;
  height: 64%;
  border: 2px dashed rgba(0, 113, 227, 0.82);
  border-radius: 999px;
  background: rgba(0, 113, 227, 0.08);
}

.selection-rect {
  position: absolute;
  border: 2px solid var(--teal);
  background: rgba(0, 113, 227, 0.14);
  box-shadow: 0 0 0 9999px rgba(29, 29, 31, 0.08);
}

.map-picker-side,
.selection-summary {
  display: grid;
  gap: 12px;
}

.selection-summary {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.selection-summary span {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.candidate-actions {
  display: grid;
  justify-items: end;
  gap: 10px;
  min-width: 160px;
}

.route-controls {
  align-self: start;
  display: grid;
  gap: 12px;
  padding: 20px;
}

.route-controls .panel-head {
  margin-bottom: 2px;
}

.route-controls .panel-head h2 {
  font-size: 19px;
}

.route-selected-count {
  flex: 0 0 auto;
  border-radius: 999px;
  background: rgba(0, 113, 227, 0.10);
  color: #0057a8;
  padding: 5px 10px;
  font-size: 13px;
  font-weight: 850;
}

.route-controls label {
  gap: 5px;
  font-size: 12px;
  line-height: 1.2;
}

.route-controls input,
.route-controls select {
  min-height: 36px;
  padding: 7px 10px;
  font-size: 14px;
  font-weight: 650;
}

.route-compact-grid {
  gap: 10px;
  box-shadow: none;
  padding: 0;
}

.route-coordinate-grid input {
  font-variant-numeric: tabular-nums;
}

.route-action-row {
  display: grid;
  grid-template-columns: auto auto;
  justify-content: start;
  gap: 8px;
}

.route-action-row button {
  min-height: 36px;
  padding: 0 12px;
  font-size: 14px;
  font-weight: 750;
}

.route-action-row .primary {
  min-width: 92px;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.12);
}

.route-lead-picker {
  max-height: min(460px, calc(100vh - 420px));
  overflow: auto;
  gap: 8px;
  padding-right: 6px;
  scrollbar-width: thin;
}

.route-check {
  position: relative;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  cursor: pointer;
  min-height: 66px;
  transition:
    border-color 0.16s ease,
    background 0.16s ease,
    box-shadow 0.16s ease;
}

.route-check input {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 1px;
  margin: 0;
  opacity: 0;
}

.route-check-mark {
  width: 22px;
  height: 22px;
  margin-top: 2px;
  border: 1.5px solid rgba(0, 0, 0, 0.24);
  border-radius: 6px;
  background: #fff;
  display: grid;
  place-items: center;
  transition:
    background 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease;
}

.route-check-mark::after {
  content: "";
  width: 10px;
  height: 6px;
  border-left: 2.5px solid #fff;
  border-bottom: 2.5px solid #fff;
  opacity: 0;
  transform: translateY(-1px) rotate(-45deg);
}

.route-check input:checked + .route-check-mark {
  border-color: #0071e3;
  background: #0071e3;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.14);
}

.route-check input:checked + .route-check-mark::after {
  opacity: 1;
}

.route-check:has(input:checked) {
  border-color: rgba(0, 113, 227, 0.24);
  background: rgba(0, 113, 227, 0.055);
}

.route-check:focus-within {
  border-color: rgba(0, 113, 227, 0.54);
  outline: 3px solid rgba(0, 113, 227, 0.18);
  outline-offset: 2px;
  box-shadow: none;
}

.route-check-content {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.route-check-content strong {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.route-check small {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.route-check small span:not(:last-child)::after {
  content: "·";
  margin-left: 5px;
  color: rgba(110, 110, 115, 0.74);
}

.map-empty,
.mini-map {
  min-height: 320px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #fbfbfd;
  background-size: auto;
  border: 1px solid var(--line);
  color: var(--muted);
}

.mini-map {
  position: relative;
  margin: 14px 0;
  overflow: hidden;
}

.mini-map::before {
  content: "";
  position: absolute;
  inset: 22% 10% 24% 12%;
  border-top: 4px solid rgba(0, 113, 227, 0.30);
  transform: rotate(-8deg);
}

.mini-map i {
  position: absolute;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--teal);
  color: #fff;
  font-style: normal;
  font-size: 12px;
  font-weight: 900;
  transform: translate(-50%, -50%);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.16);
}

.mini-map i.start {
  background: var(--amber);
}

.route-stats {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}

.route-list {
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
  list-style: none;
}

.route-list li {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.route-list li > span,
.visit-order {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #e0f2fe;
  color: var(--blue);
  font-weight: 900;
}

.phone-shell {
  max-width: 440px;
  width: 100%;
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.78);
  color: var(--text);
  border-radius: 28px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.phone-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 8px 16px;
}

.phone-top span {
  display: block;
  color: #86868b;
  font-size: 12px;
}

.phone-top select {
  max-width: 160px;
}

.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.quick-actions button {
  background: rgba(0, 113, 227, 0.10);
  color: #0066cc;
}

.visit-list {
  max-height: 640px;
  overflow: auto;
}

.visit-card {
  color: var(--text);
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
}

.arrival-proof {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin: 12px 0;
}

.arrival-proof span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.team-card-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.team-card-person {
  flex: 1 1 auto;
}

.team-card-person > div:last-child {
  min-width: 0;
}

.team-card-person strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}

.metric-grid span {
  display: grid;
  gap: 3px;
  font-size: 12px;
}

.metric-grid b {
  color: var(--text);
  font-size: 20px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  background: rgba(29, 29, 31, 0.90);
  color: #fff;
  padding: 12px 16px;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.toast.warn {
  background: var(--amber);
}

.empty {
  color: var(--muted);
  margin: 0;
}

.mobile-nav {
  display: none;
}

.mobile-nav-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .main {
    padding: 18px 16px 104px;
  }

  .kpi-grid,
  .dashboard-grid,
  .two-col,
  .route-workspace,
  .team-workspace,
  .map-picker-layout,
  .rep-grid {
    grid-template-columns: 1fr;
  }

  .map-picker-map {
    min-height: 360px;
  }

  .mobile-nav {
    display: grid;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 12;
    grid-template-columns: 1fr;
    gap: 6px;
    background: rgba(255, 255, 255, 0.76);
    color: #424245;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 18px 18px 0 0;
    padding: 8px 10px max(10px, env(safe-area-inset-bottom));
    box-shadow: var(--shadow);
  }

  .mobile-nav button {
    justify-content: center;
    min-height: 44px;
    padding: 0 4px;
    font-size: 12px;
  }

  .mobile-nav button.active {
    background: rgba(255, 255, 255, 0.14);
  }

  .mobile-language-switcher {
    width: min(184px, 100%);
  }
}

@media (max-width: 720px) {
  .topbar,
  .panel-head,
  .lead-main,
  .candidate-card {
    display: grid;
    grid-template-columns: 1fr;
  }

  .topbar-actions,
  .inline-controls {
    width: 100%;
  }

  .main {
    padding: 16px 12px 138px;
  }

  .mobile-nav {
    grid-template-columns: 1fr;
  }

  .mobile-nav-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .mobile-nav button {
    min-height: 38px;
    padding: 0 2px;
  }

  .topbar-actions label,
  .inline-controls input,
  .inline-controls select,
  .lead-controls,
  .candidate-actions {
    width: 100%;
  }

  .form-grid,
  .quick-actions,
  .metric-grid,
  .input-with-button {
    grid-template-columns: 1fr;
  }

  .kpi {
    min-height: 110px;
  }

  .funnel-row {
    grid-template-columns: 92px minmax(0, 1fr) 24px;
  }

  .phone-shell {
    border-radius: 18px;
  }
}

/* Apple-style visual refresh */
:root {
  --bg: #f5f5f7;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-2: rgba(245, 245, 247, 0.88);
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: rgba(0, 0, 0, 0.10);
  --teal: #0071e3;
  --teal-2: #005bb5;
  --blue: #007aff;
  --amber: #ff9f0a;
  --rose: #ff3b30;
  --shadow: 0 16px 42px rgba(0, 0, 0, 0.08);
  --soft-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 12px 30px rgba(0, 0, 0, 0.05);
}

body {
  background: #f5f5f7;
  font-family:
    -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", Inter,
    "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

button,
.button,
.file-button {
  min-height: 38px;
  border-radius: 8px;
  font-weight: 650;
  letter-spacing: 0;
  box-shadow: none;
}

button:hover,
.button:hover,
.file-button:hover {
  transform: translateY(-1px);
}

button:active,
.button:active,
.file-button:active {
  transform: translateY(0);
}

.primary {
  background: #0071e3;
  color: #fff;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

.primary:hover {
  background: #0066cc;
}

.secondary,
.file-button,
.button.secondary {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(0, 0, 0, 0.10);
  color: #1d1d1f;
}

.secondary:hover,
.file-button:hover {
  border-color: rgba(0, 113, 227, 0.35);
  background: rgba(255, 255, 255, 0.95);
}

.app-shell {
  background: #f5f5f7;
}

.sidebar {
  background: rgba(255, 255, 255, 0.74);
  color: #1d1d1f;
  border-right: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: inset -1px 0 rgba(255, 255, 255, 0.52);
  backdrop-filter: blur(22px) saturate(180%);
}

.brand-mark {
  background: #0071e3;
  color: #fff;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.14);
}

.brand span,
.sidebar-footer {
  color: #86868b;
}

.nav {
  gap: 6px;
}

.nav button,
.mobile-nav button {
  border-radius: 8px;
  color: #424245;
  font-weight: 650;
}

.nav button:hover {
  background: rgba(0, 0, 0, 0.04);
}

.nav button.active {
  background: rgba(0, 113, 227, 0.12);
  color: #0066cc;
}

.main {
  padding: 30px;
}

.topbar {
  align-items: center;
  padding: 2px 0 6px;
}

.topbar h1 {
  color: #1d1d1f;
  font-size: clamp(30px, 3vw, 44px);
  font-weight: 760;
}

.eyebrow {
  color: #86868b;
  font-weight: 700;
  text-transform: none;
}

label {
  color: #6e6e73;
  font-size: 12px;
  font-weight: 650;
}

input,
select,
textarea {
  min-height: 38px;
  border-color: rgba(0, 0, 0, 0.10);
  background: rgba(255, 255, 255, 0.86);
  color: #1d1d1f;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.70);
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(0, 113, 227, 0.55);
  outline: 3px solid rgba(0, 113, 227, 0.18);
  outline-offset: 2px;
  box-shadow: none;
}

input:disabled,
select:disabled,
textarea:disabled {
  background: rgba(235, 235, 240, 0.72);
  color: #86868b;
}

.auth-screen {
  background: #f5f5f7;
}

.auth-card,
.tool-panel,
.modal-card,
.kpi,
.lead-card,
.candidate-card,
.rep-card,
.team-card,
.visit-card,
.activity-item,
.city-item,
.mini-record,
.route-check,
.route-list li {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(18px) saturate(160%);
}

.tool-panel,
.auth-card,
.modal-card {
  padding: 20px;
}

.panel-head h2 {
  color: #1d1d1f;
  font-size: 19px;
  font-weight: 740;
}

.kpi {
  min-height: 126px;
}

.kpi strong {
  color: #1d1d1f;
  font-size: 32px;
  font-weight: 760;
}

.kpi span,
.kpi small,
.lead-card p,
.candidate-card p,
.visit-card p,
.route-list small,
.team-card span,
.rep-card span,
.activity-item span,
.activity-item small {
  color: #6e6e73;
}

.bar {
  background: rgba(0, 0, 0, 0.06);
}

.bar i {
  background: #0071e3;
}

.score {
  background: rgba(255, 149, 0, 0.12);
  color: #bf6a00;
}

.tags span,
.mode-pill,
.status {
  background: rgba(0, 0, 0, 0.055);
  color: #6e6e73;
  font-weight: 700;
}

.status.arrived {
  background: rgba(0, 122, 255, 0.12);
  color: #0066cc;
}

.status.done {
  background: rgba(52, 199, 89, 0.14);
  color: #248a3d;
}

.lead-meta {
  border-top-color: rgba(0, 0, 0, 0.08);
}

.lead-meta a,
.activity-item a,
.arrival-proof a,
.timeline-item a,
.mini-record a,
.lead-details summary {
  color: #0066cc;
}

.modal-backdrop {
  background: rgba(245, 245, 247, 0.68);
  backdrop-filter: blur(16px) saturate(160%);
}

.modal-card {
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.16);
}

.map-picker-map,
.map-empty,
.mini-map {
  background: #fbfbfd;
  background-size: auto;
  border-color: rgba(0, 0, 0, 0.08);
}

.map-draw-layer {
  background: rgba(0, 113, 227, 0.025);
}

.map-hint {
  background: rgba(29, 29, 31, 0.78);
}

.selection-rect {
  border-color: #0071e3;
  background: rgba(0, 113, 227, 0.14);
  box-shadow: 0 0 0 9999px rgba(29, 29, 31, 0.08);
}

.center-pin {
  background: #ff3b30;
}

.radius-ring {
  border-color: rgba(0, 113, 227, 0.82);
  background: rgba(0, 113, 227, 0.08);
}

.mini-map::before {
  border-top-color: rgba(0, 113, 227, 0.30);
}

.mini-map i,
.route-list li > span,
.visit-order {
  background: rgba(0, 122, 255, 0.13);
  color: #0066cc;
  box-shadow: none;
}

.mini-map i.start {
  background: rgba(255, 159, 10, 0.16);
  color: #a15c00;
}

.route-stats,
.selection-summary {
  background: rgba(245, 245, 247, 0.78);
}

.phone-shell {
  background: rgba(255, 255, 255, 0.78);
  color: #1d1d1f;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(18px) saturate(160%);
}

.phone-top span {
  color: #86868b;
}

.quick-actions button {
  background: rgba(0, 113, 227, 0.10);
  color: #0066cc;
}

.quick-actions button:hover {
  background: rgba(0, 113, 227, 0.16);
}

.toast {
  background: rgba(29, 29, 31, 0.90);
  border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(18px) saturate(160%);
}

.toast.warn {
  background: rgba(255, 149, 0, 0.94);
}

.mobile-nav {
  background: rgba(255, 255, 255, 0.96);
  color: #424245;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.14);
  backdrop-filter: blur(22px) saturate(180%);
}

.mobile-nav button {
  color: #424245;
}

.mobile-nav button.active {
  background: rgba(0, 113, 227, 0.12);
  color: #0066cc;
}

@media (max-width: 1100px) {
  .main {
    padding: 22px 18px 112px;
  }
}

@media (max-width: 720px) {
  .main {
    padding: 18px 12px 142px;
  }

  .tool-panel,
  .auth-card,
  .modal-card {
    padding: 16px;
  }

  .topbar h1 {
    font-size: 30px;
  }
}

/* UIAudit accessibility and responsive hardening */
:root {
  --focus: #0a84ff;
  --muted-readable: #5f6368;
  --green: #176c2e;
  --warning-bg: #7a3f00;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  line-height: 1.45;
}

::selection {
  background: rgba(0, 113, 227, 0.22);
}

button,
.button,
.file-button,
input,
select,
textarea {
  min-height: 44px;
}

button,
.button,
.file-button {
  line-height: 1.2;
  text-align: center;
}

button:focus-visible,
.button:focus-visible,
.file-button:focus-within,
a:focus-visible,
summary:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.route-check:focus-within,
.map-draw-layer:focus-visible {
  outline: 3px solid rgba(10, 132, 255, 0.38);
  outline-offset: 3px;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline-offset: 1px;
}

.icon-button {
  width: 44px;
  height: 44px;
  min-height: 44px;
}

.brand span,
.sidebar-footer,
.phone-top span,
.eyebrow {
  color: var(--muted-readable);
}

.nav button,
.mobile-nav button {
  min-width: 0;
}

.nav button.active,
.mobile-nav button.active {
  background: rgba(0, 113, 227, 0.16);
  color: #0057a8;
}

.mobile-nav button {
  min-height: 48px;
  padding: 6px 8px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.score {
  color: #8a4b00;
}

.status.done {
  color: var(--green);
}

.status.arrived {
  color: #0057a8;
}

.lead-meta a,
.activity-item a,
.arrival-proof a,
.mini-record a,
.lead-details summary {
  text-underline-offset: 3px;
}

.lead-card,
.candidate-card,
.visit-card,
.activity-item,
.mini-record,
.route-check,
.team-card {
  min-width: 0;
  overflow-wrap: anywhere;
}

.lead-main > div,
.candidate-card > div,
.visit-card > div,
.team-card-top > div,
.route-check span,
.route-list li > div {
  min-width: 0;
}

.lead-title-row {
  align-items: flex-start;
  min-width: 0;
}

.lead-heading,
.lead-title-row h3,
.lead-card p,
.candidate-card p,
.visit-card p,
.tags span,
.route-list small {
  min-width: 0;
  overflow-wrap: anywhere;
}

.tags span {
  white-space: normal;
}

.lead-details summary {
  min-height: 44px;
  padding: 10px 0;
}

.lead-meta a,
.activity-item a,
.arrival-proof a,
.mini-record a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

.route-check {
  grid-template-columns: 22px minmax(0, 1fr);
}

.route-check input {
  width: 1px;
  height: 1px;
  min-height: 1px;
}

.file-button {
  position: relative;
  overflow: hidden;
  min-height: 46px;
}

.file-button input[type="file"] {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  min-height: 44px;
  opacity: 0;
  cursor: pointer;
}

.bounds-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.map-draw-layer:focus-visible {
  outline-offset: -5px;
}

.map-picker-map,
.map-empty,
.mini-map {
  background: linear-gradient(180deg, #fbfbfd 0%, #f3f7fb 100%);
  background-size: auto;
}

.center-pin {
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
}

.toast {
  left: auto;
  max-width: min(420px, calc(100vw - 32px));
}

.toast.warn {
  background: var(--warning-bg);
  color: #fff;
}

.topbar-actions {
  align-items: end;
}

.topbar-actions label {
  min-width: 132px;
}

.topbar-actions button[data-action="logout"] {
  min-width: 108px;
  margin-bottom: 0;
}

.panel-title-actions,
.team-card-person,
.team-card-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.panel-title-actions {
  flex-wrap: wrap;
}

.team-panel-head {
  align-items: center;
  margin-bottom: 18px;
}

.team-card-top {
  justify-content: space-between;
  align-items: flex-start;
}

.team-card-actions {
  flex: 0 0 auto;
  justify-content: flex-end;
  gap: 6px;
  margin-left: auto;
}

.team-card-actions button {
  min-height: 36px;
  padding: 0;
  white-space: nowrap;
}

.team-icon-button {
  width: 36px;
  height: 36px;
  min-height: 36px;
  border-radius: 10px;
}

.team-icon-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.secondary.danger {
  border-color: rgba(180, 35, 24, 0.24);
  color: #b42318;
}

.secondary.danger:hover {
  border-color: rgba(180, 35, 24, 0.42);
  background: rgba(180, 35, 24, 0.06);
}

.team-member-modal {
  width: min(100%, 560px);
}

.team-member-form input[type="color"] {
  padding: 5px;
}

.form-actions {
  justify-content: flex-end;
}

@media (prefers-reduced-motion: reduce) {
  button:hover,
  .button:hover,
  .file-button:hover,
  button:active,
  .button:active,
  .file-button:active {
    transform: none;
  }

  button,
  .button,
  .file-button {
    transition:
      background 0.12s ease,
      border-color 0.12s ease,
      box-shadow 0.12s ease;
  }
}

@media (max-width: 720px) {
  .topbar-actions,
  .inline-controls,
  .button-row,
  .route-actions {
    align-items: stretch;
  }

  .topbar-actions > *,
  .inline-controls > *,
  .button-row > *,
  .route-actions > * {
    flex: 1 1 100%;
  }

  .topbar-actions label,
  .topbar-actions button[data-action="logout"] {
    min-width: 0;
  }

  .team-card-top,
  .team-action-row,
  .timeline-item,
  .form-actions {
    display: grid;
    grid-template-columns: 1fr;
    justify-items: stretch;
  }

  .team-card-top {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
  }

  .team-card-actions {
    display: flex;
    justify-content: flex-end;
    justify-self: end;
  }

  .team-card-actions button {
    width: 38px;
    min-height: 38px;
  }

  .lead-visit-summary {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
  }

  .lead-visit-summary > .status {
    justify-self: start;
  }

  .lead-visit-actions {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .lead-visit-evidence {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .lead-tabs,
  .arrival-evidence-links {
    align-items: stretch;
  }

  .lead-tabs button,
  .arrival-evidence-links > * {
    flex: 1 1 auto;
  }

  .lead-workflow-tabs button {
    flex: 0 0 auto;
  }

  .arrival-record-row {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .timeline-location {
    justify-items: start;
  }

  .visit-card {
    grid-template-columns: 1fr;
  }

  .visit-order {
    width: 44px;
    height: 44px;
  }

  .route-stats,
  .lead-meta,
  .metric-line {
    display: grid;
    grid-template-columns: 1fr;
    justify-items: start;
  }

  .modal-backdrop {
    padding: 10px;
    place-items: stretch;
  }

  .modal-card {
    max-height: calc(100vh - 20px);
  }
}

@media (max-width: 460px) {
  .main {
    padding: 14px 10px 164px;
  }

  .mobile-nav {
    grid-template-columns: 1fr;
  }

  .mobile-nav-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .funnel-row,
  .route-list li {
    grid-template-columns: 1fr;
  }

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

/* Specific alignment for the requested filter rows. Keep this after generic panel rules. */
.panel-head.filter-panel-head {
  display: grid;
  grid-template-columns: minmax(88px, auto) minmax(0, 1fr);
  align-items: center;
  gap: 20px;
}

.panel-head.filter-panel-head h2 {
  white-space: nowrap;
}

@media (max-width: 900px) {
  .panel-head.filter-panel-head,
  .lead-filter-row {
    grid-template-columns: 1fr;
  }
}
