:root {
  color-scheme: light;
  --ink: #172126;
  --muted: #607078;
  --line: #d9e1df;
  --panel: #ffffff;
  --page: #eef6fb;
  --green: #286b5f;
  --green-2: #d9eee8;
  --red: #b34a3c;
  --amber: #b98325;
  --blue: #386fa4;
  --shadow: 0 20px 50px rgba(28, 48, 43, 0.12);
  font-family: Inter, Segoe UI, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
}

.start-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  background: var(--page);
}

.start-hero {
  width: min(880px, 100%);
  display: grid;
  justify-items: center;
  gap: 28px;
  text-align: center;
}

.start-logo {
  width: min(360px, 72vw);
  height: auto;
  display: block;
}

.start-logo-link {
  display: inline-flex;
}

.start-copy {
  display: grid;
  gap: 6px;
}

.start-copy h1 {
  color: #052f63;
  font-size: clamp(2rem, 5vw, 4rem);
}

.offline-note {
  max-width: 620px;
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.start-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background: var(--page);
}

.login-card {
  display: grid;
  gap: 18px;
  width: min(420px, 100%);
  border-radius: 8px;
  padding: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-logo {
  width: min(230px, 72vw);
  height: auto;
  justify-self: center;
}

.login-card h1 {
  color: #052f63;
  font-size: 2rem;
}

.login-error {
  margin: 0;
  color: var(--red);
  font-size: 0.86rem;
  font-weight: 800;
}

.login-hint {
  margin: 0;
  color: var(--muted);
  text-align: center;
  font-size: 0.82rem;
}

button,
input,
select {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

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

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 28px;
  height: 100vh;
  overflow: auto;
  padding: 24px 18px;
  background: #16231f;
  color: #f8fbfa;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: block;
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: 8px;
  background: #ffffff;
  padding: 4px;
}

.brand strong,
.brand span {
  display: block;
}

.brand span,
.sync-panel small {
  color: #b7c5c0;
  font-size: 0.82rem;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-item {
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #d9e7e2;
  text-align: left;
  cursor: pointer;
}

.nav-item span:first-child {
  text-align: center;
  color: #9fb3ad;
  font-size: 0.72rem;
  font-weight: 800;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.11);
  color: #ffffff;
}

.nav-item.sub-item {
  grid-template-columns: 34px 1fr;
  margin-left: 18px;
  min-height: 34px;
  color: #c8d6d1;
  font-size: 0.86rem;
}

.nav-item.sub-item span:first-child {
  color: #7f9690;
}

.sync-panel {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
}

.sync-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #6bdb9f;
  box-shadow: 0 0 0 5px rgba(107, 219, 159, 0.13);
}

.user-panel {
  display: grid;
  gap: 10px;
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
}

.user-panel span,
.user-panel strong,
.user-panel small {
  display: block;
}

.user-panel small {
  color: #b7c5c0;
  font-size: 0.78rem;
}

.logout-button {
  min-height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.09);
  color: #ffffff;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 800;
}

.logout-button:hover {
  background: #ffffff;
  color: #16231f;
}

body > .user-panel {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 5;
  display: flex;
  align-items: center;
  width: auto;
  min-width: 220px;
  background: rgba(22, 35, 31, 0.92);
  color: #ffffff;
  box-shadow: 0 12px 36px rgba(10, 24, 20, 0.16);
}

.main {
  display: grid;
  align-content: start;
  gap: 18px;
  padding: 24px;
}

.topbar,
.filters,
.surface-header,
.detail-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.8rem, 4vw, 2.7rem);
}

h2 {
  margin-bottom: 4px;
  font-size: 1.1rem;
}

.toolbar {
  display: flex;
  gap: 10px;
}

.sort-toggle {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef3f1;
}

.sort-toggle-button {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  padding: 0 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 800;
}

.sort-toggle-button.active,
.sort-toggle-button:hover {
  background: #ffffff;
  color: var(--green);
}

.primary-action,
.icon-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.toolbar .primary-action,
.toolbar .icon-action {
  white-space: nowrap;
}

.primary-action {
  padding: 0 16px;
  background: var(--green);
  color: #ffffff;
  font-weight: 700;
}

.danger-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  background: #f8dfda;
  color: var(--red);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 800;
}

