:root {
  --ink: #18212f;
  --muted: #667085;
  --line: #d7dce4;
  --surface: #ffffff;
  --soft: #f4f6f8;
  --panel: #eef2f5;
  --under: #cf3e35;
  --normal: #2f7e69;
  --over: #1b72ad;
  --inactive: #7d8794;
  --action: #b4238a;
  --prospect: #b46b18;
  --review: #8b5e00;
  --focus: #2563eb;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--soft);
  color: var(--ink);
}

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

button,
.file-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  min-height: 36px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  white-space: nowrap;
}

button:hover,
.file-button:hover {
  border-color: #9aa6b5;
}

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

.link-button {
  min-height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #175cd3;
  text-align: left;
  white-space: normal;
}

.link-button:hover {
  text-decoration: underline;
  border-color: transparent;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
.file-button:focus-within {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto 1fr;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(120deg, rgba(17, 24, 39, 0.92), rgba(24, 33, 47, 0.82)),
    url("https://images.unsplash.com/photo-1607860108855-64acf2078ed9?auto=format&fit=crop&w=1600&q=80") center/cover;
}

.login-panel {
  width: min(440px, 100%);
  display: grid;
  gap: 14px;
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
}

.login-brand {
  color: var(--ink);
  margin-bottom: 4px;
}

.login-brand p,
.login-help,
.login-message {
  color: var(--muted);
  font-size: 13px;
}

.login-message {
  min-height: 18px;
  color: #b42318;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto auto;
  gap: 16px;
  align-items: center;
  padding: 14px 18px;
  background: #111827;
  color: #fff;
  border-bottom: 1px solid #283345;
}

.brand-block {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 6px;
  background: #d9a441;
  color: #111827;
  display: grid;
  place-items: center;
  font-weight: 800;
  flex: 0 0 auto;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 18px;
  line-height: 1.2;
}

h2 {
  font-size: 14px;
  letter-spacing: 0;
}

.brand-block p {
  color: #c7d0dd;
  font-size: 13px;
  margin-top: 2px;
}

.upload-strip,
.role-strip,
.session-strip,
.tab-strip,
.map-actions,
.review-actions,
.route-actions,
.heading-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.map-actions .is-active {
  background: #d9a441;
  border-color: #d9a441;
  color: #111827;
}

.topbar button,
.topbar .file-button {
  background: #1e293b;
  color: #f8fafc;
  border-color: #35445a;
}

.file-button input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.role-chip.is-active {
  background: #d9a441;
  color: #151515;
  border-color: #d9a441;
}

.session-strip {
  justify-content: flex-end;
}

.session-user {
  display: grid;
  gap: 3px;
  color: #c7d0dd;
  font-size: 11px;
  min-width: 170px;
}

.session-user strong {
  color: #f8fafc;
  font-size: 13px;
  line-height: 1.2;
}

.active-operator-field {
  display: grid;
  gap: 3px;
  min-width: 160px;
  color: #c7d0dd;
  font-size: 11px;
}

.active-operator-field select {
  min-height: 32px;
  padding: 5px 8px;
  background: #1e293b;
  color: #f8fafc;
  border-color: #35445a;
}

.tab-strip {
  padding: 8px 18px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.tab-button.is-active {
  background: #111827;
  border-color: #111827;
  color: #fff;
}

.app-view[hidden] {
  display: none;
}

.settings-view,
.users-view,
.list-view {
  min-height: 620px;
  padding: 18px;
  background: var(--soft);
}

.settings-grid,
.users-layout,
.prospects-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 520px));
  gap: 16px;
  align-items: start;
}

.prospects-layout {
  grid-template-columns: minmax(280px, 360px) minmax(520px, 1fr);
}

.connectors-view {
  min-height: 620px;
  padding: 18px;
  background: var(--soft);
}

.connectors-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(320px, 1fr));
  gap: 16px;
  align-items: start;
}

.connector-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.connector-note {
  color: #475467;
  font-size: 13px;
  line-height: 1.45;
  margin: 0 0 12px;
}

.google-cost-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.google-cost-panel div {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.google-cost-panel span {
  display: block;
  color: #475467;
  font-size: 12px;
}

.google-cost-panel strong {
  display: block;
  margin-top: 3px;
  color: #182230;
  font-size: 18px;
  line-height: 1.2;
}

.connector-status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 700;
}

.connector-status.is-live {
  background: #e8f7f2;
  color: #176b55;
}

.connector-status.is-planned {
  background: #eef4ff;
  color: #175cd3;
}

.connector-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.connector-row {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.connector-row-header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: start;
}

.connector-row strong {
  font-size: 13px;
}

