:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-soft: #f8fafd;
  --text: #101828;
  --muted: #667085;
  --line: #d8e0ec;
  --line-strong: #c7d2e1;
  --green: #16a36d;
  --yellow: #d39100;
  --red: #e5484d;
  --blue: #2563eb;
  --blue-deep: #174ea6;
  --blue-soft: #eef4ff;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 3px 12px rgba(15, 23, 42, 0.06);
  --cursor-text-visible: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='24' viewBox='0 0 16 24'%3E%3Cpath d='M8 3v18M5 3h6M5 21h6' fill='none' stroke='white' stroke-width='4' stroke-linecap='round'/%3E%3Cpath d='M8 3v18M5 3h6M5 21h6' fill='none' stroke='%23101828' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") 8 12, text;
  --cursor-lasso: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHdpZHRoPScyNCcgaGVpZ2h0PScyNCcgdmlld0JveD0nMCAwIDI0IDI0JyBmaWxsPSdub25lJz4KICA8cGF0aCBkPSdNMTYuNSAxOUMxMy41IDE5IDExIDE2LjUgMTEgMTMuNVMxMy41IDggMTYuNSA4UzIyIDEwLjUgMjIgMTMuNSAxOS41IDE5IDE2LjUgMTknIHN0cm9rZT0nIzAwMCcgc3Ryb2tlLXdpZHRoPScyJyBzdHJva2UtZGFzaGFycmF5PScyIDMnIHN0cm9rZS1saW5lY2FwPSdyb3VuZCcgLz4KICA8cGF0aCBkPSdNMTEgMTMuNUw4IDEwLjJMNC41IDEyJyBzdHJva2U9JyMwMDAnIHN0cm9rZS13aWR0aD0nMicgc3Ryb2tlLWxpbmVjYXA9J3JvdW5kJyBzdHJva2UtbGluZWpvaW49J3JvdW5kJy8+CiAgPHBhdGggZD0nTTExIDEzLjVMNyAxNi41JyBzdHJva2U9JyMwMDAnIHN0cm9rZS13aWR0aD0nMicgc3Ryb2tlLWxpbmVjYXA9J3JvdW5kJyAvPgo8L3N2Zz4=") 12 12, auto;
}

* {
  box-sizing: border-box;
}

::selection {
  background: #c7d7fe;
  color: #101828;
}

::-moz-selection {
  background: #c7d7fe;
  color: #101828;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

input:not([type]),
input[type="email"],
input[type="number"],
input[type="password"],
input[type="search"],
input[type="tel"],
input[type="text"],
input[type="url"],
textarea,
[contenteditable="true"] {
  caret-color: #101828 !important;
  cursor: var(--cursor-text-visible);
}

body.auth-locked {
  overflow: hidden;
}

body.auth-locked .app {
  pointer-events: none;
  user-select: none;
  filter: saturate(0.75);
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(248, 250, 252, 0.9), rgba(232, 239, 249, 0.92)),
    #edf3f8;
}

.auth-screen::before,
.auth-screen::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.auth-screen::before {
  inset: -18%;
  background:
    repeating-linear-gradient(0deg, rgba(16, 24, 40, 0.05) 0 1px, transparent 1px 68px),
    repeating-linear-gradient(90deg, rgba(16, 24, 40, 0.04) 0 1px, transparent 1px 82px),
    linear-gradient(112deg, transparent 0 15%, rgba(37, 99, 235, 0.16) 15% 15.8%, transparent 15.8% 41%, rgba(22, 163, 109, 0.13) 41% 42%, transparent 42% 100%),
    linear-gradient(28deg, transparent 0 24%, rgba(211, 145, 0, 0.14) 24% 25%, transparent 25% 62%, rgba(37, 99, 235, 0.1) 62% 63%, transparent 63% 100%);
  opacity: 0.95;
  transform: rotate(-5deg) scale(1.08);
}

.auth-screen::after {
  inset: auto -8% -18% -8%;
  height: 48%;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.74), rgba(255, 255, 255, 0)),
    linear-gradient(120deg, rgba(22, 163, 109, 0.13), transparent 42%),
    linear-gradient(245deg, rgba(37, 99, 235, 0.14), transparent 46%);
  clip-path: polygon(0 28%, 17% 14%, 36% 40%, 57% 18%, 77% 34%, 100% 7%, 100% 100%, 0 100%);
}

.auth-screen[hidden] {
  display: none;
}

.auth-panel {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid rgba(199, 210, 225, 0.95);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  color: var(--text);
  font-size: 15px;
  font-weight: 760;
}

.auth-brand-mark {
  position: relative;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border: 7px solid var(--blue);
  border-radius: 50% 50% 50% 8px;
  background: #fff;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.2);
  transform: rotate(-45deg);
}

.auth-brand-mark::after {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  background: var(--green);
}

.auth-copy {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.auth-copy h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.1;
  letter-spacing: 0;
}

.auth-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.auth-copy p.error {
  color: #c8333a;
}

.auth-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  margin: 0 0 18px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 13px;
}

.auth-loading.ready {
  border-color: rgba(22, 163, 109, 0.35);
  background: rgba(22, 163, 109, 0.08);
  color: #18835b;
}

.auth-spinner {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  border: 2px solid rgba(37, 99, 235, 0.18);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: auth-spin 0.8s linear infinite;
}

.auth-loading.ready .auth-spinner {
  display: grid;
  place-items: center;
  border: 0;
  background: var(--green);
  color: #fff;
  animation: none;
}

.auth-loading.ready .auth-spinner::before {
  content: "";
  width: 8px;
  height: 5px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg) translate(1px, -1px);
}

@keyframes auth-spin {
  to {
    transform: rotate(360deg);
  }
}

.app-busy-overlay {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.22);
  backdrop-filter: blur(2px);
}

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

.app-busy-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 4px 10px;
  min-width: 260px;
  max-width: 360px;
  padding: 16px 18px;
  border: 1px solid #c8d4e5;
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.app-busy-card strong {
  color: var(--text);
  font-size: 14px;
}

.app-busy-card span:last-child {
  grid-column: 2;
  color: var(--muted);
  font-size: 12px;
}

.app-busy-spinner {
  grid-row: 1 / span 2;
  width: 22px;
  height: 22px;
  border: 3px solid #dbe7ff;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: auth-spin 0.75s linear infinite;
}

.auth-form {
  display: grid;
  gap: 16px;
}

.auth-form label {
  display: grid;
  gap: 7px;
  color: var(--text);
  font-size: 13px;
  font-weight: 680;
}

.auth-form input[type="text"],
.auth-form input[type="password"] {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
  box-shadow: inset 0 1px 1px rgba(15, 23, 42, 0.03);
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.auth-form input[type="text"]:hover,
.auth-form input[type="password"]:hover {
  border-color: var(--line-strong);
}

.auth-form input[type="text"]:focus,
.auth-form input[type="password"]:focus {
  outline: none;
  border-color: rgba(37, 99, 235, 0.78);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.auth-form button {
  min-height: 42px;
  margin-top: 2px;
}

@media (max-width: 520px) {
  .auth-screen {
    padding: 16px;
  }

  .auth-panel {
    padding: 24px 20px;
  }
}

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

.app-topbar {
  display: flex;
  align-items: stretch;
  gap: 24px;
  min-width: 0;
  padding: 0 18px;
  border-bottom: 1px solid rgba(216, 224, 236, 0.9);
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.02);
  backdrop-filter: blur(14px);
}

.app-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  min-width: 0;
  padding: 8px 0;
}

.topbar-action {
  width: auto;
  min-width: 98px;
  min-height: 38px;
  padding: 8px 14px;
  white-space: nowrap;
}

.settings-open-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  min-width: 38px;
  max-width: 38px;
  min-height: 38px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}

.autosave-status {
  min-width: 104px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
  text-align: right;
}

.autosave-status.pending {
  color: #b7791f;
}

.autosave-status.saving {
  color: #2563eb;
}

.autosave-status.saved {
  color: #18835b;
}

.autosave-status.error {
  color: var(--red);
}

.app-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  min-width: 210px;
  font-size: 15px;
  font-weight: 760;
  letter-spacing: 0;
}

.app-title-mark {
  position: relative;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 6px;
  background: linear-gradient(135deg, #2563eb 0%, #16a36d 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.36), 0 4px 10px rgba(37, 99, 235, 0.22);
}

.app-title-mark::after {
  content: "";
  position: absolute;
  inset: 5px;
  border: 2px solid #fff;
  border-radius: 999px;
}

@media (min-width: 901px) and (max-width: 1400px) {
  .app-topbar {
    gap: 10px;
    padding-inline: 10px;
  }

  .app-title {
    gap: 7px;
    min-width: 126px;
  }

  .tabs {
    flex: 1 1 auto;
    gap: 3px;
    overflow-x: hidden;
  }

  .tab-button {
    flex: 0 1 auto;
    min-width: 0;
    padding-inline: 8px;
  }

  .app-actions {
    flex: 0 0 auto;
    gap: 6px;
  }

  .topbar-action {
    min-width: 84px;
    padding-inline: 10px;
  }

  .autosave-status {
    min-width: 88px;
  }
}

.workspace {
  display: grid;
  grid-template-columns: var(--sidebar-width, 340px) 6px 1fr;
  height: calc(100vh - 56px);
  min-height: 0;
  overflow: hidden;
}

body[data-active-tab="import"] .workspace {
  grid-template-columns: var(--sidebar-width, 340px) 6px 1fr;
}

body[data-active-tab="routes"] .workspace,
body[data-active-tab="days"] .workspace {
  grid-template-columns: var(--sidebar-width, clamp(720px, 44vw, 940px)) 6px minmax(320px, 1fr);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  padding: 16px 14px;
  border-right: 1px solid rgba(216, 224, 236, 0.9);
  background: var(--panel);
  overflow: auto;
  box-shadow: 1px 0 0 rgba(255, 255, 255, 0.72);
}

.sidebar-resizer {
  width: 6px;
  min-width: 6px;
  cursor: col-resize;
  background: linear-gradient(90deg, rgba(216, 224, 236, 0.4), rgba(216, 224, 236, 0.92), rgba(216, 224, 236, 0.4));
}

.sidebar-resizer:hover,
body.resizing-sidebar .sidebar-resizer {
  background: rgba(37, 99, 235, 0.28);
}

body.resizing-sidebar {
  cursor: col-resize;
  user-select: none;
}

.brand h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.12;
  letter-spacing: 0;
  font-weight: 760;
}

.brand p,
.field span,
.hint,
.summary-row span {
  color: var(--muted);
}

.controls,
.button-row,
.legend,
.summary,
.clients,
.status-block,
.import-timings,
.import-stage-list,
.tab-panels {
  display: grid;
  gap: 9px;
}

.button-row {
  grid-template-columns: 1fr 1fr;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
  padding: 8px 0;
}

.tab-button {
  width: auto;
  min-width: 112px;
  min-height: 38px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #344054;
  font-size: 13px;
  font-weight: 680;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.tab-button:hover {
  background: #f2f5fa;
  color: var(--text);
}

.tab-button.active {
  border-color: #d6e4ff;
  background: var(--blue-soft);
  color: var(--blue-deep);
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.06);
}