.danger-action:hover {
  background: var(--red);
  color: #ffffff;
}

.danger-action.small-action {
  min-height: 32px;
  padding: 0 10px;
  font-size: 0.78rem;
}

.primary-action:disabled {
  background: #b9c8c3;
  color: #f8fbfa;
  cursor: default;
}

.primary-action.full-width {
  width: 100%;
}

.icon-action {
  min-width: 42px;
  padding: 0 8px;
  background: #ffffff;
  color: var(--green);
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 0.82rem;
  font-weight: 800;
}

.icon-action.small {
  width: 30px;
  min-width: 30px;
  min-height: 30px;
  padding: 0;
}

.import-action {
  white-space: nowrap;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.filters {
  display: grid;
  grid-template-columns: 170px 190px minmax(220px, 1fr) auto;
  padding: 14px;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.filters.new-tour-search {
  grid-template-columns: minmax(250px, 320px) 150px 150px 190px 180px 210px;
  justify-content: start;
}

.filters.new-tour-search .wide-field {
  grid-column: 1 / 2;
}

.filters.new-tour-search label:nth-child(7),
.filters.new-tour-search label:nth-child(8),
.filters.new-tour-search label:nth-child(9),
.filters.new-tour-search label:nth-child(10) {
  grid-row: 2;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

select,
input[type="search"],
input[type="date"],
input[type="time"],
input[type="text"],
textarea {
  min-height: 40px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fbfdfc;
  color: var(--ink);
}

textarea {
  min-height: 110px;
  padding: 10px 12px;
  resize: vertical;
}

.toggle-row {
  display: flex;
  align-items: end;
  gap: 8px;
  padding-bottom: 9px;
  white-space: nowrap;
}

.compact-toggle {
  align-items: center;
  padding-bottom: 0;
}

.route-home-toggle {
  min-height: 40px;
  align-self: end;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.tour-builder-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.78fr) minmax(460px, 1fr);
  gap: 18px;
  align-items: start;
}

.optional-map-panel[hidden] {
  display: none;
}

.planner-surface,
.route-list,
.detail-band {
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.planner-surface {
  padding: 18px;
}

.config-panel {
  display: grid;
  gap: 18px;
}

.config-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) auto;
  gap: 14px;
  align-items: end;
}

.config-actions {
  justify-content: flex-start;
}

.user-profiles-list {
  display: grid;
  gap: 14px;
}

.user-profile-card {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #ffffff;
}

.user-address-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.user-address-columns h3,
.user-profile-card h3 {
  margin: 0 0 10px;
  font-size: 0.95rem;
}

.user-address-grid {
  display: grid;
  grid-template-columns: 1fr 130px;
  gap: 10px;
}

.user-address-grid label:first-child,
.user-address-grid label:last-child {
  grid-column: 1 / -1;
}

.route-list {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.surface-header p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.metric-strip,
.detail-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.metric-strip span,
.detail-metrics span {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--green-2);
  color: var(--green);
  font-size: 0.82rem;
}

.small-map-action {
  min-height: 34px;
  padding: 0 10px;
}

.map-board {
  position: relative;
  overflow: hidden;
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  aspect-ratio: 16 / 9;
  min-height: 360px;
  background:
    linear-gradient(90deg, rgba(56, 111, 164, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(56, 111, 164, 0.08) 1px, transparent 1px),
    radial-gradient(circle at 22% 36%, rgba(242, 198, 109, 0.42), transparent 16%),
    radial-gradient(circle at 74% 24%, rgba(40, 107, 95, 0.18), transparent 18%),
    #f9fbfa;
  background-size: 52px 52px, 52px 52px, auto, auto, auto;
}

.plan-map-board {
  min-height: 520px;
}

#routeMap {
  width: 100%;
  height: 100%;
  display: block;
}

.osm-map,
.map-board svg {
  width: 100%;
  height: 100%;
  min-height: inherit;
  display: block;
}

.osm-map {
  z-index: 0;
}

.google-map-canvas {
  width: 100%;
  height: 100%;
  min-height: inherit;
  display: block;
}

.map-config-note {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 2;
  padding: 9px 12px;
  border: 1px solid rgba(5, 47, 99, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.map-route-note {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 56px;
  z-index: 2;
  padding: 9px 12px;
  border: 1px solid rgba(217, 120, 36, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.95);
  color: #7a3b08;
  font-size: 0.78rem;
  font-weight: 800;
}

.osm-marker {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 3px solid #ffffff;
  border-radius: 50%;
  color: #ffffff;
  box-shadow: 0 6px 18px rgba(10, 24, 20, 0.24);
  font-size: 0.72rem;
  font-weight: 900;
}

.user-location-dot {
  width: 34px;
  height: 34px;
  background: #052f63;
  font-size: 0.68rem;
}

.map-stop {
  cursor: pointer;
}

.map-stop text {
  pointer-events: none;
}

.map-legend {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: flex;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.map-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--green);
}

.lead-dot {
  border-radius: 3px;
  background: #d97824;
}

.map-account-panel {
  position: absolute;
  top: 12px;
  right: 12px;
  display: none;
  width: min(360px, calc(100% - 24px));
  max-height: calc(100% - 24px);
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 42px rgba(28, 48, 43, 0.18);
}

.map-account-panel.is-open {
  display: grid;
  gap: 12px;
}

.account-panel-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.modal-header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.account-panel-header h3 {
  margin: 7px 0 2px;
  font-size: 1rem;
}

.account-panel-header p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.contact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0;
}

.contact-grid div {
  min-width: 0;
}

.contact-grid dt {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.contact-grid dd {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
  font-size: 0.86rem;
  font-weight: 700;
}

.contact-grid a {
  color: var(--green);
}

.revenue-history {
  display: grid;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.revenue-history-title {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.revenue-bars {
  display: grid;
  gap: 7px;
}

.revenue-row {
  display: grid;
  grid-template-columns: 42px minmax(70px, 1fr) auto;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
}

.revenue-row span {
  color: var(--muted);
  font-weight: 800;
}

.revenue-row strong {
  font-size: 0.78rem;
}

.revenue-track {
  overflow: hidden;
  height: 8px;
  border-radius: 999px;
  background: #e8efec;
}

.revenue-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.account-actions {
  display: grid;
  gap: 7px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.account-actions p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.stops {
  display: grid;
  gap: 10px;
  max-height: 526px;
  overflow: auto;
  padding-right: 2px;
}

.compact-stops {
  max-height: 590px;
}

.selected-tour-panel {
  max-height: calc(100vh - 220px);
  overflow: hidden;
}

.selected-tour-panel .compact-stops {
  max-height: calc(100vh - 330px);
  overflow-y: auto;
}

.time-select {
  max-height: 220px;
}

.stop-card {
  display: grid;
  gap: 8px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdfc;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.stop-card:hover,
.stop-card.selected {
  border-color: var(--green);
  box-shadow: inset 4px 0 0 var(--green);
}

.selected-tour-stop {
  cursor: default;
}

.empty-state {
  margin: 0;
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.88rem;
}

.saved-tours-list {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.saved-tour-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfdfc;
}

.saved-tour-card.selected {
  border-color: var(--green);
  box-shadow: inset 4px 0 0 var(--green);
}

.saved-tour-stops {
  display: grid;
  gap: 8px;
}

.saved-tour-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.saved-tour-actions .primary-action,
.saved-tour-actions .icon-action {
  min-width: 132px;
  justify-content: center;
}

.tour-detail-section {
  display: grid;
  gap: 18px;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 18px;
}

.tour-detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 18px;
  align-items: start;
}

.tour-detail-grid.single-column {
  grid-template-columns: 1fr;
}

.tour-detail-map {
  min-height: 560px;
}

.tour-osm-map {
  height: 560px;
  min-height: 560px;
  background: #dfe8ec;
}

.custom-tour-map {
  min-height: 520px;
  border-radius: 8px;
  overflow: hidden;
  background: linear-gradient(180deg, #e8f4fb 0%, #f7fbfd 100%);
}

.custom-tour-map svg {
  display: block;
  width: 100%;
  min-height: 520px;
}

.germany-map-shape {
  fill: #edf4ee;
  stroke: #9bb7a9;
  stroke-width: 3;
}

.germany-map-river {
  fill: none;
  stroke: #a8cfe5;
  stroke-width: 6;
  stroke-linecap: round;
  opacity: 0.7;
}

.tour-map-route {
  fill: none;
  stroke: #052f63;
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.9;
}

.tour-map-number {
  fill: #ffffff;
  font-size: 11px;
  font-weight: 900;
}

.tour-map-label {
  fill: var(--ink);
  font-size: 13px;
  font-weight: 800;
  paint-order: stroke;
  stroke: #ffffff;
  stroke-width: 5px;
  stroke-linejoin: round;
}

.tour-osm-marker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transform: translateY(-2px);
}

.tour-osm-number {
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  place-items: center;
  border: 3px solid #ffffff;
  border-radius: 50%;
  color: #ffffff;
  box-shadow: 0 3px 8px rgba(10, 24, 20, 0.18);
  font-size: 0.72rem;
  font-weight: 900;
}

.tour-osm-label {
  max-width: 180px;
  overflow: hidden;
  padding: 5px 7px;
  border: 1px solid rgba(12, 35, 28, 0.12);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: none;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 800;
  text-overflow: ellipsis;
}

.map-modal {
  display: grid;
  gap: 14px;
  width: min(980px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  border-radius: 8px;
  padding: 18px;
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(10, 24, 20, 0.28);
}

.appointment-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

.edit-appointment-grid {
  padding-top: 4px;
}

.completed-stop {
  background: #f4faf7;
}

.saved-tour-stop {
  display: grid;
  align-items: center;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
  color: var(--muted);
  font-size: 0.95rem;
}

.saved-tour-stop strong {
  color: var(--ink);
}

.saved-tour-stop-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.saved-tour-stop-contact {
  display: block;
  color: var(--muted);
  text-align: right;
}

.stop-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.stop-name {
  font-weight: 800;
}

.stop-meta,
.stop-tags,
.stop-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
}

.visit-complete-button {
  min-height: 32px;
  border: 0;
  border-radius: 8px;
  padding: 0 10px;
  background: #fae1c8;
  color: #a45112;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 800;
}

.visit-complete-button:hover {
  background: #d97824;
  color: #ffffff;
}

.note-open-button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 800;
}

.note-open-button:hover {
  border-color: var(--green);
  color: var(--green);
}

.visit-status-complete {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
  padding: 0 10px;
  background: var(--green);
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 800;
}

.badge {
  border-radius: 999px;
  padding: 3px 8px;
  background: #eef3f1;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.badge.high {
  background: #f8dfda;
  color: var(--red);
}

.badge.medium {
  background: #f6ead2;
  color: var(--amber);
}

.badge.low {
  background: #dbeaf7;
  color: var(--blue);
}

.badge.customer-badge,
.badge.revenue-customer {
  background: #d9eee8;
  color: var(--green);
}

.badge.lead-badge,
.badge.zero-revenue-lead {
  background: #fae1c8;
  color: #a45112;
}

.detail-band {
  padding: 18px;
}

.detail-band p {
  max-width: 760px;
  margin-bottom: 0;
  color: var(--muted);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(19, 31, 28, 0.48);
}

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

.visit-modal {
  display: grid;
  gap: 14px;
  width: min(560px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  border-radius: 8px;
  padding: 18px;
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(10, 24, 20, 0.28);
}

.visit-note-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #ffffff;
}

.visit-note-box p {
  margin: 0;
  color: var(--ink);
  line-height: 1.6;
  white-space: pre-wrap;
}

.structured-visit-note {
  display: grid;
  gap: 10px;
}

.structured-visit-note div {
  display: grid;
  gap: 3px;
}

.structured-visit-note strong {
  color: var(--ink);
  font-size: 0.78rem;
}

.structured-visit-note span {
  color: var(--muted);
  line-height: 1.5;
}

.customer-directory {
  display: grid;
  gap: 16px;
}

.ai-research-panel {
  display: grid;
  gap: 14px;
  border-radius: 8px;
  padding: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.ai-search-grid {
  display: grid;
  grid-template-columns: 180px 130px minmax(260px, 1fr) auto;
  align-items: end;
  gap: 12px;
}

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

.ai-result-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #ffffff;
}

.ai-result-card p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.ai-result-card button {
  flex: 0 0 auto;
}

.compact-search {
  min-width: min(360px, 100%);
}

.alphabet-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.alphabet-button {
  width: 34px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
}

.alphabet-button.active,
.alphabet-button:hover:not(:disabled) {
  border-color: var(--green);
  background: var(--green);
  color: #ffffff;
}

.alphabet-button:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

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

.customer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.customer-row:hover {
  border-color: var(--green);
  box-shadow: 0 10px 28px rgba(18, 42, 34, 0.08);
}

.customer-row-main,
.customer-row-side {
  display: grid;
  gap: 4px;
}

.customer-row-main small,
.customer-row-side small {
  color: var(--muted);
}

.customer-row-side {
  justify-items: end;
  min-width: 170px;
}

.customer-modal {
  display: grid;
  gap: 16px;
  width: min(780px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  border-radius: 8px;
  padding: 18px;
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(10, 24, 20, 0.28);
}

.modal-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.modal-head h2 {
  margin: 8px 0 4px;
}

.modal-head p {
  margin: 0;
  color: var(--muted);
}

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

.customer-master-grid article,
.visit-summary {
  display: grid;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #ffffff;
}

.customer-master-grid span,
.visit-summary p {
  color: var(--muted);
}

.customer-master-grid a {
  color: var(--green);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.visit-summary h3 {
  margin: 0;
}

.visit-summary p {
  margin: 0;
}

.tight-heading {
  margin-bottom: 8px;
}

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

.visit-history-entry {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #ffffff;
}

.visit-history-entry div {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
}

.visit-history-entry span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.visit-history-entry .deleted-tour-source {
  color: var(--amber);
  font-weight: 800;
}

.visit-history-entry p {
  margin: 0;
  color: var(--ink);
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 228px minmax(0, 1fr);
  }

  .brand div:last-child,
  .sync-panel div {
    display: none;
  }

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

  .tour-builder-grid {
    grid-template-columns: 1fr;
  }

  .tour-detail-grid {
    grid-template-columns: 1fr;
  }

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

  .route-list {
    order: -1;
  }

  .selected-tour-panel {
    order: -2;
    max-height: none;
    overflow: visible;
  }

  .selected-tour-panel .compact-stops {
    max-height: 590px;
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
    flex-direction: row;
    align-items: center;
    height: auto;
    padding: 12px;
    overflow-x: auto;
  }

  .nav-list {
    grid-auto-flow: column;
    overflow: auto;
  }

  .nav-item {
    min-width: max-content;
    padding-right: 12px;
  }

  .sync-panel {
    display: none;
  }

  .user-panel {
    margin-top: 0;
    min-width: 210px;
  }

  .main {
    padding: 16px;
  }

  .topbar,
  .detail-band,
  .modal-actions {
    align-items: start;
    flex-direction: column;
  }

  .modal-actions .icon-action,
  .modal-actions .primary-action {
    width: 100%;
  }

  .modal-header-actions {
    justify-content: flex-start;
  }

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

  .filters.new-tour-search {
    grid-template-columns: 1fr;
  }

  .filters.new-tour-search .wide-field {
    grid-column: auto;
  }

  .ai-search-grid {
    grid-template-columns: 1fr;
  }

  .user-address-columns,
  .user-address-grid {
    grid-template-columns: 1fr;
  }

  .user-address-grid label:first-child,
  .user-address-grid label:last-child {
    grid-column: auto;
  }

  .ai-result-card {
    align-items: stretch;
    flex-direction: column;
  }

  .ai-result-card button {
    width: 100%;
  }

  .toolbar {
    flex-wrap: wrap;
  }

  .map-board {
    min-height: 0;
    aspect-ratio: auto;
  }

  #routeMap {
    height: 280px;
  }

  .map-account-panel {
    position: relative;
    inset: auto;
    width: 100%;
    max-height: none;
    border-top: 1px solid var(--line);
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 0;
    box-shadow: none;
  }

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

  .revenue-row {
    grid-template-columns: 38px minmax(70px, 1fr);
  }

  .revenue-row strong {
    grid-column: 2;
  }

  .saved-tour-stop {
    align-items: flex-start;
    flex-direction: column;
  }

  .customer-row,
  .modal-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .customer-row-side {
    justify-items: start;
    min-width: 0;
  }

  .customer-master-grid {
    grid-template-columns: 1fr;
  }
}