.connector-row span,
.connector-row code {
  color: #475467;
  font-size: 12px;
}

.connector-row code {
  display: block;
  white-space: normal;
  word-break: break-all;
}

.report-filters {
  display: grid;
  grid-template-columns: minmax(220px, 320px) repeat(2, minmax(160px, 220px));
  gap: 12px;
  align-items: end;
  padding: 12px 16px 2px;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  background: #fff;
}

.settings-panel,
.prospect-table-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.prospect-table-panel {
  overflow: hidden;
}

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px 8px 0 0;
}

.list-header h2 {
  font-size: 16px;
}

.list-header p {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.metrics-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.metric {
  min-width: 0;
  padding: 12px 18px;
  border-right: 1px solid var(--line);
}

.metric span {
  color: var(--muted);
  display: block;
  font-size: 12px;
}

.metric strong {
  font-size: 22px;
  line-height: 1.2;
}

.workspace {
  display: grid;
  grid-template-columns: 300px minmax(420px, 1fr) 340px;
  min-height: 0;
}

.left-panel,
.right-panel {
  min-width: 0;
  overflow: auto;
  background: var(--panel);
  border-right: 1px solid var(--line);
}

.right-panel {
  border-right: 0;
  border-left: 1px solid var(--line);
}

.panel-section {
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.section-heading,
.review-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.section-heading span,
.review-header p,
#visitSavedLabel {
  color: var(--muted);
  font-size: 12px;
}

.field {
  display: grid;
  gap: 5px;
  margin-bottom: 10px;
}

.field span,
.check-row span {
  color: #465264;
  font-size: 12px;
}

.check-row {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 8px;
  align-items: start;
}

.check-row input {
  width: auto;
  margin-top: 2px;
}

.map-stage {
  position: relative;
  min-height: 520px;
  background: #dce7ed;
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
}

.map-toolbar {
  position: relative;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.95);
  border-bottom: 1px solid var(--line);
}

.legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  color: #344054;
  font-size: 12px;
}

.legend-toggle {
  min-height: 30px;
  padding: 0 9px;
  border-color: transparent;
  background: #fff;
  color: #344054;
}

.legend-toggle.is-active {
  border-color: var(--line);
  box-shadow: inset 0 0 0 1px rgba(17, 24, 39, 0.04);
}

.legend-toggle:not(.is-active) {
  color: #8a94a3;
  opacity: 0.58;
  text-decoration: line-through;
}

.dot {
  inline-size: 10px;
  block-size: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 5px;
  border: 1px solid rgba(0, 0, 0, 0.2);
}

.under {
  background: var(--under);
}

.normal {
  background: var(--normal);
}

.over {
  background: var(--over);
}

.inactive {
  background: var(--inactive);
}

.prospect {
  background: var(--prospect);
}

.action {
  background: var(--action);
}

.map {
  min-height: 100%;
  width: 100%;
}

.map.is-selecting-route {
  cursor: crosshair;
}

.selection-box {
  position: absolute;
  z-index: 900;
  border: 1px dashed #111827;
  background: rgba(217, 164, 65, 0.18);
  pointer-events: none;
}

.fallback-map {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.45) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.45) 1px, transparent 1px),
    linear-gradient(135deg, #b8d2de, #eef3e6 52%, #c9dde8);
  background-size: 72px 72px, 72px 72px, 100% 100%;
}

.fallback-marker {
  position: absolute;
  inline-size: 18px;
  block-size: 18px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.35);
  transform: translate(-50%, -50%);
  cursor: pointer;
}

.context-menu {
  position: absolute;
  z-index: 1200;
  width: 220px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.2);
}

.context-menu[hidden],
.modal-backdrop[hidden] {
  display: none;
}

.context-title {
  color: #344054;
  font-weight: 750;
  font-size: 13px;
  padding: 4px 6px 8px;
}

.context-menu button {
  width: 100%;
  justify-content: flex-start;
  border-color: transparent;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2500;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.42);
}

.modal-panel {
  width: min(720px, calc(100vw - 32px));
  max-height: min(780px, calc(100vh - 32px));
  overflow: auto;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 22px 70px rgba(15, 23, 42, 0.34);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.modal-header h2 {
  font-size: 18px;
}

.modal-body {
  padding: 16px 18px 18px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  gap: 10px;
}

.info-grid div,
.info-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #f8fafc;
}

.info-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.info-grid strong {
  display: block;
  margin-top: 3px;
  font-size: 15px;
}

.info-block {
  margin-top: 10px;
}

.info-block h3 {
  margin: 0 0 6px;
  font-size: 13px;
}

.info-block p {
  color: #344054;
  font-size: 13px;
  margin-top: 3px;
}

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