button.active {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.tab-panel {
  display: none;
  gap: 10px;
}

.tab-panel.active {
  display: grid;
}

.empty-state {
  display: grid;
  gap: 8px;
  padding: 12px 0;
}

.empty-state h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.export-summary {
  padding-top: 2px;
}

.summary,
.status-block,
.import-timings,
.clients,
.routes-panel {
  padding: 10px;
  border: 1px solid rgba(216, 224, 236, 0.8);
  border-radius: 8px;
  background: var(--panel-soft);
}

.summary-row {
  min-height: 22px;
}

.summary-row strong {
  font-variant-numeric: tabular-nums;
}

.import-summary strong {
  max-width: 160px;
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-summary strong {
  max-width: 150px;
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.import-timings {
  padding-top: 2px;
}

.import-timings-top {
  display: none;
  padding-top: 12px;
  background: #fff;
}

body[data-active-tab="import"] .import-timings-top {
  display: grid;
}

.load-progress + .import-timings-top {
  margin-top: -8px;
}

body.is-importing .sidebar {
  overflow: hidden;
}

body.is-importing .import-workbench {
  pointer-events: none;
  user-select: none;
}

.import-timings-head,
.import-stage-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.import-timings-head {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.import-timings-head strong {
  color: var(--text);
  white-space: nowrap;
}

.import-stage-list {
  gap: 8px;
}

.import-stage-row {
  min-height: 32px;
  padding: 7px 9px;
  border: 1px solid rgba(216, 224, 236, 0.86);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  box-shadow: 0 1px 1px rgba(15, 23, 42, 0.02);
}

.import-stage-row strong {
  color: var(--text);
  font-size: 12px;
  white-space: nowrap;
}

.import-workbench {
  display: none;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 28px 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.74) 0%, rgba(245, 247, 251, 0.92) 42%, #f5f7fb 100%);
}

body[data-active-tab="import"] .import-workbench {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 22px;
}

body[data-active-tab="import"] .map-stage {
  display: none;
}

.import-workbench-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 22px;
}

.import-workbench-header h2,
.section-head h3 {
  margin: 0;
}

.import-workbench-header h2 {
  font-size: 28px;
  line-height: 1.15;
  font-weight: 780;
  letter-spacing: 0;
}

.import-workbench-header p {
  max-width: 760px;
  margin: 7px 0 0;
  color: #526174;
}

.import-workbench-actions {
  flex: 0 0 190px;
}

.import-workbench-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(420px, 1.1fr);
  gap: 20px;
  min-height: 0;
}

.import-card {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 16px;
  min-width: 0;
  min-height: 0;
  padding: 18px;
  border: 1px solid rgba(216, 224, 236, 0.86);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.section-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(196px, auto);
  align-items: center;
  gap: 10px;
}

.section-head h3 {
  font-size: 17px;
  line-height: 1.25;
  font-weight: 760;
}

.section-head span {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.days-head-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.days-week-count-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.days-week-count-control input {
  width: 48px;
  min-height: 28px;
  padding: 3px 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
  text-align: center;
}

.sessions-list-block {
  gap: 10px;
}

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

.session-row {
  display: grid;
  gap: 8px;
  align-items: center;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid rgba(216, 224, 236, 0.9);
  border-radius: 8px;
  background: #fff;
}

.session-row-main {
  min-width: 0;
}

.session-row-main strong,
.session-row-main span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-row-main strong {
  font-size: 13px;
  line-height: 1.35;
}

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

.session-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.session-row.editing {
  align-items: stretch;
}

.session-rename-input {
  width: 100%;
  min-height: 34px;
  padding: 6px 8px;
  font-size: 13px;
}

.session-row button {
  width: auto;
  min-width: 34px;
  min-height: 34px;
  padding: 6px 10px;
  font-size: 12px;
}

.mapping-table {
  display: grid;
  align-content: start;
  gap: 9px;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding-right: 3px;
}

.mapping-row {
  display: grid;
  grid-template-columns: minmax(130px, 0.76fr) minmax(150px, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid rgba(216, 224, 236, 0.92);
  border-radius: 8px;
  background: #fff;
  font-size: 13.5px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.025);
}

.mapping-row-missing {
  border-color: rgba(214, 69, 69, 0.54);
  background: rgba(214, 69, 69, 0.045);
}

.mapping-head {
  position: sticky;
  top: 0;
  z-index: 1;
  min-height: 38px;
  background: #f7f9fc;
  color: var(--muted);
  font-weight: 700;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.04);
}

.mapping-row em {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
}

.mapping-row-missing em {
  color: var(--red);
  font-weight: 700;
}

.mapping-row select {
  min-height: 36px;
  padding: 7px 9px;
  font-size: 13px;
}

.import-preview {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  border: 1px solid rgba(216, 224, 236, 0.92);
  border-radius: 8px;
  background: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.import-preview table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.import-preview th,
.import-preview td {
  max-width: 240px;
  padding: 10px 11px;
  border-right: 1px solid #e2e8f2;
  border-bottom: 1px solid #e2e8f2;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.import-preview th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f7f9fc;
  color: #475467;
  font-weight: 740;
}

.import-preview th small {
  display: block;
  max-width: 220px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.import-preview th.preview-missing {
  color: var(--red);
  background: rgba(214, 69, 69, 0.08);
}

.import-preview tbody tr:nth-child(even) {
  background: #fbfcfe;
}

.import-preview tbody tr:hover {
  background: var(--blue-soft);
}

.field {
  display: grid;
  gap: 5px;
  font-size: 13px;
  font-weight: 600;
}

.check-field {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.check-field input {
  width: 16px;
  height: 16px;
  margin: 0;
}

.route-filter {
  display: grid;
  gap: 8px;
}

.route-filter-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

.route-list {
  display: grid;
  gap: 4px;
  max-height: 170px;
  overflow: auto;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.route-filter-item {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  padding: 4px 7px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-weight: 650;
}

.route-filter-item input {
  width: 15px;
  height: 15px;
  margin: 0;
}

.route-filter-item:hover,
.route-filter-item.active {
  border-color: var(--line);
  background: var(--blue-soft);
}

.route-swatch {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7);
}

.route-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.route-count {
  min-width: 26px;
  padding: 2px 6px;
  border-radius: 999px;
  background: #eef2f7;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.routes-head {
  padding-bottom: 4px;
}

.routes-summary strong {
  max-width: 156px;
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.routes-panel {
  display: grid;
  gap: 10px;
}

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

.route-summary-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-width: 0;
  padding: 9px;
  border: 1px solid rgba(216, 224, 236, 0.92);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.025);
}

.route-summary-row[data-route-row] {
  cursor: pointer;
}

.route-summary-row:hover,
.route-summary-row.active {
  border-color: #c8d8f8;
  background: var(--blue-soft);
}

.route-summary-main {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.route-summary-main strong,
.route-summary-main span,
.route-summary-details span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.route-summary-main strong {
  font-size: 13px;
  line-height: 1.35;
}

.route-summary-main span,
.route-summary-details {
  color: var(--muted);
  font-size: 12px;
}

.route-summary-swatch {
  width: 14px;
  height: 14px;
}

.route-summary-meta {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
}

.route-zone-pill {
  min-width: 34px;
  padding: 3px 6px;
  border-radius: 999px;
  color: #fff;
  font-size: 11px;
  font-weight: 760;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.route-summary-details {
  display: grid;
  grid-column: 1 / -1;
  gap: 3px;
}

.route-focus-button {
  grid-column: 1 / -1;
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
}

.route-row-note {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

body[data-active-tab="routes"] .tab-panels,
body[data-active-tab="days"] .tab-panels {
  flex: 1 1 auto;
  min-height: 0;
}

body[data-active-tab="routes"] .tab-panel.active,
body[data-active-tab="days"] .tab-panel.active {
  min-height: 0;
}

body[data-active-tab="routes"] .sidebar,
body[data-active-tab="days"] .sidebar {
  padding: 10px;
  overflow: hidden;
  background: #eef2f7;
}

.routes-workbench,
.days-workbench {
  display: grid;
  height: 100%;
  min-height: 0;
}

.routes-workbench {
  grid-template-rows: var(--routes-top-panel-height, minmax(360px, 1fr)) 7px minmax(260px, 0.9fr);
  gap: 0;
}

.days-workbench {
  grid-template-rows: var(--days-top-panel-height, minmax(260px, 0.9fr)) 7px minmax(240px, 1fr);
  gap: 0;
}

.days-panel-resizer,
.routes-panel-resizer {
  min-height: 7px;
  border-radius: 999px;
  cursor: row-resize;
  background: transparent;
  touch-action: none;
}

.days-panel-resizer::before,
.routes-panel-resizer::before {
  content: "";
  display: block;
  height: 3px;
  margin: 2px 10px;
  border-radius: 999px;
  background: #c8d4e5;
}

.days-panel-resizer:hover::before,
.routes-panel-resizer:hover::before,
body.resizing-days-panels .days-panel-resizer::before,
body.resizing-routes-panels .routes-panel-resizer::before {
  background: var(--blue);
}

body.resizing-days-panels,
body.resizing-routes-panels {
  cursor: row-resize;
  user-select: none;
}

body[data-active-tab="routes"] .routes-head,
body[data-active-tab="routes"] .routes-toolbar,
body[data-active-tab="routes"] .routes-transfer {
  display: none;
}

.routes-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 8px;
  border: 1px solid #c8d4e5;
  border-radius: 6px;
  background: linear-gradient(#f8fbff, #e8eef7);
}

.routes-head h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.routes-head .hint {
  margin: 2px 0 0;
}

#routes-visible-count {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

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

.routes-toolbar button,
.routes-transfer button {
  min-height: 30px;
  padding: 5px 8px;
  border-radius: 5px;
  font-size: 12px;
}

.routes-summary {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  padding: 6px;
}

.routes-summary .summary-row {
  display: grid;
  gap: 2px;
  min-height: 42px;
  padding: 5px 6px;
  border: 1px solid #d9e2ef;
  border-radius: 5px;
  background: #fff;
}

.routes-summary .summary-row span {
  font-size: 11px;
}

.routes-summary .summary-row strong {
  font-size: 16px;
  line-height: 1;
}

.routes-head-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  min-width: 0;
}

.routes-head-actions > * {
  flex: 0 0 auto;
}

.routes-stops-panel > .section-head {
  grid-template-columns: auto minmax(0, 1fr);
}

.routes-stops-panel .routes-head-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto auto;
  width: 100%;
}

.routes-stops-panel .routes-head-actions .manual-point-open,
.routes-stops-panel .routes-head-actions .bulk-client-editor-toggle {
  width: auto;
  min-width: 0;
  min-height: 30px;
}

.routes-routes-panel > .section-head {
  grid-template-columns: auto auto;
  justify-content: start;
  gap: 10px;
}

.days-head-actions {
  flex-wrap: wrap;
}

@media (max-width: 900px) {
  .routes-stops-panel .routes-head-actions {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

.mileage-panel-left {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.mileage-panel-left h3 {
  margin: 0;
}

.routes-head-actions span {
  min-width: 0;
  max-width: 160px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.route-table-update-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  color: #334155;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
}

.routes-head-actions .route-table-update-toggle span {
  max-width: 68px;
}

.routes-routes-panel .routes-head-actions .route-table-update-toggle span {
  max-width: 52px;
}

.route-table-update-toggle input {
  width: 14px;
  height: 14px;
  margin: 0;
}

.route-table-update-toggle span {
  max-width: none;
}

.route-add-button,
.route-action-button {
  width: auto;
  min-width: 72px;
  min-height: 28px;
  padding: 4px 6px;
  font-size: 11px;
  white-space: nowrap;
}

.route-action-button {
  min-width: 118px;
}

#routes-delete-empty {
  min-width: 72px;
}

.routes-routes-panel .mileage-panel-left {
  grid-template-columns: max-content minmax(0, 1fr);
  column-gap: clamp(18px, 1.4vw, 24px);
}

.routes-routes-panel .mileage-tab-quick {
  grid-template-columns: minmax(66px, max-content) minmax(0, 1fr);
  gap: 4px;
  padding: 3px;
}

.routes-routes-panel .mileage-tab-quick .mileage-preset-grid {
  grid-template-columns: repeat(5, 38px);
  gap: 3px;
}

.routes-routes-panel .mileage-tab-quick .mileage-preset-button {
  width: 38px;
  min-width: 38px;
  min-height: 34px;
}

.routes-routes-panel .mileage-tab-quick .mileage-preset-icon {
  width: 30px;
  height: 30px;
}

.routes-routes-panel .route-add-button,
.routes-routes-panel #routes-delete-empty {
  min-width: 64px;
}

.routes-routes-panel .route-action-button {
  min-width: 110px;
}

.routes-routes-panel #routes-delete-empty {
  min-width: 64px;
}

.routes-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 5px;
  min-height: 0;
  padding: 7px;
  border-color: #c8d4e5;
  border-radius: 6px;
  background: #f8fafc;
}

.routes-routes-panel {
  grid-template-rows: auto minmax(180px, 1fr);
}

.route-search-field {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.route-search-field input {
  min-height: 30px;
  padding: 5px 8px;
  font-size: 12px;
}

.routes-grid {
  min-height: 0;
  overflow: auto;
  border: 1px solid #bfcbdc;
  border-radius: 4px;
  background: #fff;
}

.routes-routes-panel .routes-grid {
  min-height: 180px;
}

.routes-stops-panel .routes-grid {
  min-height: 190px;
}

.routes-stops-panel {
  grid-template-rows: auto minmax(170px, 1fr) auto;
}

.days-days-panel {
  grid-template-rows: auto auto minmax(210px, 1fr);
}

.days-clients-panel {
  grid-template-rows: auto minmax(170px, 1fr) auto;
}

.days-route-field {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.days-route-field select {
  min-height: 30px;
  padding: 5px 8px;
  font-size: 12px;
}

.route-actions-cell button {
  width: auto;
  min-height: 24px;
  padding: 3px 7px;
  border-radius: 4px;
  font-size: 11px;
}

.routes-data-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  color: var(--text);
  font-size: 13px;
}

.routes-data-table th,
.routes-data-table td {
  max-width: none;
  padding: 4px 5px;
  border-right: 1px solid #e1e7f0;
  border-bottom: 1px solid #dfe7f2;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.routes-data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: linear-gradient(#f8fbff, #e7edf6);
  color: #344054;
  font-size: 12px;
  font-weight: 760;
}

.routes-data-table th,
.client-table th,
.import-preview th {
  gap: 6px;
  padding-right: 10px;
}

.routes-data-table th > span,
.client-table th > span {
  display: inline-block;
  max-width: calc(100% - 18px);
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

.routes-data-table th:not(.has-filter) > span {
  max-width: calc(100% - 6px);
}

.routes-data-table th.sortable {
  cursor: pointer;
  user-select: none;
}

.column-resize-handle {
  position: absolute;
  top: 0;
  right: -3px;
  z-index: 4;
  width: 7px;
  height: 100%;
  cursor: col-resize;
  touch-action: none;
}

.column-resize-handle:hover,
body.resizing-column .column-resize-handle {
  background: rgba(37, 99, 235, 0.18);
}

body.resizing-column {
  cursor: col-resize;
  user-select: none;
}

.routes-data-table th.drag-over,
.client-table th.drag-over {
  background: #dbeafe;
  box-shadow: inset 0 0 0 2px rgba(37, 99, 235, 0.28);
}

.routes-data-table td {
  overflow: hidden;
  text-overflow: ellipsis;
}

.routes-data-table tr[data-route-row],
.routes-data-table tr[data-route-stop],
.routes-data-table tr[data-days-route-summary],
.routes-data-table tr[data-day-row],
.routes-data-table tr[data-day-stop] {
  cursor: pointer;
}

.routes-data-table tr:hover td,
.routes-data-table tr.selected td {
  background: var(--blue-soft);
}

.routes-data-table tr.row-selected td {
  background: #dbeafe;
  box-shadow: inset 0 1px 0 rgba(37, 99, 235, 0.18), inset 0 -1px 0 rgba(37, 99, 235, 0.18);
}

.routes-data-table tr.day-checked td {
  background: rgba(255, 255, 255, 0.58);
}

.routes-data-table tr.day-unchecked td {
  color: #667085;
  background: #f2f4f7;
}

.routes-data-table tr.day-week-row td {
  background: #e5e7eb;
  font-weight: 680;
}

.routes-data-table tr.day-week-row.day-checked td {
  background: #f1f5f9;
}

.routes-data-table tr.day-week-row.day-partial td {
  background: #eef4ff;
}

.routes-data-table tr.days-route-summary-row td {
  background: #edf4ff;
  font-weight: 720;
}

.routes-data-table tr.days-route-summary-row:hover td {
  background: #e3efff;
}

.routes-data-table tr.days-route-summary-row.row-selected td {
  background: #dbeafe;
  box-shadow: inset 0 1px 0 rgba(37, 99, 235, 0.34), inset 0 -1px 0 rgba(37, 99, 235, 0.34);
}

.routes-data-table tr.days-route-summary-row:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: -2px;
}

.days-route-summary-label {
  display: block;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.routes-data-table tr.route-supervisor-row td {
  background: #e8f0fe;
  font-weight: 680;
}

.routes-data-table tr.route-supervisor-row.route-partial td {
  background: #eef4ff;
}

.routes-data-table tr.route-supervisor-child-row td:not(.route-mismatch-cell) {
  background: rgba(255, 255, 255, 0.68);
}

.routes-data-table tr.route-no-supervisor-divider td {
  background: #fff7ed;
  border-top: 3px solid #f97316;
  color: #9a3412;
  font-weight: 700;
}

.routes-data-table tr.day-child-row td {
  font-weight: 400;
}

.routes-data-table tr.drag-over td {
  background: rgba(37, 99, 235, 0.14);
  box-shadow: inset 0 0 0 2px rgba(37, 99, 235, 0.28);
}

.route-table-route {
  display: inline-grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  max-width: 240px;
}

.route-table-route strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.route-table-supervisor {
  grid-template-columns: auto auto minmax(0, 1fr);
}

.route-table-color {
  display: inline-block;
  width: 42px;
  height: 20px;
  border: 1px solid #9fb0c7;
  border-radius: 2px;
  vertical-align: middle;
}

.day-table-day {
  display: inline-grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  min-width: 96px;
}

.day-table-day strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.day-table-week {
  display: inline-grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  min-width: 128px;
}

.day-table-week strong {
  white-space: nowrap;
}

.day-week-toggle {
  width: 18px;
  min-width: 18px;
  height: 20px;
  min-height: 20px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #475467;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}

.day-week-spacer,
.day-child-indent {
  display: inline-block;
  width: 18px;
  min-width: 18px;
}

.day-table-color,
.day-color-input {
  display: inline-block;
  width: 54px;
  height: 21px;
  border: 1px solid #9fb0c7;
  border-radius: 2px;
  vertical-align: middle;
}

.day-color-input {
  min-width: 54px;
  min-height: 21px;
  padding: 0;
  cursor: pointer;
}

.day-color-input::-webkit-color-swatch-wrapper {
  padding: 0;
}

.day-color-input::-webkit-color-swatch {
  border: 0;
  border-radius: 1px;
}

.day-table-color.readonly {
  cursor: default;
}

.day-load-bar {
  position: relative;
  display: inline-block;
  width: 132px;
  height: 24px;
  min-width: 132px;
  overflow: hidden;
  border: 1px solid #d8e3f0;
  border-radius: 5px;
  background: #f8fafc;
  vertical-align: middle;
}

.day-load-axis {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 50%;
  border-left: 1px dashed #64748b;
  transform: translateX(-.5px);
}

.day-load-fill {
  position: absolute;
  top: 5px;
  bottom: 5px;
  border-radius: 999px;
  opacity: .9;
}

.day-load-bar.over .day-load-fill {
  left: 50%;
}

.day-load-bar.under .day-load-fill {
  right: 50%;
}

.day-load-text {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 0 6px;
  color: #1f2937;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.92);
  white-space: nowrap;
  pointer-events: none;
}

.day-load-settings-modal {
  width: min(420px, calc(100vw - 28px));
}

.day-load-settings-modal label {
  display: grid;
  gap: 5px;
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
}

.day-load-settings-modal input {
  min-height: 34px;
}

.routes-data-table td.route-mismatch-cell {
  background: #fff3bf;
  color: #7a4f00;
  font-weight: 700;
}

.day-stop-visits {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 46px;
  padding: 3px 7px;
  border-radius: 999px;
  font-weight: 700;
}

.day-stop-visits.yellow {
  background: rgba(211, 145, 0, 0.14);
  color: #7a4f00;
}

.day-stop-visits.red {
  background: rgba(229, 72, 77, 0.14);
  color: #9f1d24;
}

.route-row-checkbox {
  width: 16px;
  height: 16px;
  min-height: 0;
  margin: 0;
}

.route-row-checkbox.mileage-missing {
  outline: 2px solid #e5484d;
  outline-offset: 2px;
}

.route-name-input {
  width: 150px;
  min-width: 120px;
  min-height: 27px;
  padding: 3px 6px;
  border-radius: 4px;
  font-size: 13px;
}

.route-color-input {
  width: 34px;
  min-width: 34px;
  height: 26px;
  min-height: 26px;
  padding: 2px;
  border-radius: 6px;
  cursor: pointer;
}

.routes-stops-table {
  width: max-content;
  min-width: 100%;
}

.routes-stops-table [data-column-key="address"],
.route-address-cell {
  min-width: 300px;
  max-width: 520px;
}

.routes-stops-table td[data-column-key="address"] {
  overflow: hidden;
  text-overflow: ellipsis;
}

.route-zone-count {
  display: inline-block;
  min-width: 20px;
  padding: 2px 5px;
  border-radius: 5px;
  color: #fff;
  text-align: center;
  font-size: 11px;
  font-weight: 760;
  font-variant-numeric: tabular-nums;
}

.route-zone-count.green,
.route-zone-pill.green {
  background: var(--green);
}

.route-zone-count.yellow,
.route-zone-pill.yellow {
  background: #d99a00;
}

.route-zone-count.red,
.route-zone-pill.red {
  background: var(--red);
}

.routes-transfer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px;
}

.routes-transfer select {
  min-height: 32px;
  padding: 6px 9px;
  font-size: 12px;
}

.routes-transfer button {
  width: auto;
  min-width: 104px;
}

.map-selection-info {
  position: absolute;
  left: 14px;
  bottom: 72px;
  z-index: 1100;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  width: max-content;
  max-width: calc(100% - 28px);
  padding: 7px 10px;
  border: 1px solid rgba(31, 41, 51, 0.14);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 12px 32px rgba(31, 41, 51, 0.16);
  backdrop-filter: blur(8px);
  pointer-events: none;
  user-select: none;
}

.map-selection-metric {
  min-width: 0;
  text-align: center;
}

.map-selection-metric > span {
  display: block;
  color: var(--muted);
  white-space: nowrap;
  font-size: 11px;
  line-height: 1.15;
}

.map-selection-metric > strong {
  display: block;
  margin-top: 2px;
  color: var(--text);
  white-space: nowrap;
  font-size: 15px;
  line-height: 1.1;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.map-selection-value {
  display: flex !important;
  justify-content: center;
  gap: 4px;
}

#routes-map-selection-workload-title,
#routes-map-selection-fte-metric > span {
  pointer-events: auto;
  cursor: help;
}

.route-day-strip {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 4px;
}

.route-day-strip span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  min-width: 0;
  min-height: 26px;
  padding: 4px 6px;
  border: 1px solid #dde5f0;
  border-radius: 6px;
  background: #fff;
  color: #526174;
  font-size: 11px;
}

.route-day-strip strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.selected-visits-panel {
  display: grid;
  gap: 3px;
  min-height: 58px;
  padding: 5px 7px;
  border: 1px solid #c8d4e5;
  border-radius: 6px;
  background: #fff;
}

.selected-visits-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
}

.selected-visits-head strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-visits-weeks {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  align-items: start;
  gap: 7px;
}

.selected-visits-plan {
  display: grid;
  gap: 2px;
  align-self: stretch;
  min-width: 0;
  padding: 4px 6px;
  border: 1px solid #dbe3ee;
  border-radius: 5px;
  background: #f8fafc;
  color: #526174;
  font-size: 11px;
  font-weight: 760;
}

.selected-visits-week-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 8px;
  min-width: 0;
}

.selected-visits-plan.green {
  border-color: rgba(22, 163, 109, 0.32);
  background: rgba(22, 163, 109, 0.08);
}

.selected-visits-plan.yellow {
  border-color: rgba(211, 145, 0, 0.34);
  background: rgba(211, 145, 0, 0.1);
}

.selected-visits-plan.red {
  border-color: rgba(229, 72, 77, 0.34);
  background: rgba(229, 72, 77, 0.1);
}

.selected-visit-week {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 4px;
  min-width: 0;
  align-content: start;
}

.selected-visit-week-title {
  color: #526174;
  font-size: 10px;
  font-weight: 760;
  white-space: nowrap;
}

.selected-visit-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(17px, 1fr));
  gap: 2px;
}

