:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --text: #1a1f2b;
  --muted: #6a7384;
  --border: #e3e6ec;
  --accent: #2f6fed;
  --accent-hover: #2256c4;
  --danger: #c43a3a;
  --shadow: 0 1px 3px rgba(20, 30, 60, 0.06), 0 6px 24px rgba(20, 30, 60, 0.06);
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

.app {
  display: grid;
  grid-template-columns: 380px 1fr;
  height: 100vh;
  min-height: 0;
}

.panel {
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 24px 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.panel header h1 {
  font-size: 18px;
  margin: 0 0 4px 0;
  letter-spacing: -0.01em;
}

.panel header .sub {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.tabs {
  display: flex;
  gap: 2px;
  margin: 8px 0 12px;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
}
.tabs a {
  padding: 6px 10px;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.12s, border-color 0.12s;
}
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }

.recents {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
  font-size: 12px;
}
.recents.hidden { display: none; }
.recents .recent-label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}
.recents .chips { display: flex; flex-wrap: wrap; gap: 4px; }
.recents .chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 12px;
  background: #eef2fb;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  border: none;
  transition: background 0.12s;
}
.recents .chip:hover { background: #dde6f7; }
.recents .chip .x { color: var(--muted); font-size: 14px; line-height: 1; }
.recents .chip:hover .x { color: var(--danger); }

.group-block {
  padding: 10px 0 12px 12px;
  border-left: 4px solid var(--accent);
  margin-bottom: 16px;
}
.group-block:last-child { margin-bottom: 0; }
.group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}
.group-title small { font-weight: 400; color: var(--muted); }
.group-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}
.group-block .stats { margin: 0 0 8px 0; }
.group-block .group-list { margin-bottom: 8px; max-height: 220px; }

.step {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.step:first-of-type { border-top: none; padding-top: 0; }

.step.hidden { display: none; }

.step h2 {
  font-size: 14px;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

label { font-size: 13px; color: var(--muted); }

input[type="text"] {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  background: #fff;
  transition: border-color 0.15s;
}
input[type="text"]:focus { outline: none; border-color: var(--accent); }

button {
  padding: 9px 14px;
  font: inherit;
  font-weight: 500;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
button:hover { background: #f0f2f6; }
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button.ghost:hover { color: var(--text); background: #f0f2f6; }
button:disabled { opacity: 0.55; cursor: progress; }

.ico {
  width: 16px;
  height: 16px;
  margin-right: 6px;
  vertical-align: -3px;
  display: inline-block;
}

fieldset {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  margin: 0;
}
fieldset legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 14px;
  padding: 4px 0;
  cursor: pointer;
}

.mode-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.mode {
  position: relative;
  display: block;
}
.mode input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.mode span {
  display: block;
  text-align: center;
  padding: 7px 4px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}
.mode input:checked + span {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}
.mode span:hover { border-color: var(--accent); }

.places {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fafbfc;
}
.places li {
  display: flex;
  gap: 10px;
  padding: 8px 11px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.places li:last-child { border-bottom: none; }
.places li .num {
  flex: 0 0 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.places.ordered li .num { background: #1f9d55; }
.places li .name { font-weight: 500; }
.places li .addr { color: var(--muted); font-size: 12px; }

.stats {
  margin: 0;
  font-size: 14px;
  color: var(--text);
}
.stats strong { font-weight: 600; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.split-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.split-actions button { width: 100%; }

.split-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  background: #fafbfc;
}
.split-list.hidden { display: none; }
.split-list .row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--border);
}
.split-list .row:last-child { border-bottom: none; padding-bottom: 0; }
.split-list .row .label { color: var(--text); line-height: 1.35; }
.split-list .row .label small { color: var(--muted); display: block; }
.split-list .row-actions { display: flex; gap: 6px; }
.split-list .row-actions button { flex: 1; padding: 6px 10px; font-size: 13px; }
.split-list .row-actions .primary { flex: 1.4; }

.hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  min-height: 1.2em;
}
.hint.error { color: var(--danger); }
.hint.ok { color: #1f9d55; }

.map-wrap { position: relative; min-height: 0; }
#map { width: 100%; height: 100%; }

.marker-pin {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}
.marker-pin.start { background: #1f9d55; }
.marker-pin.end { background: #c43a3a; }
.marker-pin.unordered { background: #6a7384; }

@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 50vh; height: 100vh; }
  .panel { border-right: none; border-bottom: 1px solid var(--border); max-height: 50vh; }
}