.visit-history-row {
  display: grid;
  gap: 3px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e5e7eb;
}

.visit-history-row:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.visit-history-row strong {
  font-size: 13px;
}

.visit-history-row span,
.visit-history-row p {
  color: #475467;
  font-size: 12px;
}

.edit-form {
  display: grid;
  gap: 10px;
}

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

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.selected-empty,
.empty-table {
  color: var(--muted);
  font-size: 13px;
}

.selected-card {
  display: grid;
  gap: 8px;
}

.selected-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
}

.selected-name {
  font-weight: 750;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 8px;
  color: #fff;
  font-size: 12px;
  font-weight: 650;
}

.status-under {
  background: var(--under);
}

.status-normal {
  background: var(--normal);
}

.status-over {
  background: var(--over);
}

.status-inactive {
  background: var(--inactive);
}

.status-prospect {
  background: var(--prospect);
}

.status-action {
  background: var(--action);
}

.assignment-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: #344054;
  font-size: 12px;
  font-weight: 650;
}

.assignment-unassigned {
  color: var(--muted);
  background: #f8fafc;
}

.assignment-assigned {
  border-color: #b8c7dd;
  background: #eef4ff;
  color: #175cd3;
}

.assignment-mine {
  border-color: #a6d8ca;
  background: #e8f7f2;
  color: #176b55;
}

.assignment-other {
  border-color: #f2b8b5;
  background: #fff1f0;
  color: #991b1b;
}

.assignment-warning-line {
  border-left: 3px solid #991b1b;
  padding: 6px 8px;
  background: #fff1f0;
  color: #991b1b;
  font-size: 13px;
  font-weight: 650;
}

.user-list,
.assignment-selection-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.user-row,
.assignment-selection-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.user-row div {
  display: grid;
  gap: 2px;
}

.user-row .user-row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.user-row .user-row-actions button {
  min-height: 30px;
  padding: 0 9px;
}

.user-row span {
  color: var(--muted);
  font-size: 12px;
}

.route-list {
  padding-left: 22px;
  margin: 12px 0 0;
}

.route-progress {
  color: var(--muted);
  font-size: 12px;
  margin-top: 10px;
}

.route-batches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.route-batches button {
  min-height: 30px;
  padding: 0 9px;
}

.route-list li {
  margin-bottom: 10px;
  padding-right: 34px;
  position: relative;
}

.route-list li.is-complete {
  color: var(--muted);
}

.route-list li.is-current {
  border-left: 3px solid #d9a441;
  padding-left: 8px;
}

.route-stop-meta {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.route-list button {
  position: absolute;
  right: 0;
  top: -4px;
  min-height: 28px;
  padding: 0 8px;
}

.review-row,
.customer-table-section {
  background: #fff;
  border-top: 1px solid var(--line);
  padding: 16px 18px;
}

.review-header {
  margin-bottom: 10px;
}

.review-header h2,
.table-title h2 {
  font-size: 16px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  max-height: 360px;
  background: #fff;
}

.list-table-wrap {
  max-height: calc(100vh - 220px);
  border-top: 0;
  border-radius: 0 0 8px 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 880px;
}

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid #edf0f4;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: #475467;
  font-size: 12px;
}

tr.is-selected {
  background: #f2f7ff;
}

.review-source {
  display: inline-block;
  margin-left: 6px;
  color: var(--muted);
  font-size: 11px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(20px);
  max-width: min(560px, calc(100vw - 32px));
  background: #101828;
  color: #fff;
  border-radius: 8px;
  padding: 10px 14px;
  opacity: 0;
  pointer-events: none;
  transition: 180ms ease;
  z-index: 2000;
  font-size: 13px;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 1180px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .workspace {
    grid-template-columns: 280px minmax(420px, 1fr);
  }

  .settings-grid,
  .users-layout,
  .prospects-layout,
  .connectors-layout,
  .google-cost-panel,
  .report-filters {
    grid-template-columns: 1fr;
  }

  .right-panel {
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid var(--line);
    display: grid;
    grid-template-columns: repeat(3, minmax(260px, 1fr));
  }
}

@media (max-width: 820px) {
  .metrics-row {
    grid-template-columns: repeat(2, minmax(130px, 1fr));
  }

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

  .left-panel,
  .right-panel {
    display: block;
    border: 0;
  }

  .map-stage {
    min-height: 520px;
  }

  .map-toolbar,
  .review-header,
  .list-header,
  .user-row,
  .assignment-selection-row {
    align-items: stretch;
    flex-direction: column;
  }

  .edit-form-grid {
    grid-template-columns: 1fr;
  }
}