.selected-visit-day {
  min-width: 0;
  min-height: 18px;
  padding: 1px 2px;
  border: 1px solid #dbe3ee;
  border-radius: 4px;
  background: #f8fafc;
  color: #7a8797;
  font-size: 10px;
  line-height: 14px;
  text-align: center;
  font-size: 11px;
  font-weight: 680;
}

.selected-visit-day.active.green {
  border-color: rgba(22, 163, 109, 0.34);
  background: rgba(22, 163, 109, 0.12);
  color: #10724f;
}

.selected-visit-day.active.yellow {
  border-color: rgba(211, 145, 0, 0.38);
  background: rgba(211, 145, 0, 0.14);
  color: #8a5d00;
}

.selected-visit-day.active.red {
  border-color: rgba(229, 72, 77, 0.38);
  background: rgba(229, 72, 77, 0.14);
  color: #b42328;
}

.route-map-badge {
  padding: 2px 4px;
  border: 0 !important;
  border-radius: 4px;
  background: rgba(17, 24, 39, 0.88);
  color: #fff;
  box-shadow: none;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
}

.route-map-badge::before {
  display: none;
}

.leaflet-mileage-label-pane,
.mileage-order-marker,
.mileage-order-marker * {
  pointer-events: none !important;
}

.mileage-order-marker span {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
  height: 20px;
  padding: 0 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.92);
  color: #ffffff;
  box-shadow: 0 5px 14px rgba(15, 23, 42, 0.28);
  font-size: 12px;
  font-weight: 800;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  line-height: 1;
  white-space: nowrap;
}

select,
input[type="number"],
input[type="text"],
input[type="file"],
button {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

select,
input[type="number"],
input[type="text"],
input[type="file"] {
  padding: 8px 10px;
  box-shadow: inset 0 1px 1px rgba(15, 23, 42, 0.03);
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

select:hover,
input[type="number"]:hover,
input[type="text"]:hover,
input[type="file"]:hover {
  border-color: var(--line-strong);
}

select:focus,
input[type="number"]:focus,
input[type="text"]:focus,
input[type="file"]:focus,
button:focus-visible {
  outline: none;
  border-color: rgba(37, 99, 235, 0.78);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

button {
  cursor: pointer;
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
  font-weight: 720;
  box-shadow: 0 6px 14px rgba(37, 99, 235, 0.18);
  transition: transform 120ms ease, box-shadow 160ms ease, background 160ms ease, border-color 160ms ease;
}

button:hover:not(:disabled) {
  background: #1d55d6;
  border-color: #1d55d6;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.24);
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button.secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--line);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

button.secondary:hover:not(:disabled) {
  background: #f8fafc;
  border-color: var(--line-strong);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

button.danger {
  color: var(--red);
}

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

.load-progress {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid rgba(216, 224, 236, 0.86);
  border-radius: 8px;
  background: #f8fafc;
  box-shadow: var(--shadow-soft);
}

.load-progress[hidden] {
  display: none;
}

.load-progress-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
}

.load-progress-top strong {
  color: var(--text);
  font-size: 12px;
}

.load-progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7edf3;
}

.load-progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
  transition: width 180ms ease;
}

.legend-item,
.summary-row,
.client-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.zone-drop {
  padding: 8px;
  border: 1px dashed transparent;
  border-radius: 6px;
}

.zone-drop:hover {
  border-color: var(--blue);
  background: #f3f7ff;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex: 0 0 auto;
}

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

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

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

.legend-label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.client-list {
  max-height: 340px;
  overflow: auto;
  border: 1px solid rgba(216, 224, 236, 0.9);
  border-radius: 8px;
  background: #fff;
}

.client-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.client-table th,
.client-table td {
  max-width: 180px;
  min-width: 96px;
  padding: 6px 8px;
  border-right: 1px solid #e2e8f2;
  border-bottom: 1px solid #e2e8f2;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.client-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f7f9fc;
  color: #475467;
  font-weight: 740;
}

.table-filter-button {
  float: right;
  width: 16px;
  min-width: 16px;
  height: 18px;
  min-height: 18px;
  margin-left: 2px;
  padding: 0;
  border: 1px solid #c8d4e5;
  border-radius: 4px;
  background: #fff;
  color: #475467;
  font-size: 12px;
  line-height: 16px;
}

.table-filter-button:hover,
.table-filter-button.active {
  border-color: var(--blue);
  background: #eef4ff;
  color: var(--blue);
}

.table-filter-menu {
  position: fixed;
  z-index: 5000;
  display: flex;
  flex-direction: column;
  width: 282px;
  max-width: calc(100vw - 16px);
  max-height: calc(100vh - 16px);
  padding: 8px;
  overflow: hidden;
  border: 1px solid #b8c6d8;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 16px 34px rgba(31, 41, 51, 0.22);
  color: var(--text);
  font-size: 12px;
}

.table-filter-title {
  margin-bottom: 6px;
  overflow: hidden;
  color: #344054;
  font-weight: 760;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-filter-menu button {
  width: 100%;
  min-height: 28px;
  margin-bottom: 4px;
  padding: 4px 8px;
  justify-content: flex-start;
  border-radius: 4px;
  font-size: 12px;
}

.table-filter-menu .table-filter-search {
  width: 100%;
  min-height: 28px;
  margin: 4px 0;
  padding: 4px 7px;
  border-radius: 4px;
  font-size: 12px;
}

.table-filter-values {
  flex: 1 1 auto;
  min-height: 48px;
  max-height: 210px;
  overflow: auto;
  margin: 4px 0 8px;
  border: 1px solid #e1e7f0;
  border-radius: 4px;
  background: #fbfcfe;
}

.table-filter-check {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  min-height: 26px;
  margin: 0;
  padding: 4px 7px;
  color: #344054;
}

.table-filter-check:hover {
  background: #eef4ff;
}

.table-filter-check input {
  width: 14px;
  min-width: 14px;
  height: 14px;
  min-height: 14px;
  margin: 0;
}

.table-filter-check span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-filter-check small {
  color: var(--muted);
  font-size: 11px;
}

.table-filter-check-all {
  border-top: 1px solid #eef2f7;
  border-bottom: 1px solid #eef2f7;
  background: #f8fafc;
}

.table-filter-menu footer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.table-filter-menu footer button {
  justify-content: center;
  margin-bottom: 0;
}

.client-table tbody tr {
  cursor: pointer;
}

.client-table tbody tr:nth-child(even) {
  background: #fbfcfe;
}

.client-table tbody tr:hover {
  background: var(--blue-soft);
}

.client-table-note {
  padding: 6px 8px;
}

.client-table tbody tr.selected {
  background: #eef4ff;
  outline: 1px solid #d6e4ff;
  outline-offset: -1px;
}
.badge {
  min-width: 70px;
  padding: 5px 9px;
  border-radius: 999px;
  color: #fff;
  text-align: center;
  font-size: 12px;
  font-weight: 760;
}

#map {
  position: relative;
  z-index: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.leaflet-control-attribution {
  max-width: min(72vw, 520px);
  margin: 0 8px 8px 0 !important;
  padding: 4px 8px !important;
  overflow: hidden;
  border: 1px solid rgba(15, 23, 42, .14);
  border-radius: 6px;
  background: rgba(255, 255, 255, .9) !important;
  color: #475467;
  font-size: 10px !important;
  line-height: 1.25 !important;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(15, 23, 42, .12);
  backdrop-filter: blur(6px);
}

.leaflet-control-attribution a {
  color: #174ea6;
  text-decoration: none;
}

.leaflet-control-attribution a:hover,
.leaflet-control-attribution a:focus-visible {
  color: #0f3c82;
  text-decoration: underline;
}

.yandex-map-brand {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 8px 6px 0 !important;
}

.yandex-map-logo-link {
  position: relative;
  display: block;
  width: 76px;
  height: 30px;
  overflow: hidden;
  border: 1px solid rgba(15, 23, 42, .14);
  border-radius: 7px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, .12);
}

.yandex-map-logo {
  position: absolute;
  top: -26px;
  left: -3px;
  width: 82px;
  height: 82px;
  max-width: none;
  filter: none !important;
}

.yandex-map-open-link {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  border: 1px solid rgba(15, 23, 42, .14);
  border-radius: 7px;
  background: rgba(255, 255, 255, .94);
  color: #174ea6;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(15, 23, 42, .12);
  backdrop-filter: blur(6px);
}

.yandex-map-open-link:hover,
.yandex-map-open-link:focus-visible {
  border-color: rgba(15, 23, 42, .28);
  background: #fff;
  color: #0f3c82;
}

.map-stage {
  position: relative;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  container-type: inline-size;
  container-name: map-stage;
}

.bulk-client-editor {
  position: absolute;
  inset: 0;
  z-index: 3200;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 10px;
  min-width: 0;
  min-height: 0;
  padding: 16px;
  overflow: hidden;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #0f172a;
  outline: none;
}

.bulk-client-editor[hidden] {
  display: none;
}

.bulk-client-editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.bulk-client-editor-head > div {
  min-width: 0;
}

.bulk-client-editor h2,
.bulk-client-editor h3,
.bulk-client-editor p {
  margin: 0;
}

.bulk-client-editor h2 {
  font-size: 19px;
}

.bulk-client-editor-head p,
.bulk-client-editor-hint {
  margin-top: 4px;
  color: #475569;
  font-size: 12px;
  line-height: 1.4;
}

.bulk-client-editor-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
  gap: 12px;
  min-height: 0;
  overflow: auto;
}

.bulk-client-editor-column {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  padding: 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
}

.bulk-client-editor-column h3 {
  font-size: 15px;
}

.bulk-client-drop-target {
  display: grid;
  gap: 6px;
  min-height: 76px;
  padding: 10px;
  border: 1px dashed #94a3b8;
  border-radius: 8px;
  background: #f8fafc;
  transition: border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
}

.bulk-client-drop-target > span {
  color: #334155;
  font-size: 12px;
  font-weight: 700;
}

.bulk-client-drop-target small {
  color: #64748b;
  font-size: 11px;
  line-height: 1.35;
}

.bulk-client-drop-target input,
.bulk-client-drop-target textarea {
  width: 100%;
  min-height: 44px;
}

.bulk-client-drop-target textarea {
  min-height: 150px;
  resize: vertical;
  white-space: pre-wrap;
}

.bulk-client-presets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(52px, 1fr));
  gap: 6px;
}

.bulk-client-presets button {
  min-width: 0;
  min-height: 44px;
  padding: 6px;
  border-color: #cbd5e1;
  background: #fff;
  color: #1e293b;
  font-weight: 700;
}

.bulk-client-drop-target.drag-over,
.bulk-client-presets button.drag-over {
  border-color: #2f6fed;
  background: #eaf1ff;
  box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.18);
}

.bulk-client-apply {
  margin-top: auto;
}

.bulk-client-comment-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
}

.bulk-client-comment-actions button {
  flex: 1 1 150px;
}

.bulk-client-geocode-target {
  align-content: center;
  min-height: 110px;
}

.bulk-client-geocode-target strong {
  font-size: 13px;
}

.bulk-client-geocode-column progress {
  width: 100%;
  min-height: 16px;
}

.bulk-client-geocode-status {
  min-height: 58px;
  color: #475569;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.bulk-client-editor[aria-busy="true"] [aria-disabled="true"],
.bulk-client-editor[aria-busy="true"] :disabled:not(#bulk-client-geocode-stop) {
  cursor: not-allowed;
  opacity: 0.58;
}

.bulk-client-editor-toggle {
  min-height: 28px;
  padding: 4px 9px;
  font-size: 11px;
  white-space: nowrap;
}

@container map-stage (max-width: 820px) {
  .bulk-client-editor-columns {
    grid-template-columns: 1fr;
  }

  .bulk-client-editor {
    padding: 12px;
  }

  .bulk-client-editor-head {
    flex-wrap: wrap;
  }
}

html[data-theme="dark"] .bulk-client-editor {
  border-color: #475569;
  background: #0f172a;
  color: #e2e8f0;
}

html[data-theme="dark"] .bulk-client-editor-column,
html[data-theme="dark"] .bulk-client-presets button {
  border-color: #475569;
  background: #172033;
  color: #e2e8f0;
}

html[data-theme="dark"] .bulk-client-drop-target {
  border-color: #64748b;
  background: #111c2e;
}

html[data-theme="dark"] .bulk-client-editor-head p,
html[data-theme="dark"] .bulk-client-editor-hint,
html[data-theme="dark"] .bulk-client-drop-target small,
html[data-theme="dark"] .bulk-client-geocode-status {
  color: #aebed3;
}

html[data-theme="dark"] .bulk-client-drop-target > span {
  color: #dbe7f5;
}

html[data-theme="dark"] .bulk-client-drop-target.drag-over,
html[data-theme="dark"] .bulk-client-presets button.drag-over {
  border-color: #78a6ff;
  background: #1d3766;
}

.map-tools {
  position: absolute;
  top: 0;
  left: 50%;
  z-index: 1100;
  display: flex;
  flex-direction: row;
  gap: 8px;
  width: 196px;
  max-width: calc(100% - 28px);
  padding: 8px 10px 10px;
  border: 1px solid rgba(31, 41, 51, 0.12);
  border-top: 0;
  border-radius: 0 0 8px 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 26px rgba(31, 41, 51, 0.16);
  backdrop-filter: blur(8px);
  transform: translateX(-50%);
  transition: width 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.map-tools:hover,
.map-tools:focus-within {
  width: 520px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 14px 34px rgba(31, 41, 51, 0.2);
}

.zone-tools {
  position: absolute;
  bottom: 0;
  left: 50%;
  z-index: 1100;
  display: flex;
  flex-direction: row;
  gap: 8px;
  width: 210px;
  max-width: calc(100% - 28px);
  padding: 10px 12px 9px;
  border: 1px solid rgba(31, 41, 51, 0.12);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 -10px 26px rgba(31, 41, 51, 0.14);
  backdrop-filter: blur(8px);
  transform: translateX(-50%);
  transition: width 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.zone-tools:hover,
.zone-tools:focus-within,
.zone-tools:has(.zone-drop.drag-over) {
  width: 420px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 -14px 34px rgba(31, 41, 51, 0.18);
}

body[data-active-tab="routes"] .zone-tools,
body[data-active-tab="days"] .zone-tools {
  display: none;
}

.days-map-tools {
  position: absolute;
  bottom: 0;
  left: 50%;
  z-index: 1100;
  display: none;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 28px);
  padding: 10px 12px 9px;
  border: 1px solid rgba(31, 41, 51, 0.12);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 -10px 26px rgba(31, 41, 51, 0.14);
  backdrop-filter: blur(8px);
  transform: translateX(-50%);
}

body[data-active-tab="days"] .days-map-tools {
  display: flex;
}

@container map-stage (max-width: 620px) {
  .map-tools,
  .map-tools:hover,
  .map-tools:focus-within {
    left: 12px;
    width: 196px;
    transform: none;
  }

  .days-map-tools {
    max-width: calc(100% - 24px);
    overflow-x: auto;
  }

}

.days-map-switches {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 0 0 auto;
  padding-right: 10px;
  border-right: 1px solid rgba(31, 41, 51, 0.12);
}

.days-map-switches .map-switch {
  flex: 0 0 auto;
  white-space: nowrap;
}

.days-map-drop-list {
  display: flex;
  align-items: center;
  gap: 6px;
}

.days-map-drop {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px dashed color-mix(in srgb, var(--day-drop-color, var(--blue)) 72%, #1f2933 28%);
  border-radius: 8px;
  background: color-mix(in srgb, var(--day-drop-color, var(--blue)) 88%, #ffffff 12%);
  color: #0f172a;
  font-size: 13px;
  font-weight: 800;
  cursor: default;
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease, transform 120ms ease;
}

.days-map-drop:hover,
.days-map-drop.drag-over {
  border-color: color-mix(in srgb, var(--day-drop-color, var(--blue)) 70%, #0f172a 30%);
  background: color-mix(in srgb, var(--day-drop-color, var(--blue)) 78%, #ffffff 22%);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--day-drop-color, var(--blue)) 28%, transparent);
  transform: translateY(-1px);
}

.map-layer-panel {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid rgba(31, 41, 51, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 26px rgba(31, 41, 51, 0.16);
  backdrop-filter: blur(8px);
}

.map-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-start;
  color: var(--text);
  font-size: 12px;
  font-weight: 760;
  white-space: nowrap;
}

.mileage-map-switch {
  display: none;
}

body[data-active-tab="days"] .mileage-map-switch {
  display: inline-flex;
}

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

.map-switch-ui {
  position: relative;
  width: 38px;
  height: 20px;
  border-radius: 999px;
  background: #cbd5e1;
  transition: background 160ms ease;
}

.map-switch-ui::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.24);
  transition: transform 160ms ease;
}

.map-switch input:checked + .map-switch-ui {
  background: var(--blue);
}

.map-switch input:checked + .map-switch-ui::after {
  transform: translateX(18px);
}

.map-switch input:focus-visible + .map-switch-ui {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

.map-switch input:disabled + .map-switch-ui {
  opacity: 0.55;
}

.map-tool-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  width: 40px;
  flex: 1 1 40px;
  min-width: 36px;
  min-height: 38px;
  overflow: hidden;
  padding: 8px 9px;
  border-radius: 8px;
  white-space: nowrap;
}

.map-tools:hover .map-tool-button,
.map-tools:focus-within .map-tool-button {
  gap: 10px;
}

.map-tool-button.active {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.tool-icon {
  position: relative;
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  color: currentColor;
}

.lasso-icon {
  border: 2px dashed currentColor;
  border-radius: 45% 55% 50% 42%;
  transform: rotate(-10deg);
}

.ruler-icon {
  height: 7px;
  margin-top: 5px;
  border: 2px solid currentColor;
  border-radius: 3px;
  transform: rotate(-12deg);
}

.ruler-icon::before {
  content: "";
  position: absolute;
  inset: 1px 3px 1px 3px;
  background:
    linear-gradient(90deg, currentColor 0 1px, transparent 1px 4px) left center / 4px 100% repeat-x;
  opacity: 0.9;
}

.route-planner-icon svg {
  display: block;
  width: 20px;
  height: 20px;
}

.clear-icon::before,
.clear-icon::after {
  content: "";
  position: absolute;
  top: 8px;
  left: 2px;
  width: 14px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.clear-icon::before {
  transform: rotate(45deg);
}

.clear-icon::after {
  transform: rotate(-45deg);
}

.tool-label {
  max-width: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-width 160ms ease, opacity 120ms ease;
}

.map-tools:hover .tool-label,
.map-tools:focus-within .tool-label {
  max-width: 130px;
  opacity: 1;
}

.map-planner-panel {
  position: absolute;
  top: 80px;
  left: 14px;
  z-index: 1110;
  display: grid;
  gap: 10px;
  width: min(336px, calc(100% - 28px));
  max-height: calc(100% - 94px);
  overflow-y: auto;
  padding: 12px;
  border: 1px solid rgba(31, 41, 51, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 12px 30px rgba(31, 41, 51, 0.18);
  backdrop-filter: blur(8px);
}

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

.map-planner-route-controls[hidden],
.map-planner-alternatives[hidden],
.map-planner-route-details[hidden],
#map-planner-time-row[hidden] {
  display: none;
}

.map-planner-head,
.map-planner-row,
.map-planner-route-controls,
.map-planner-metrics {
  display: flex;
  align-items: center;
}

.map-planner-head {
  justify-content: space-between;
  gap: 10px;
}

.map-planner-head > div:first-child {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.map-planner-head strong {
  font-size: 14px;
  line-height: 1.2;
}

.map-planner-head span,
.map-planner-point-text span,
.map-planner-metrics dt,
.map-planner-speed span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.map-planner-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.map-planner-icon-button {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  font-size: 17px;
  line-height: 1;
}

.map-planner-icon-button:hover,
.map-planner-icon-button:focus-visible {
  border-color: var(--blue);
  color: var(--blue);
}

.map-planner-points {
  display: grid;
  gap: 7px;
}

.map-planner-address-attribution {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.2;
}

.map-planner-address-attribution[hidden] {
  display: none;
}

.map-planner-row {
  gap: 8px;
  min-width: 0;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.map-planner-point-label {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.map-planner-point-text {
  display: grid;
  min-width: 0;
  flex: 1 1 auto;
  gap: 1px;
}

.map-planner-point-text strong,
.map-planner-point-text span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-planner-route-controls {
  justify-content: space-between;
  gap: 8px;
}

.map-planner-alternatives {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.map-planner-option {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  min-width: 0;
  min-height: 42px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  text-align: left;
  box-shadow: none;
}

.map-planner-option:hover,
.map-planner-option:focus-visible {
  border-color: var(--blue);
}

.map-planner-option.selected {
  border-color: var(--blue);
  background: rgba(47, 111, 237, 0.08);
  box-shadow: inset 0 0 0 1px rgba(47, 111, 237, 0.18);
}

.map-planner-option span,
.map-planner-option strong,
.map-planner-option em {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-planner-option span {
  grid-column: 1 / -1;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
}

.map-planner-option strong {
  font-size: 12px;
  line-height: 1.2;
}

.map-planner-option em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  line-height: 1.2;
  text-align: right;
}

.map-planner-route-details {
  display: grid;
  gap: 7px;
}

.map-planner-route-details-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 32px;
  padding: 6px 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  text-align: left;
}

.map-planner-route-details-toggle::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 140ms ease;
}

.map-planner-route-details-toggle[aria-expanded="true"]::after {
  transform: rotate(225deg);
}

.map-planner-route-steps {
  display: grid;
  gap: 7px;
  max-height: 220px;
  margin: 0;
  padding: 0 4px 0 0;
  overflow-y: auto;
  list-style: none;
}

.map-planner-route-steps[hidden] {
  display: none;
}

.map-planner-route-step {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.map-planner-step-icon {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  flex: 0 0 24px;
}

.map-planner-step-icon::before {
  content: "";
  width: 8px;
  height: 8px;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  transform: rotate(-45deg);
}

.map-planner-step-icon.left::before {
  transform: rotate(-135deg);
}

.map-planner-step-icon.right::before {
  transform: rotate(45deg);
}

.map-planner-step-icon.uturn {
  background: #f59e0b;
}

.map-planner-step-icon.uturn::before {
  content: "U";
  width: auto;
  height: auto;
  border: 0;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  transform: none;
}

.map-planner-step-icon.round {
  background: #f59e0b;
}

.map-planner-step-icon.round::before {
  width: 10px;
  height: 10px;
  border: 2px solid currentColor;
  border-left-color: transparent;
  border-radius: 999px;
  transform: rotate(35deg);
}

.map-planner-step-icon.finish {
  background: #dc2626;
}

.map-planner-step-icon.finish::before {
  content: "";
  width: 8px;
  height: 8px;
  border: 2px solid currentColor;
  border-radius: 999px;
  transform: none;
}

.map-planner-step-text,
.map-planner-step-distance {
  min-width: 0;
  font-size: 12px;
  line-height: 1.25;
}

.map-planner-step-text {
  color: var(--text);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.map-planner-step-distance {
  color: var(--muted);
  white-space: nowrap;
}

.map-planner-swap {
  min-height: 32px;
  padding: 6px 9px;
  white-space: nowrap;
}

.map-planner-speed {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-width: 0;
}

.map-planner-speed input {
  width: 62px;
  min-height: 32px;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.map-planner-metrics {
  justify-content: space-between;
  gap: 8px;
  margin: 0;
}

.map-planner-metrics div {
  display: grid;
  flex: 1 1 0;
  min-width: 0;
  gap: 2px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.map-planner-metrics dd {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-planner-marker {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.28);
  font-size: 13px;
  font-weight: 850;
}

.map-planner-marker.b {
  background: var(--green);
}

.leaflet-planner-pane-pane .leaflet-marker-icon {
  pointer-events: auto;
}

.zone-tool {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  width: 56px;
  flex: 1 1 56px;
  min-width: 44px;
  min-height: 38px;
  overflow: hidden;
  padding: 6px 9px;
  border: 1px dashed transparent;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  white-space: nowrap;
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.zone-tools:hover .zone-tool,
.zone-tools:focus-within .zone-tool {
  gap: 10px;
}

.zone-tool[data-zone-drop="green"]:hover,
.zone-tool[data-zone-drop="green"].drag-over {
  border-color: var(--green);
  background: rgba(34, 160, 107, 0.12);
  box-shadow: 0 0 0 3px rgba(34, 160, 107, 0.12);
}

.zone-tool[data-zone-drop="yellow"]:hover,
.zone-tool[data-zone-drop="yellow"].drag-over {
  border-color: var(--yellow);
  background: rgba(217, 154, 0, 0.13);
  box-shadow: 0 0 0 3px rgba(217, 154, 0, 0.13);
}

.zone-tool[data-zone-drop="red"]:hover,
.zone-tool[data-zone-drop="red"].drag-over {
  border-color: var(--red);
  background: rgba(214, 69, 69, 0.12);
  box-shadow: 0 0 0 3px rgba(214, 69, 69, 0.12);
}

.zone-token {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-width: 34px;
  width: auto;
  height: 34px;
  padding: 0 6px;
  border: 2px solid currentColor;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.green-zone {
  color: var(--green);
  background: rgba(34, 160, 107, 0.12);
}

.yellow-zone {
  color: var(--yellow);
  background: rgba(217, 154, 0, 0.14);
}

.red-zone {
  color: var(--red);
  background: rgba(214, 69, 69, 0.12);
}

.zone-tool-label {
  max-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  opacity: 0;
  transition: max-width 160ms ease, opacity 120ms ease;
}

.zone-tools:hover .zone-tool-label,
.zone-tools:focus-within .zone-tool-label {
  max-width: 80px;
  opacity: 1;
}

.hint {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
}

.point-popup {
  display: grid;
  gap: 10px;
  min-width: 280px;
  color: var(--text);
}

.point-popup-compact {
  gap: 8px;
  min-width: 250px;
  max-width: 300px;
}

.point-popup label {
  display: grid;
  gap: 4px;
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.point-popup input,
.point-popup textarea,
.point-popup select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 8px;
  color: var(--text);
  font: 13px Arial, sans-serif;
}

.point-popup-compact input,
.point-popup-compact textarea {
  padding: 5px 7px;
  border-radius: 5px;
  font-size: 12px;
}

.popup-zone-picker {
  position: relative;
}

.point-popup .popup-zone-select,
.popup-zone-option {
  width: auto;
  min-width: 104px;
  min-height: 30px;
  padding: 5px 28px 5px 12px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.point-popup .popup-zone-select {
  position: relative;
  text-align: left;
}

.point-popup .popup-zone-select::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 11px;
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-65%) rotate(45deg);
}

.popup-zone-select.green,
.popup-zone-option.green {
  background-color: var(--green);
}

.popup-zone-select.yellow,
.popup-zone-option.yellow {
  background-color: var(--yellow);
}

.popup-zone-select.red,
.popup-zone-option.red {
  background-color: var(--red);
}

.popup-zone-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 1200;
  display: grid;
  gap: 6px;
  min-width: 150px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(31, 41, 51, 0.18);
}

.popup-zone-menu[hidden] {
  display: none;
}

.popup-zone-option {
  width: 100%;
  padding: 7px 12px;
  text-align: left;
}

.popup-zone-option:hover {
  box-shadow: inset 0 0 0 999px rgba(255, 255, 255, 0.14);
}

.drag-ghost {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  padding: 6px 10px;
  border-radius: 999px;
  background: #1f2933;
  color: #fff;
  font: 12px Arial, sans-serif;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
}

.point-popup textarea {
  resize: vertical;
}

.popup-head,
.popup-grid {
  display: grid;
  gap: 8px;
}

.popup-head {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.popup-title {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.popup-title strong,
.popup-title span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.popup-title span {
  color: var(--muted);
  font-size: 11px;
}

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

.popup-field-head {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

.popup-inline-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 100%;
  gap: 6px;
}

.popup-inline-actions .popup-inline-button {
  width: 100%;
  min-width: 0;
  padding-inline: 6px;
  font-size: 11px;
}

.popup-inline-button {
  width: auto;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
}

.popup-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.point-popup-compact .popup-note {
  max-height: 34px;
  overflow: hidden;
  font-size: 11px;
}

.popup-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.popup-actions button {
  width: 100%;
  min-width: 0;
  min-height: 30px;
  padding: 5px 8px;
  font-size: 12px;
}

@media (max-width: 900px) {
  .map-tools {
    width: 188px;
  }

  .map-tools:hover,
  .map-tools:focus-within {
    width: calc(100% - 28px);
  }

  .map-layer-panel {
    top: 72px;
  }

  .map-planner-panel {
    top: 80px;
    left: 8px;
    width: calc(100% - 16px);
    max-height: calc(100% - 94px);
    padding: 10px;
  }

  .map-planner-route-controls,
  .map-planner-alternatives,
  .map-planner-metrics {
    align-items: stretch;
    flex-direction: column;
  }

  .map-planner-alternatives {
    grid-template-columns: 1fr;
  }

  .map-planner-swap,
  .map-planner-speed {
    width: 100%;
  }

  .map-planner-speed {
    justify-content: space-between;
  }

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

  .workspace {
    height: auto;
    grid-template-columns: 1fr;
    overflow: visible;
  }

  body[data-active-tab="routes"] .workspace {
    grid-template-columns: 1fr;
  }

  .map-selection-info {
    left: 10px;
    bottom: 72px;
  }

  .selected-visits-weeks {
    grid-template-columns: minmax(0, 1fr);
  }

  .selected-visits-week-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .app {
    grid-template-rows: auto 1fr;
  }

  .app-topbar {
    display: grid;
    gap: 8px;
    padding: 10px;
  }

  .app-actions {
    margin-left: 0;
    padding: 0;
    justify-content: space-between;
  }

  .app-title {
    min-width: 0;
  }

  .sidebar {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar-resizer {
    display: none;
  }

  .map-stage,
  #map {
    height: 62vh;
    min-height: 62vh;
  }

  body[data-active-tab="import"] .import-workbench {
    padding: 16px;
  }

  .import-workbench-header,
  .section-head {
    display: grid;
  }

  .import-workbench-actions {
    width: 100%;
    flex-basis: auto;
  }

  .import-workbench-grid,
  .mapping-row {
    grid-template-columns: 1fr;
  }
}

.client-context-menu {
  position: fixed;
  z-index: 2400;
  display: grid;
  min-width: 168px;
  overflow: hidden;
  border: 1px solid rgba(216, 224, 236, 0.95);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 34px rgba(31, 41, 51, 0.2);
}

.client-context-menu button {
  min-height: 34px;
  padding: 7px 12px;
  border: 0;
  border-radius: 0;
  background: #fff;
  color: var(--text);
  box-shadow: none;
  text-align: left;
  font-size: 13px;
  font-weight: 650;
}

.client-context-menu button:hover {
  background: var(--blue-soft);
  color: var(--blue-deep);
}
.route-code-tooltip {
  position: fixed;
  z-index: 2600;
  pointer-events: none;
  padding: 4px 7px;
  border: 1px solid rgba(31, 41, 51, 0.16);
  border-radius: 6px;
  background: rgba(17, 24, 39, 0.92);
  color: #fff;
  box-shadow: 0 8px 18px rgba(31, 41, 51, 0.2);
  font-size: 12px;
  font-weight: 740;
}

.route-code-tooltip.day-route-list {
  max-width: calc(100vw - 16px);
  padding: 7px 9px;
  font-weight: 500;
}

.route-code-tooltip-header {
  margin-bottom: 5px;
  font-weight: 740;
}

.route-code-tooltip-list {
  display: grid;
  grid-auto-flow: column;
  grid-template-columns: repeat(var(--day-route-tooltip-columns, 1), minmax(0, 1fr));
  grid-template-rows: repeat(var(--day-route-tooltip-rows, 1), auto);
  gap: 4px 12px;
}

.route-code-tooltip-row {
  display: grid;
  grid-template-columns: 9px minmax(0, 1fr);
  align-items: start;
  gap: 7px;
}

.route-code-tooltip-dot {
  width: 8px;
  height: 8px;
  margin-top: 4px;
  border: 1px solid rgba(255, 255, 255, .75);
  border-radius: 50%;
}

.route-code-tooltip-label {
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}
.route-context-menu {
  position: fixed;
  z-index: 5000;
  display: grid;
  min-width: 190px;
  padding: 4px;
  border: 1px solid #b8c5d8;
  border-radius: 5px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.18);
}

.route-context-menu button {
  width: 100%;
  min-height: 28px;
  justify-content: flex-start;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 12px;
}

.route-context-menu button:hover {
  background: #eef4ff;
}

.route-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 5100;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.22);
}

.route-modal {
  display: grid;
  gap: 10px;
  width: min(420px, calc(100vw - 28px));
  padding: 12px;
  border: 1px solid #b8c5d8;
  border-radius: 7px;
  background: #fff;
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.22);
}

.route-modal header,
.route-modal footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.icon-button,
.route-modal header .icon-button,
.route-modal footer .icon-button {
  width: 30px;
  min-width: 30px;
  max-width: 30px;
  min-height: 30px;
  padding: 0;
  flex: 0 0 30px;
  line-height: 1;
}

.route-modal header {
  min-width: 0;
}

.route-modal header h3 {
  min-width: 0;
  overflow-wrap: anywhere;
}

.route-modal footer {
  flex-wrap: wrap;
}

.route-modal:not(.mileage-modal):not(.day-calendar-modal) footer > button:not(.icon-button) {
  width: auto;
  min-width: 120px;
  flex: 1 1 120px;
}

.route-modal h3 {
  margin: 0;
  font-size: 16px;
}

.route-modal label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.route-modal input,
.route-modal textarea {
  width: 100%;
  min-height: 32px;
  font-size: 13px;
}

.route-modal textarea {
  resize: vertical;
}

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

.settings-modal {
  width: min(540px, calc(100vw - 28px));
  max-height: min(88vh, 720px);
  gap: 14px;
  padding: 18px;
  overflow-y: auto;
}

.settings-modal header h2 {
  margin: 0;
  font-size: 20px;
}

.settings-theme-toggle {
  width: 100%;
  min-height: 38px;
}

.api-setting {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.api-setting label {
  grid-column: 1 / -1;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.api-setting input[type="password"] {
  width: 100%;
  min-width: 0;
  min-height: 38px;
}

.api-setting-actions {
  display: flex;
  gap: 8px;
}

.api-setting-actions button {
  width: auto;
  min-width: 92px;
}

.api-setting-status {
  grid-column: 1 / -1;
  min-height: 20px;
  margin: 0;
  font-size: 13px;
  font-weight: 750;
}

.api-setting-status.success {
  color: #18835b;
}

.api-setting-status.error {
  color: var(--red);
}

html[data-theme="dark"] .api-setting-status.success {
  color: #4ade80;
}

@media (max-width: 560px) {
  .settings-modal {
    width: calc(100vw - 18px);
    padding: 12px;
  }

  .api-setting {
    grid-template-columns: 1fr;
  }

  .api-setting label,
  .api-setting-status {
    grid-column: 1;
  }

  .api-setting-actions button {
    flex: 1 1 0;
    min-width: 0;
  }
}

.route-modal footer span {
  margin-right: auto;
  color: var(--muted);
  font-size: 12px;
}

.manual-point-backdrop {
  z-index: 1700;
}

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

.manual-point-modal {
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
}

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

.manual-point-grid label {
  display: grid;
  gap: 6px;
}

.manual-point-grid input,
.manual-point-grid select {
  width: 100%;
}

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

.manual-point-address-actions {
  display: flex;
  gap: 8px;
}

.manual-point-map-hint,
.manual-point-error {
  min-height: 20px;
  margin: 0 16px 10px;
}

.manual-point-error {
  color: #ff8b8b;
}

body.manual-point-map-pick .manual-point-backdrop {
  pointer-events: none;
  opacity: 0;
}

body.manual-point-map-pick #map,
body.manual-point-map-pick #map .leaflet-interactive {
  cursor: crosshair !important;
}

#map.is-lasso-tool,
#map.is-lasso-tool * {
  cursor: var(--cursor-lasso) !important;
}

@media (max-width: 700px) {
  .manual-point-grid {
    grid-template-columns: 1fr;
  }

  .manual-point-wide {
    grid-column: auto;
  }
}

.map-day-frequency-modal {
  width: min(720px, calc(100vw - 28px));
  max-height: min(82vh, 760px);
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.map-day-frequency-body {
  display: grid;
  gap: 12px;
  min-height: 0;
  padding: 2px;
  overflow-y: auto;
}

.map-day-frequency-client {
  display: grid;
  gap: 7px;
  min-width: 0;
  margin: 0;
  padding: 10px;
  border: 1px solid rgba(31, 41, 51, 0.14);
  border-radius: 7px;
}

.map-day-frequency-client legend {
  max-width: 100%;
  padding: 0 5px;
  font-size: 13px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.route-modal .map-day-frequency-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 9px;
  padding: 8px;
  border: 1px solid rgba(31, 41, 51, 0.1);
  border-radius: 6px;
  color: inherit;
  cursor: pointer;
}

.route-modal .map-day-frequency-option:has(input:checked) {
  border-color: var(--blue);
  background: rgba(47, 111, 237, 0.07);
}

.route-modal .map-day-frequency-option input {
  width: 16px;
  min-height: 16px;
  margin: 2px 0 0;
}

.map-day-frequency-option span {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.map-day-frequency-option strong,
.map-day-frequency-option small {
  overflow-wrap: anywhere;
}

.map-day-frequency-weekdays {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.map-day-frequency-option .map-day-frequency-weekdays .map-day-frequency-weekday {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border: 1px solid color-mix(in srgb, var(--frequency-day-color) 62%, #52606d);
  border-radius: 999px;
  background: color-mix(in srgb, var(--frequency-day-color) 24%, white);
  color: #172033;
  line-height: 1.25;
}

.map-day-frequency-option small {
  color: var(--muted);
  line-height: 1.35;
}

.route-modal footer .map-day-frequency-error {
  flex: 1 1 100%;
  margin: 0;
  color: #b42318;
  font-weight: 700;
}

html[data-theme="dark"] .map-day-frequency-client,
html[data-theme="dark"] .route-modal .map-day-frequency-option {
  border-color: rgba(226, 232, 240, 0.24);
}

html[data-theme="dark"] .route-modal .map-day-frequency-option:has(input:checked) {
  border-color: #78a6ff;
  background: rgba(120, 166, 255, 0.14);
}

html[data-theme="dark"] .map-day-frequency-option .map-day-frequency-weekdays .map-day-frequency-weekday {
  border-color: color-mix(in srgb, var(--frequency-day-color) 72%, #d8dee9);
  background: color-mix(in srgb, var(--frequency-day-color) 34%, #181b20);
  color: #f8fafc;
}

html[data-theme="dark"] .route-modal footer .map-day-frequency-error {
  color: #ffb4ab;
}

@media (max-width: 620px) {
  .map-day-frequency-modal {
    max-height: calc(100vh - 20px);
    padding: 10px;
  }

  .map-day-frequency-modal footer > button:not(.icon-button) {
    min-width: 110px;
  }
}

.route-new-modal {
  width: min(480px, calc(100vw - 28px));
}

.route-create-mode {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.route-create-mode button {
  width: 100%;
  min-width: 0;
}

.route-create-mode button[aria-pressed="true"] {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: var(--blue-deep);
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, .12);
}

.route-create-panel {
  display: grid;
  gap: 8px;
}

.route-create-panel[hidden],
.route-create-error[hidden] {
  display: none;
}

.route-create-preview,
.route-create-error {
  margin: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.route-create-error {
  border-color: rgba(229, 72, 77, .42);
  background: rgba(229, 72, 77, .08);
  color: var(--red);
}

html[data-theme="dark"] .route-create-mode button[aria-pressed="true"] {
  border-color: #4f8cff;
  background: #203556;
  color: #ffffff;
}

@media (max-width: 420px) {
  .route-create-mode {
    grid-template-columns: minmax(0, 1fr);
  }
}

.mileage-modal {
  gap: 12px;
  width: min(640px, calc(100vw - 28px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  padding: 14px;
  border-color: #c4d3e6;
  background: linear-gradient(180deg, #f8fbff 0%, #eef6ff 100%);
}

.optimizer-modal {
  width: min(1120px, calc(100vw - 28px));
  max-height: calc(100vh - 20px);
  overflow: auto;
}

.optimizer-modal[data-optimizer-rules-mode] {
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  max-height: calc(100vh - 20px);
  max-height: calc(100dvh - 20px);
  overflow: hidden;
}

.optimizer-calendar-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}

.optimizer-calendar-controls label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  font-size: 12px;
}

.optimizer-calendar-controls input { width: 72px; }
.optimizer-calendar-controls select { width: 132px; }
.optimizer-calendar-controls button { width: auto; flex: none; white-space: nowrap; }

.optimizer-preset-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
}

.optimizer-preset-toolbar > label {
  font-weight: 700;
}

.optimizer-preset-toolbar select {
  width: min(260px, 100%);
  min-width: 150px;
}

.optimizer-preset-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.optimizer-preset-actions button {
  width: auto;
}

.optimizer-preset-editor {
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  gap: 6px;
  min-width: 0;
}

.optimizer-preset-editor[hidden] {
  display: none;
}

.optimizer-preset-editor label {
  font-weight: 700;
}

.optimizer-preset-editor input {
  flex: 1 1 180px;
  min-width: 120px;
  border-color: var(--line);
  background: var(--panel);
  color: var(--text);
}

.optimizer-preset-editor input[aria-invalid="true"] {
  border-color: var(--red);
}

.optimizer-preset-editor button {
  width: auto;
  white-space: nowrap;
}

.optimizer-preset-status {
  min-width: 0;
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.optimizer-rules-body {
  display: grid;
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.optimizer-modal > footer {
  position: sticky;
  bottom: -12px;
  z-index: 3;
  margin: 0 -12px -12px;
  padding: 10px 12px 12px;
  border-top: 1px solid #d8e3f0;
  background: #fff;
}

.optimizer-modal[data-optimizer-rules-mode] > footer {
  position: static;
}

.optimizer-progress-modal {
  width: min(440px, calc(100vw - 28px));
}

.optimizer-progress-body {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.optimizer-progress-body strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
}

.optimizer-progress-body p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.optimizer-progress-body progress {
  width: 100%;
  height: 12px;
  margin-bottom: 8px;
  accent-color: var(--primary);
}

.optimizer-progress-body span {
  color: var(--muted);
  font-size: 12px;
}

.optimizer-progress-spinner {
  width: 30px;
  height: 30px;
  border: 3px solid #dbe7f5;
  border-top-color: var(--primary);
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.optimizer-modal .optimizer-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

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

.optimizer-rule-columns section {
  display: grid;
  align-content: start;
  gap: 7px;
  min-width: 0;
  padding: 11px;
  border: 1px solid #d8e3f0;
  border-radius: 7px;
  background: #f8fafc;
}

.optimizer-rule-columns h4 {
  margin: 0 0 2px;
  color: var(--text);
  font-size: 13px;
}

.optimizer-rule-list {
  display: grid;
  align-content: start;
  gap: 6px;
  min-height: 260px;
  padding: 2px;
  border-radius: 5px;
}

.optimizer-rule-list.drag-over {
  background: #eaf4ff;
  outline: 1px dashed #9bc2ea;
}

.optimizer-day-matrix {
  border: 1px solid #d8e3f5;
  border-radius: 8px;
  padding: 10px;
  background: #f8fbff;
  margin-bottom: 10px;
}

.optimizer-day-matrix-title {
  display: flex;
  align-items: center;
  gap: 16px;
  font-weight: 700;
  margin-bottom: 8px;
}

.optimizer-day-matrix-title .days-week-count-control { font-weight: 400; }
.optimizer-day-matrix-title .days-week-count-control input {
  background: var(--panel);
  color: var(--text);
}

.optimizer-day-matrix-grid {
  display: grid;
  gap: 6px;
  align-items: center;
}

.optimizer-day-matrix-grid strong {
  font-size: 12px;
  color: #334155;
}

.optimizer-day-cell {
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  min-height: 30px;
  font-size: 12px;
  cursor: pointer;
}

.optimizer-day-cell.allowed {
  background: #dcfce7;
  border-color: #86efac;
  color: #166534;
}

.optimizer-day-cell.partial {
  background: #fef3c7;
  border-color: #facc15;
  color: #854d0e;
}

.optimizer-day-cell.forbidden {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #991b1b;
}

.optimizer-rule-row {
  display: grid;
  grid-template-columns: 18px minmax(180px, 1fr) minmax(86px, 110px) 72px;
  align-items: center;
  gap: 6px;
  min-width: 0;
  min-height: 38px;
  padding: 4px 5px;
  border: 1px solid transparent;
  border-radius: 5px;
  cursor: default;
  color: #334155;
  font-size: 12px;
}

.optimizer-rule-row:hover {
  border-color: #cfe0f2;
  background: #fff;
}

.optimizer-rule-row.dragging {
  opacity: .55;
  cursor: grabbing;
}

.optimizer-rule-handle {
  color: #98a2b3;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  cursor: grab;
}

.optimizer-rule-label {
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.3;
  white-space: normal;
}

.optimizer-rule-actions {
  display: inline-flex;
  gap: 2px;
  justify-content: flex-end;
}

.optimizer-rule-actions .icon-button {
  width: 22px;
  height: 22px;
  min-height: 22px;
  padding: 0;
  font-size: 12px;
  line-height: 1;
}

.optimizer-rule-actions .icon-button:disabled {
  opacity: .35;
  cursor: default;
}

.optimizer-rule-value {
  width: 100%;
  min-width: 0;
  min-height: 26px;
  padding: 3px 6px;
  border-radius: 5px;
  font-size: 12px;
  cursor: text;
  user-select: text;
}

.optimizer-rule-value:focus {
  position: relative;
  z-index: 1;
}

.optimizer-rule-value-spacer {
  min-width: 86px;
}

.optimizer-modal[data-optimizer-rules-mode="days"] > header h3 {
  margin-right: auto;
}

@media (max-width: 760px) {
  .optimizer-preset-toolbar {
    flex-wrap: wrap;
  }

  .optimizer-preset-toolbar select {
    flex: 1 1 180px;
  }

  .optimizer-preset-actions {
    flex: 1 1 100%;
  }

  .optimizer-preset-editor {
    flex: 1 1 100%;
    flex-wrap: wrap;
  }

  .optimizer-preset-editor label {
    flex: 1 1 100%;
  }

  .optimizer-preset-editor input {
    flex: 1 1 100%;
  }

  .optimizer-preset-status {
    flex: 1 1 100%;
    margin-left: 0;
    text-align: left;
  }

  .optimizer-modal[data-optimizer-rules-mode="days"] > header {
    flex-wrap: wrap;
  }

  .optimizer-modal[data-optimizer-rules-mode="days"] > header h3 {
    flex: 1 1 calc(100% - 40px);
  }

  .optimizer-calendar-controls {
    order: 3;
    justify-content: flex-start;
    width: 100%;
    margin-left: 0;
  }

  .optimizer-rule-columns {
    grid-template-columns: minmax(0, 1fr);
  }

  .optimizer-rule-list {
    min-height: 0;
  }

  .optimizer-rule-row {
    grid-template-columns: 18px minmax(0, 1fr) 86px 72px;
  }
}

.optimizer-modal .optimizer-summary-grid div {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 7px;
  border: 1px solid #d8e3f0;
  border-radius: 6px;
  background: #f8fafc;
}

.optimizer-modal .optimizer-summary-grid span {
  color: #667085;
  font-size: 11px;
}

.optimizer-modal .optimizer-summary-grid strong {
  overflow: hidden;
  color: var(--text);
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.optimizer-modal .optimizer-problems {
  max-height: 110px;
  overflow: auto;
  padding: 7px;
  border: 1px solid #d8e3f0;
  border-radius: 6px;
  background: #fff;
  color: #526174;
  font-size: 12px;
}

.optimizer-modal .optimizer-preview-table {
  max-height: min(48vh, 360px);
  overflow: auto;
  border: 1px solid #d8e3f0;
  border-radius: 6px;
  background: #fff;
}

.optimizer-modal .optimizer-preview-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.optimizer-modal .optimizer-preview-table th,
.optimizer-modal .optimizer-preview-table td {
  padding: 6px 7px;
  border-bottom: 1px solid #eef2f7;
  text-align: left;
  vertical-align: top;
}

.optimizer-modal .optimizer-preview-table th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  color: #475467;
}

.mileage-modal header {
  padding-bottom: 4px;
  border-bottom: 1px solid #d8e4f2;
}

.mileage-modal header .icon-button {
  width: 34px;
  min-width: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 7px;
  font-size: 18px;
  line-height: 1;
}

.mileage-modal h3 {
  max-width: 270px;
  color: #142033;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.25;
}

.mileage-quick-panel {
  display: grid;
  gap: 8px;
  padding: 8px;
  border: 1px solid #c8d7e8;
  border-radius: 8px;
  background: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.82);
}

.mileage-quick-title {
  justify-self: stretch;
  min-height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid #c5d2e4;
  border-radius: 7px;
  background: #f8fafc;
  color: #142033;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
}

.mileage-quick-title:hover {
  border-color: #9fb6d1;
  background: #eef5ff;
}

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

.mileage-quick-form {
  display: grid;
  gap: 6px;
  margin: 0;
}

.mileage-tab-quick {
  grid-template-columns: 66px minmax(0, 1fr);
  align-items: center;
  justify-self: start;
  width: fit-content;
  max-width: 100%;
  gap: 6px;
  margin: 0 0 6px;
  padding: 5px;
  min-width: 0;
}

.mileage-tab-quick .mileage-quick-title {
  min-height: 32px;
  font-size: 13px;
}

.mileage-tab-quick .mileage-preset-grid {
  grid-template-columns: repeat(5, 44px);
  justify-content: start;
  gap: 6px;
}

.mileage-tab-quick .mileage-preset-button {
  position: relative;
  display: grid;
  place-items: center;
  width: 44px;
  min-width: 44px;
  min-height: 38px;
  padding: 2px;
  overflow: hidden;
  border-radius: 8px;
}

.mileage-tab-quick .mileage-preset-button span:last-child {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.mileage-quick-progress {
  height: 6px;
}

.mileage-tab-quick .mileage-quick-progress,
.mileage-tab-quick .mileage-quick-status,
.mileage-tab-quick .mileage-quick-result {
  grid-column: 1 / -1;
  width: 100%;
}

.mileage-tab-quick .mileage-quick-progress[value="0"] {
  display: none;
}

.mileage-quick-status {
  min-height: 14px;
  margin: 0;
  text-align: center;
  font-size: 11px;
  overflow-wrap: anywhere;
}

.mileage-quick-status:empty {
  display: none;
}

.mileage-quick-result {
  min-height: 0;
  margin: 0;
  padding: 5px 7px;
  font-size: 11px;
  overflow-wrap: anywhere;
}

.mileage-quick-result:empty {
  display: none;
}

.mileage-preset-button {
  display: grid;
  gap: 7px;
  justify-items: center;
  min-width: 0;
  min-height: 106px;
  padding: 10px 8px;
  border: 1px solid #c8d7e8;
  border-radius: 8px;
  background: #f8fafc;
  color: #142033;
  font-size: 13px;
  font-weight: 700;
}

.mileage-modal-presets {
  gap: 10px;
}

.mileage-modal .mileage-preset-button {
  min-height: 132px;
  padding: 10px;
}

.mileage-preset-button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.12);
}

.mileage-preset-button:disabled {
  opacity: 0.64;
  cursor: wait;
}

.mileage-preset-icon {
  width: 78px;
  height: 78px;
  display: grid;
  place-items: center;
}

.mileage-tab-quick .mileage-preset-icon {
  width: 34px;
  height: 34px;
}

.mileage-preset-icon img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  border-radius: 6px;
}

.mileage-modal .mileage-preset-icon {
  width: 92px;
  height: 92px;
}

.mileage-preset-icon svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mileage-preset-button.walk {
  border-color: #9edaae;
  background: #f2fbf4;
  color: #207f3b;
}

.mileage-preset-button.walk-roads {
  border-color: #75b9d8;
  background: #edf8fd;
  color: #176c91;
}

.mileage-preset-button.transit {
  border-color: #f0cb5b;
  background: #fff8dc;
  color: #8f6900;
}

.mileage-preset-button.auto {
  border-color: #ef9b9b;
  background: #fff1f1;
  color: #b51f28;
}

.mileage-preset-button.adaptive {
  border-color: #a997e8;
  background: #f5f1ff;
  color: #6148ad;
}

.mileage-fieldset {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 13px 12px 12px;
  border: 1px solid #ccd9e8;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.72);
}

.mileage-modal [data-mileage-single-speed][hidden],
.mileage-modal [data-mileage-adaptive-editor][hidden] {
  display: none;
}

.mileage-modal [data-mileage-common-parameters][hidden],
.mileage-modal [data-mileage-lines-multiplier][hidden] {
  display: none;
}

.mileage-fieldset legend {
  padding: 0 6px;
  color: #24364f;
  font-size: 13px;
  font-weight: 600;
}

.mileage-fieldset label {
  grid-template-columns: minmax(190px, 1fr) minmax(120px, 170px);
  align-items: center;
  gap: 14px;
}

.mileage-fieldset select,
.mileage-fieldset input {
  width: 100%;
  min-height: 34px;
  padding: 5px 9px;
  border: 1px solid #b9c8dc;
  border-radius: 6px;
  background: #fff;
  color: #172033;
  font-size: 13px;
}

.mileage-adaptive-derived {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) minmax(120px, 170px);
  align-items: center;
  gap: 14px;
}

.mileage-adaptive-derived span:last-child {
  min-height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid #b9c8dc;
  border-radius: 6px;
  background: #f3f6fa;
  font-size: 18px;
}

@media (max-width: 700px) {
  .mileage-modal-presets {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 460px) {
  .mileage-modal-presets {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mileage-fieldset label,
  .mileage-adaptive-derived {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
  }
}

.mileage-selection,
.mileage-osrm-status,
.mileage-status,
.mileage-result {
  margin: 0;
  color: #24364f;
  font-size: 13px;
  line-height: 1.35;
}

.mileage-selection {
  padding: 0 2px;
  color: #334155;
}

.mileage-osrm-status {
  padding: 7px 9px;
  border: 1px solid #d6e1ee;
  border-radius: 7px;
  background: #f8fafc;
  color: #475569;
}

.mileage-result {
  min-height: 36px;
  padding: 9px 10px;
  border: 1px solid #d6e1ee;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.64);
}

.mileage-result:empty {
  display: none;
}

.mileage-progress {
  width: 100%;
  height: 10px;
  overflow: hidden;
  border: 1px solid #c9d7e8;
  border-radius: 999px;
  background: #e8eef7;
}

.mileage-progress::-webkit-progress-bar {
  border-radius: 999px;
  background: #e8eef7;
}

.mileage-progress::-webkit-progress-value {
  border-radius: 999px;
  background: linear-gradient(90deg, #2f6df6, #1aa374);
}

.mileage-modal footer {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding-top: 2px;
}

.mileage-modal footer button {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  border-radius: 7px;
  font-weight: 600;
}

.days-client-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.days-clients-panel > .section-head {
  grid-template-columns: auto minmax(0, 1fr);
}

.days-clients-panel .days-client-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  width: 100%;
}

.days-clients-panel .days-client-actions > button {
  width: auto;
  min-width: 0;
  min-height: 30px;
}

.days-calendar-button {
  min-width: 92px;
  min-height: 28px;
  padding: 4px 10px;
  font-size: 12px;
}

@media (max-width: 900px) {
  .days-clients-panel .days-client-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.day-calendar-backdrop {
  z-index: 5200;
}

.day-calendar-modal {
  display: grid;
  grid-template-rows: auto minmax(210px, 1fr) auto;
  gap: 8px;
  width: min(920px, calc(100vw - 24px));
  height: min(620px, calc(100vh - 24px));
  padding: 8px;
  border: 1px solid #aebdd0;
  border-radius: 7px;
  background: #e8f2ff;
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.24);
  user-select: none;
}

.day-calendar-modal input,
.day-calendar-modal select,
.day-calendar-modal button {
  user-select: none;
}

.day-calendar-modal header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.day-calendar-modal h3 {
  margin: 0;
  font-size: 15px;
}

.day-calendar-modal header button {
  width: 28px;
  min-width: 28px;
  min-height: 28px;
  padding: 0;
  border-radius: 5px;
  font-size: 18px;
  line-height: 1;
}

.day-calendar-client-table {
  min-height: 0;
  overflow: auto;
  border: 1px solid #b6c6d8;
  background: #fff;
}

.day-calendar-client-table .routes-data-table {
  min-width: 820px;
}

.day-calendar-sort-button {
  width: 100%;
  min-height: 22px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
}

.day-calendar-sort-button:hover {
  color: #1d4ed8;
}

.day-calendar-client-table tr.selected td {
  background: #d8e8ff;
}

.day-calendar-client-table tr.active td {
  box-shadow: inset 0 1px 0 rgba(37, 99, 235, 0.22), inset 0 -1px 0 rgba(37, 99, 235, 0.22);
}

.day-calendar-schedule-cell {
  max-width: 230px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.day-calendar-modal footer {
  display: grid;
  grid-template-columns: minmax(220px, 0.72fr) minmax(330px, 1fr) 104px;
  gap: 8px;
  align-items: stretch;
  min-height: 128px;
}

.day-calendar-mode-panel,
.day-calendar-board,
.day-calendar-actions {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 8px;
  border: 1px solid #b6c6d8;
  background: #eef6ff;
}

.day-calendar-mode-panel {
  align-content: start;
  color: #334155;
  font-size: 12px;
}

.day-calendar-mode-panel label {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 6px;
}

.day-calendar-mode-panel input {
  width: 14px;
  height: 14px;
  margin: 0;
}

.day-calendar-move-day {
  grid-template-columns: auto minmax(64px, 92px) !important;
  padding-left: 22px;
}

.day-calendar-move-day select {
  min-height: 24px;
  padding: 2px 6px;
  font-size: 12px;
}

.day-calendar-board {
  align-content: center;
}

.day-calendar-total {
  color: var(--text);
  text-align: center;
  font-size: 12px;
  font-weight: 700;
}

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

.day-calendar-week {
  display: grid;
  grid-template-columns: auto repeat(7, minmax(22px, 1fr));
  align-items: center;
  gap: 3px;
}

.day-calendar-week strong {
  min-width: 14px;
  color: #334155;
  font-size: 12px;
  text-align: right;
}

.day-calendar-day {
  min-width: 0;
  min-height: 24px;
  padding: 2px 3px;
  border: 1px solid #cbd8ea;
  border-radius: 4px;
  background: #fff;
  color: #526174;
  font-size: 11px;
  font-weight: 700;
}

.day-calendar-day.active.green {
  border-color: rgba(22, 163, 109, 0.55);
  background: rgba(22, 163, 109, 0.24);
  color: #126747;
}

.day-calendar-day.active.yellow {
  border-color: rgba(211, 145, 0, 0.62);
  background: rgba(211, 145, 0, 0.22);
  color: #8a5e00;
}

.day-calendar-day.active.red {
  border-color: rgba(229, 72, 77, 0.58);
  background: rgba(229, 72, 77, 0.2);
  color: #9c2f34;
}

.day-calendar-day.partial {
  border-style: dashed;
  background: #fff8e6;
}

.day-calendar-shift {
  display: flex;
  justify-content: center;
  gap: 96px;
  margin-top: 4px;
}

.day-calendar-shift button {
  min-width: 76px;
}

.day-calendar-actions {
  align-content: space-between;
}

.day-calendar-actions button {
  width: 100%;
  min-width: 0;
  min-height: 30px;
  padding: 5px 8px;
  font-size: 12px;
}

/* Responsive polish for dense workbenches and map overlays. */
.routes-panel > .section-head {
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}

.routes-panel > .section-head .routes-head-actions,
.routes-panel > .section-head .days-head-actions {
  justify-content: flex-start;
  flex-wrap: wrap;
}

@media (max-width: 1320px) {
  .import-workbench-grid {
    grid-template-columns: minmax(300px, 0.9fr) minmax(0, 1.1fr);
  }

  .section-head,
  .routes-routes-panel > .section-head {
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
  }

  .routes-head-actions,
  .days-head-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .routes-head-actions span,
  .routes-head-actions .route-table-update-toggle span {
    max-width: none;
  }
}

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

  .day-calendar-modal footer {
    grid-template-columns: minmax(190px, 0.8fr) minmax(280px, 1.2fr);
    overflow: auto;
  }

  .day-calendar-actions {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .day-calendar-modal {
    grid-template-rows: auto minmax(180px, 1fr) minmax(0, auto);
  }

  .day-calendar-modal footer,
  .day-calendar-actions {
    grid-template-columns: minmax(0, 1fr);
  }

  .day-calendar-actions {
    grid-column: auto;
  }

  .map-layer-panel {
    top: 68px;
    right: 8px;
    max-width: calc(100% - 16px);
  }

  .days-map-tools,
  .zone-tools {
    max-width: calc(100% - 16px);
    overflow-x: auto;
  }

  .map-selection-info {
    max-width: calc(100% - 20px);
    justify-content: center;
    gap: 7px;
    padding: 6px 8px;
  }

  .map-selection-metric > span {
    white-space: normal;
    font-size: 10px;
  }

  .map-selection-metric > strong {
    font-size: 13px;
  }
}

/* Dark theme. Semantic zone colors remain unchanged; only base raster map tiles are filtered. */
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0f12;
  --panel: #17191d;
  --panel-soft: #1d2025;
  --text: #f2f4f7;
  --muted: #a8b0bd;
  --line: #343941;
  --line-strong: #4a515c;
  --blue: #4f8cff;
  --blue-deep: #73a4ff;
  --blue-soft: #18243a;
  --shadow: 0 12px 34px rgba(0, 0, 0, 0.38);
  --shadow-soft: 0 4px 16px rgba(0, 0, 0, 0.3);
  --cursor-text-visible: text;
}

html[data-theme="dark"] ::selection {
  background: #356fd6;
  color: #ffffff;
}

html[data-theme="dark"] ::-moz-selection {
  background: #356fd6;
  color: #ffffff;
}

html[data-theme="dark"] body,
html[data-theme="dark"] .workspace {
  background: #0d0f12;
  color: var(--text);
}

html[data-theme="dark"] .workspace {
  background: linear-gradient(180deg, #14171b 0%, #0d0f12 100%);
}

html[data-theme="dark"] .auth-screen {
  background: linear-gradient(135deg, rgba(13, 15, 18, 0.96), rgba(25, 29, 35, 0.96)), #0d0f12;
}

html[data-theme="dark"] .auth-screen::before {
  opacity: .42;
}

html[data-theme="dark"] .auth-screen::after {
  background: linear-gradient(135deg, rgba(54, 60, 69, .3), transparent), linear-gradient(120deg, rgba(22, 163, 109, .12), transparent 42%), linear-gradient(245deg, rgba(79, 140, 255, .16), transparent 46%);
}

html[data-theme="dark"] .auth-panel,
html[data-theme="dark"] .app-busy-card,
html[data-theme="dark"] .app-topbar,
html[data-theme="dark"] .sidebar,
html[data-theme="dark"] .tab-panel,
html[data-theme="dark"] .import-card,
html[data-theme="dark"] .routes-panel,
html[data-theme="dark"] .route-summary-row,
html[data-theme="dark"] .routes-grid,
html[data-theme="dark"] .route-modal,
html[data-theme="dark"] .day-calendar-client-table,
html[data-theme="dark"] .client-context-menu,
html[data-theme="dark"] .route-context-menu,
html[data-theme="dark"] .table-filter-menu {
  border-color: var(--line);
  background: var(--panel);
  color: var(--text);
}

html[data-theme="dark"] .app-topbar {
  background: rgba(20, 22, 26, .94);
  box-shadow: 0 1px 0 #000;
}

html[data-theme="dark"] body[data-active-tab="routes"] .sidebar,
html[data-theme="dark"] body[data-active-tab="days"] .sidebar,
html[data-theme="dark"] .routes-panel {
  background: #13161a;
}

html[data-theme="dark"] .auth-loading,
html[data-theme="dark"] .routes-head,
html[data-theme="dark"] .routes-summary .summary-row,
html[data-theme="dark"] .day-calendar-mode-panel,
html[data-theme="dark"] .day-calendar-board,
html[data-theme="dark"] .day-calendar-actions,
html[data-theme="dark"] .mileage-modal,
html[data-theme="dark"] .day-calendar-modal {
  border-color: var(--line);
  background: var(--panel-soft);
  color: var(--text);
}

html[data-theme="dark"] .routes-head,
html[data-theme="dark"] .mileage-modal {
  background: linear-gradient(180deg, #20242a 0%, #171a1f 100%);
}

html[data-theme="dark"] input:not([type="checkbox"]):not([type="radio"]),
html[data-theme="dark"] textarea,
html[data-theme="dark"] select,
html[data-theme="dark"] button.secondary,
html[data-theme="dark"] .client-context-menu button,
html[data-theme="dark"] .route-context-menu button,
html[data-theme="dark"] .table-filter-menu button {
  border-color: var(--line);
  background: #202329;
  color: var(--text);
  box-shadow: none;
}

html[data-theme="dark"] button.secondary:hover:not(:disabled),
html[data-theme="dark"] .client-context-menu button:hover,
html[data-theme="dark"] .route-context-menu button:hover,
html[data-theme="dark"] .table-filter-menu button:hover {
  border-color: var(--line-strong);
  background: #2a2e35;
}

html[data-theme="dark"] .tab-button {
  color: var(--muted);
}

html[data-theme="dark"] .tab-button:hover,
html[data-theme="dark"] .tab-button.active {
  background: #20242a;
  color: var(--text);
}

html[data-theme="dark"] .import-preview,
html[data-theme="dark"] .mapping-table,
html[data-theme="dark"] .routes-data-table,
html[data-theme="dark"] .client-table,
html[data-theme="dark"] .client-list,
html[data-theme="dark"] .route-list {
  border-color: var(--line);
  background: var(--panel);
  color: var(--text);
}

html[data-theme="dark"] .import-preview th,
html[data-theme="dark"] .routes-data-table th,
html[data-theme="dark"] .client-table th {
  border-color: var(--line);
  background: #20242a;
  color: #dce1e8;
}

html[data-theme="dark"] .import-preview td,
html[data-theme="dark"] .routes-data-table td,
html[data-theme="dark"] .client-table td {
  border-color: #2d3239;
}

html[data-theme="dark"] .import-preview tbody tr:nth-child(even),
html[data-theme="dark"] .client-table tbody tr:nth-child(even) {
  background: #191c21;
}

html[data-theme="dark"] .import-preview tbody tr:hover,
html[data-theme="dark"] .client-table tbody tr:hover,
html[data-theme="dark"] .routes-data-table tr:hover td,
html[data-theme="dark"] .routes-data-table tr.selected td,
html[data-theme="dark"] .route-summary-row:hover,
html[data-theme="dark"] .route-summary-row.active {
  background: #202b40;
}

html[data-theme="dark"] .routes-data-table tr.days-route-summary-row td {
  background: #202b40;
  color: #e5edf9;
}

html[data-theme="dark"] .routes-data-table tr.days-route-summary-row.row-selected td {
  background: #17345f;
  box-shadow: inset 0 1px 0 #6f9fe8, inset 0 -1px 0 #6f9fe8;
}

@media (max-width: 900px) {
  .days-route-summary-label {
    max-width: 180px;
  }
}

html[data-theme="dark"] .client-table tbody tr.selected,
html[data-theme="dark"] .client-table tbody tr.selected:nth-child(even),
html[data-theme="dark"] .client-table tbody tr.selected:hover {
  background: #17345f;
  outline: 1px solid #6f9fe8;
  outline-offset: -1px;
  box-shadow: inset 4px 0 0 #8bb4f3;
}

html[data-theme="dark"] .import-workbench {
  background: linear-gradient(180deg, #14171b 0%, #0d0f12 100%);
}

html[data-theme="dark"] .import-timings-top,
html[data-theme="dark"] .import-stage-row,
html[data-theme="dark"] .session-row,
html[data-theme="dark"] .mapping-row,
html[data-theme="dark"] .route-day-strip span,
html[data-theme="dark"] .selected-visits-panel,
html[data-theme="dark"] .map-planner-option,
html[data-theme="dark"] .map-planner-metrics div,
html[data-theme="dark"] .popup-zone-menu,
html[data-theme="dark"] .optimizer-modal > footer,
html[data-theme="dark"] .optimizer-rule-columns section,
html[data-theme="dark"] .optimizer-modal .optimizer-summary-grid div,
html[data-theme="dark"] .optimizer-modal .optimizer-problems,
html[data-theme="dark"] .optimizer-modal .optimizer-preview-table,
html[data-theme="dark"] .mileage-quick-panel,
html[data-theme="dark"] .mileage-quick-title,
html[data-theme="dark"] .mileage-fieldset,
html[data-theme="dark"] .mileage-osrm-status,
html[data-theme="dark"] .mileage-result {
  border-color: var(--line);
  background: #1c2025;
  color: var(--text);
}

html[data-theme="dark"] .mapping-head,
html[data-theme="dark"] .load-progress,
html[data-theme="dark"] .selected-visits-plan,
html[data-theme="dark"] .selected-visit-day:not(.active),
html[data-theme="dark"] .table-filter-values,
html[data-theme="dark"] .table-filter-check-all {
  border-color: var(--line);
  background: #20242a;
  color: var(--muted);
}

html[data-theme="dark"] .load-progress-track {
  background: #343941;
}

html[data-theme="dark"] .table-filter-title,
html[data-theme="dark"] .table-filter-check,
html[data-theme="dark"] .mileage-modal h3,
html[data-theme="dark"] .mileage-quick-title,
html[data-theme="dark"] .mileage-fieldset legend,
html[data-theme="dark"] .mileage-selection,
html[data-theme="dark"] .mileage-osrm-status,
html[data-theme="dark"] .mileage-status,
html[data-theme="dark"] .mileage-result,
html[data-theme="dark"] .optimizer-rule-row,
html[data-theme="dark"] .optimizer-day-matrix-grid strong {
  color: var(--text);
}

html[data-theme="dark"] .table-filter-check:hover,
html[data-theme="dark"] .table-filter-check:focus-within {
  background: #28364d;
  color: #ffffff;
}

html[data-theme="dark"] .table-filter-check:hover small,
html[data-theme="dark"] .table-filter-check:focus-within small {
  color: #d5dbea;
}

html[data-theme="dark"] .optimizer-rule-row:hover {
  border-color: var(--line-strong);
  background: #252a31;
}

html[data-theme="dark"] .optimizer-rule-list.drag-over {
  background: #202b40;
  outline-color: #4f8cff;
}

html[data-theme="dark"] .optimizer-rule-row.dragging {
  border-color: #5f83bd;
  background: #2a3443;
  color: #ffffff;
  opacity: .82;
  box-shadow: 0 0 0 1px rgba(79, 140, 255, .18);
}

html[data-theme="dark"] .optimizer-day-matrix {
  border-color: var(--line);
  background: #191d22;
}

html[data-theme="dark"] .optimizer-modal .optimizer-preview-table th {
  background: #242930;
  color: #dce1e8;
}

html[data-theme="dark"] .optimizer-modal .optimizer-preview-table td,
html[data-theme="dark"] .optimizer-modal .optimizer-preview-table th {
  border-color: var(--line);
}

html[data-theme="dark"] .mileage-fieldset select,
html[data-theme="dark"] .mileage-fieldset input {
  border-color: var(--line);
  background: #202329;
  color: var(--text);
}

html[data-theme="dark"] .mileage-preset-button.walk {
  border-color: #3c8050;
  background: #1d3324;
  color: #8ee0a2;
}

html[data-theme="dark"] .mileage-preset-button.walk-roads {
  border-color: #356f8b;
  background: #1c303a;
  color: #83ccea;
}

html[data-theme="dark"] .mileage-preset-button.transit {
  border-color: #8a6c24;
  background: #382f18;
  color: #f4d36d;
}

html[data-theme="dark"] .mileage-preset-button.auto {
  border-color: #8e4047;
  background: #3a2023;
  color: #ff9399;
}

html[data-theme="dark"] .mileage-preset-button.adaptive {
  border-color: #745fb2;
  background: #29233a;
  color: #c8b7ff;
}

html[data-theme="dark"] .mileage-adaptive-derived span:last-child {
  border-color: var(--line);
  background: #202329;
  color: var(--text);
}

html[data-theme="dark"] .map-tools,
html[data-theme="dark"] .zone-tools,
html[data-theme="dark"] .days-map-tools,
html[data-theme="dark"] .map-layer-panel,
html[data-theme="dark"] .map-selection-info,
html[data-theme="dark"] .map-planner-panel {
  border-color: rgba(255, 255, 255, .12);
  background: rgba(24, 27, 32, .95);
  color: var(--text);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .42);
}

html[data-theme="dark"] .map-tools:hover,
html[data-theme="dark"] .map-tools:focus-within,
html[data-theme="dark"] .zone-tools:hover,
html[data-theme="dark"] .zone-tools:focus-within {
  background: rgba(29, 33, 39, .98);
}

html[data-theme="dark"] .leaflet-popup-content-wrapper,
html[data-theme="dark"] .leaflet-popup-tip,
html[data-theme="dark"] .leaflet-control-zoom a,
html[data-theme="dark"] .leaflet-control-layers {
  border-color: var(--line);
  background: #1b1e23;
  color: var(--text);
}

html[data-theme="dark"] #map,
html[data-theme="dark"] .leaflet-container {
  color-scheme: light;
  background: #11161c;
}

html[data-theme="dark"] .leaflet-tile-pane {
  filter: brightness(.64) invert(1) contrast(.92) hue-rotate(180deg) saturate(.52);
}

html[data-theme="dark"] .leaflet-tile-pane .leaflet-tile {
  filter: none;
}

html[data-theme="dark"] .leaflet-container canvas {
  background: transparent !important;
}

html[data-theme="dark"] .leaflet-control-zoom a:hover {
  background: #292d34;
  color: #fff;
}

html[data-theme="dark"] .leaflet-control-attribution {
  border-color: rgba(255, 255, 255, .14);
  background: rgba(24, 27, 32, .92) !important;
  color: #b8c0cc;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .35);
}

html[data-theme="dark"] .leaflet-control-attribution a {
  color: #8bb4ff;
}

html[data-theme="dark"] .leaflet-control-attribution a:hover,
html[data-theme="dark"] .leaflet-control-attribution a:focus-visible {
  color: #b4ceff;
}

html[data-theme="dark"] .yandex-map-open-link {
  border-color: rgba(255, 255, 255, .14);
  background: rgba(24, 27, 32, .92);
  color: #dbe8ff;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .35);
}

html[data-theme="dark"] .yandex-map-logo-link {
  border-color: rgba(255, 255, 255, .14);
  box-shadow: 0 3px 10px rgba(0, 0, 0, .35);
}

html[data-theme="dark"] .yandex-map-open-link:hover,
html[data-theme="dark"] .yandex-map-open-link:focus-visible {
  border-color: rgba(255, 255, 255, .24);
  background: #292d34;
  color: #fff;
}

html[data-theme="dark"] .point-popup,
html[data-theme="dark"] .leaflet-popup-content,
html[data-theme="dark"] .leaflet-control-layers label {
  color: var(--text);
}

html[data-theme="dark"] .day-load-bar {
  border-color: var(--line);
  background: #242830;
}

html[data-theme="dark"] .day-load-text {
  color: #f7f9fc;
  text-shadow: 0 1px 2px #000;
}

html[data-theme="dark"] .day-calendar-day:not(.active),
html[data-theme="dark"] .day-calendar-day.partial {
  border-color: var(--line);
  background: #20242a;
  color: #c5ccd6;
}

html[data-theme="dark"] .day-calendar-mode-panel,
html[data-theme="dark"] .day-calendar-week strong,
html[data-theme="dark"] .route-table-update-toggle,
html[data-theme="dark"] .import-workbench-header p {
  color: var(--muted);
}

html[data-theme="dark"] .app-busy-overlay,
html[data-theme="dark"] .route-modal-backdrop {
  background: rgba(0, 0, 0, .62);
}

html[data-theme="dark"] .routes-data-table tr.day-checked td {
  background: #1b1f24;
}

html[data-theme="dark"] .routes-data-table tr.day-unchecked td {
  background: #171a1f;
  color: var(--muted);
}

html[data-theme="dark"] .routes-data-table tr.day-week-row td {
  background: #242930;
  color: var(--text);
}

html[data-theme="dark"] .routes-data-table tr.day-week-row.day-checked td {
  background: #202733;
}

html[data-theme="dark"] .routes-data-table tr.day-week-row.day-partial td {
  background: #1d2b43;
}

html[data-theme="dark"] .routes-data-table tr.route-supervisor-row td {
  background: #1b2940;
  color: var(--text);
}

html[data-theme="dark"] .routes-data-table tr.route-supervisor-row.route-partial td {
  background: #202c42;
}

html[data-theme="dark"] .routes-data-table tr.route-supervisor-child-row td:not(.route-mismatch-cell) {
  background: #181b20;
  color: #d5dae2;
}

html[data-theme="dark"] .routes-data-table tr.row-selected td {
  background: #203556;
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(79, 140, 255, .28), inset 0 -1px 0 rgba(79, 140, 255, .28);
}

html[data-theme="dark"] .routes-data-table tr.route-no-supervisor-divider td {
  background: #2b2018;
  border-top-color: #f97316;
  color: #f3a46d;
}

@media (min-width: 901px) and (max-width: 1400px) {
  .app-topbar .tabs {
    flex: 1 1 auto;
    gap: 3px;
    overflow-x: hidden;
  }

  .app-topbar .tabs .tab-button {
    flex: 1 1 0;
    min-width: 0;
    padding-inline: 6px;
    font-size: 12px;
  }
}

/* Final targeted overrides: keep these after the legacy component rules. */
.map-planner-icon-button {
  width: 28px;
  min-width: 28px;
  max-width: 28px;
  height: 28px;
  min-height: 28px;
  flex: 0 0 28px;
}

.map-planner-route-controls {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 10px;
}

.map-planner-swap {
  width: auto;
  min-width: 0;
}

.map-planner-speed {
  display: grid;
  grid-template-columns: minmax(54px, 62px) max-content;
  justify-content: end;
  gap: 5px;
}

.map-planner-speed > span:first-child {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.map-planner-speed input {
  width: 100%;
  min-width: 0;
}

.routes-routes-panel .routes-head-actions .route-table-update-toggle span {
  max-width: none;
  overflow: visible;
  text-overflow: clip;
}

.optimizer-rule-row {
  grid-template-columns: 18px minmax(0, 1fr) minmax(88px, 110px) 78px;
}

.optimizer-rule-value,
.optimizer-rule-value-spacer {
  grid-column: 3;
  max-width: 100%;
}

.optimizer-rule-actions {
  grid-column: 4;
  width: 78px;
  min-width: 78px;
}

.optimizer-rule-actions .icon-button {
  flex: 0 0 24px;
  width: 24px;
  min-width: 24px;
  max-width: 24px;
  height: 24px;
  min-height: 24px;
}

html[data-theme="dark"] .map-planner-icon-button {
  border-color: var(--line);
  background: #202329;
  color: var(--text);
}

html[data-theme="dark"] .map-planner-icon-button:hover:not(:disabled),
html[data-theme="dark"] .map-planner-icon-button:focus-visible {
  border-color: var(--blue);
  background: #2a2e35;
  color: #8bb4ff;
}

html[data-theme="dark"] .map-planner-icon-button:disabled {
  background: #2a2e35;
  color: #707784;
  opacity: .72;
}

@media (max-width: 760px) {
  .optimizer-rule-row {
    grid-template-columns: 18px minmax(0, 1fr) 86px 78px;
  }
}

.leaflet-control-zoom {
  border: 1px solid rgba(31, 41, 51, .14);
  background: rgba(255, 255, 255, .84);
  box-shadow: 0 10px 28px rgba(15, 23, 42, .16);
  backdrop-filter: blur(8px);
}

.leaflet-control-zoom a {
  border-bottom-color: rgba(31, 41, 51, .14);
  background: transparent;
}

.leaflet-control-zoom:hover,
.leaflet-control-zoom:focus-within {
  background: rgba(255, 255, 255, .92);
}

.leaflet-control-zoom a:hover:not(.leaflet-disabled),
.leaflet-control-zoom a:focus:not(.leaflet-disabled) {
  background: transparent;
}

html[data-theme="dark"] .leaflet-control-zoom {
  border-color: rgba(255, 255, 255, .14);
  background: rgba(24, 27, 32, .84);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .36);
}

html[data-theme="dark"] .leaflet-control-zoom a {
  border-bottom-color: rgba(255, 255, 255, .14);
  background: transparent;
}

html[data-theme="dark"] .leaflet-control-zoom:hover,
html[data-theme="dark"] .leaflet-control-zoom:focus-within {
  background: rgba(24, 27, 32, .92);
}

html[data-theme="dark"] .leaflet-control-zoom a:hover:not(.leaflet-disabled),
html[data-theme="dark"] .leaflet-control-zoom a:focus:not(.leaflet-disabled) {
  background: transparent;
}

html[data-theme="dark"] .leaflet-control-zoom a.leaflet-disabled {
  color: #707784;
  background: transparent;
}

/* Shared translucent map controls. Keep this override after theme and responsive rules. */
.map-tools,
.zone-tools,
.days-map-tools,
.map-layer-panel,
.map-selection-info,
.map-planner-panel {
  border-color: rgba(31, 41, 51, .14);
  background: rgba(255, 255, 255, .84);
  box-shadow: 0 10px 28px rgba(15, 23, 42, .16);
  backdrop-filter: blur(8px);
}

.zone-tools,
.days-map-tools {
  box-shadow: 0 -10px 28px rgba(15, 23, 42, .16);
}

.map-tools:hover,
.map-tools:focus-within,
.map-layer-panel:hover,
.map-layer-panel:focus-within,
.map-selection-info:hover,
.map-selection-info:focus-within,
.map-planner-panel:hover,
.map-planner-panel:focus-within {
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 10px 28px rgba(15, 23, 42, .16);
}

.zone-tools:hover,
.zone-tools:focus-within,
.zone-tools:has(.zone-drop.drag-over),
.days-map-tools:hover,
.days-map-tools:focus-within {
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 -10px 28px rgba(15, 23, 42, .16);
}

html[data-theme="dark"] .map-tools,
html[data-theme="dark"] .zone-tools,
html[data-theme="dark"] .days-map-tools,
html[data-theme="dark"] .map-layer-panel,
html[data-theme="dark"] .map-selection-info,
html[data-theme="dark"] .map-planner-panel {
  border-color: rgba(255, 255, 255, .14);
  background: rgba(24, 27, 32, .84);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .36);
}

html[data-theme="dark"] .zone-tools,
html[data-theme="dark"] .days-map-tools {
  box-shadow: 0 -10px 28px rgba(0, 0, 0, .36);
}

html[data-theme="dark"] .map-tools:hover,
html[data-theme="dark"] .map-tools:focus-within,
html[data-theme="dark"] .map-layer-panel:hover,
html[data-theme="dark"] .map-layer-panel:focus-within,
html[data-theme="dark"] .map-selection-info:hover,
html[data-theme="dark"] .map-selection-info:focus-within,
html[data-theme="dark"] .map-planner-panel:hover,
html[data-theme="dark"] .map-planner-panel:focus-within {
  background: rgba(24, 27, 32, .92);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .36);
}

html[data-theme="dark"] .zone-tools:hover,
html[data-theme="dark"] .zone-tools:focus-within,
html[data-theme="dark"] .zone-tools:has(.zone-drop.drag-over),
html[data-theme="dark"] .days-map-tools:hover,
html[data-theme="dark"] .days-map-tools:focus-within {
  background: rgba(24, 27, 32, .92);
  box-shadow: 0 -10px 28px rgba(0, 0, 0, .36);
}

.map-selection-info {
  bottom: 6px;
}

@media (max-width: 900px) {
  .map-selection-info {
    bottom: 4px;
  }
}

.map-stage {
  --map-control-inset: 6px;
}

.map-tools {
  top: var(--map-control-inset);
  border-top-width: 1px;
  border-top-style: solid;
  border-radius: 8px;
}

.zone-tools,
.days-map-tools {
  bottom: var(--map-control-inset);
  border-bottom-width: 1px;
  border-bottom-style: solid;
  border-radius: 8px;
}

@media (max-width: 900px) {
  .map-stage {
    --map-control-inset: 4px;
  }
}
.client-distribution-backdrop {
  z-index: 1250;
  padding: 20px;
}

.client-distribution-modal {
  width: min(900px, calc(100vw - 32px));
  max-height: min(820px, calc(100vh - 32px));
  overflow: auto;
  display: grid;
  gap: 14px;
}

.client-distribution-head,
.client-distribution-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.client-distribution-head h2,
.client-distribution-picker h3 {
  margin: 0;
}

.client-distribution-pickers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.client-distribution-picker {
  min-height: 210px;
  max-height: 310px;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.client-distribution-picker-head {
  display: grid;
  gap: 5px;
  padding: 10px 10px 7px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.client-distribution-picker-head input[type="search"] {
  min-height: 30px;
}

.client-distribution-picker-list {
  min-height: 0;
  overflow-y: auto;
  padding: 4px 8px 7px;
}

.client-distribution-route {
  display: grid;
  grid-template-columns: 16px 16px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  min-height: 25px;
  padding: 2px 3px;
  line-height: 1.2;
}

.client-distribution-route input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-height: 0;
  margin: 0;
}

.client-distribution-route.is-disabled {
  opacity: 0.48;
}

.client-distribution-swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--distribution-route-color, #98a2b3);
  border: 1px solid color-mix(in srgb, var(--distribution-route-color, #98a2b3), white 30%);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.14);
}

.client-distribution-limits {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px 12px;
}

.client-distribution-limits label {
  display: grid;
  grid-template-columns: auto 1fr minmax(58px, 74px) auto;
  align-items: center;
  gap: 5px;
  font-size: 12px;
}

.client-distribution-limits input[type="number"] {
  min-width: 0;
}

.client-distribution-error {
  min-height: 18px;
  margin: 0;
  color: var(--danger, #d92d20);
  white-space: pre-line;
}

.client-distribution-preview {
  display: grid;
  gap: 10px;
}

.client-distribution-totals {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.client-distribution-totals > div {
  display: grid;
  justify-items: center;
  gap: 3px;
  padding: 9px;
  border-right: 1px solid var(--line);
}

.client-distribution-totals > div:last-child {
  border-right: 0;
}

.client-distribution-totals span,
.client-distribution-table {
  font-size: 12px;
}

.client-distribution-totals strong {
  font-size: 20px;
  color: var(--blue);
}

.client-distribution-totals .is-success { color: #039855; }
.client-distribution-totals .is-warning { color: #dc6803; }

.client-distribution-table-wrap {
  max-height: 230px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.client-distribution-table {
  width: 100%;
  border-collapse: collapse;
}

.client-distribution-table th,
.client-distribution-table td {
  padding: 7px 9px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.client-distribution-reasons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.client-distribution-reasons span {
  padding: 4px 7px;
  border-radius: 7px;
  background: var(--surface-muted, rgba(152, 162, 179, 0.12));
  font-size: 12px;
}

.client-distribution-actions {
  justify-content: flex-end;
}

@media (max-width: 760px) {
  .client-distribution-pickers,
  .client-distribution-limits {
    grid-template-columns: 1fr;
  }

  .client-distribution-picker {
    min-height: 160px;
    max-height: 220px;
  }
}

/* The footer uses the same table columns and width attributes as the body. */
#routes-list .route-table-footer td {
  position: sticky;
  bottom: 0;
  z-index: 2;
  padding: 3px 5px;
  vertical-align: baseline;
  background: #edf2fa;
  color: #243247;
  box-shadow: inset 0 1px #b8c8dd;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

#routes-list .route-table-footer-value {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#routes-list [data-route-footer-mode] {
  display: block;
  width: 32px;
  flex: 0 0 32px;
  min-width: 0;
  max-width: 100%;
  min-height: 20px;
  margin: 0;
  padding: 1px 0;
  appearance: none;
  border: 1px solid #9aacc5;
  border-radius: 3px;
  background: #fff;
  color: inherit;
  font-size: 11px;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
}

html[data-theme="dark"] #routes-list .route-table-footer td {
  background: #243246;
  color: #e3ebf6;
  box-shadow: inset 0 1px #52657f;
}

html[data-theme="dark"] #routes-list [data-route-footer-mode] {
  background: #182435;
  border-color: #647995;
}

#routes-list .route-table-footer td:first-child {
  padding-inline: 2px;
}

#routes-list .route-table-footer-first {
  display: flex;
  align-items: baseline;
  gap: 2px;
  min-width: 0;
}

#routes-list .route-table-footer-first .route-table-footer-value {
  flex: 1;
  min-width: 0;
}
