:root { --ink: #111; --mute: #666; --line: #e3e3e3; --bg: #f6f6f4; --accent: #f7941d; --bad: #b3261e; }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); display: flex; flex-direction: column; }
header { background: #000; color: #fff; display: flex; align-items: center; gap: 14px; padding: 6px 16px; }
header img { height: 88px; width: auto; }
header h1 { font-size: 18px; margin: 0; flex: 1; font-weight: 600; }
header a { color: var(--accent); text-decoration: none; font-weight: 600; white-space: nowrap; }
header a:hover { text-decoration: underline; }
header a.btn { border: 1px solid var(--accent); border-radius: 6px; padding: 6px 12px; }
header a.btn:hover { background: var(--accent); color: #000; text-decoration: none; }

.tabs { display: flex; gap: 4px; padding: 8px 16px 0; background: #fff; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 8px 12px; font: inherit; color: var(--mute); border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }

main { flex: 1; display: flex; min-height: 0; }
.panel { width: 420px; max-width: 100%; padding: 16px; overflow-y: auto; background: #fff; border-right: 1px solid var(--line); }
#map { flex: 1; min-height: 320px; }

label { display: block; font-weight: 600; margin: 12px 0 4px; }
label:first-child { margin-top: 0; }
input, select, button { font: inherit; }
input, select { width: 100%; padding: 8px 10px; border: 1px solid #bbb; border-radius: 6px; background: #fff; color: var(--ink); }
select { margin-bottom: 6px; }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button { padding: 8px 14px; border-radius: 6px; border: 1px solid var(--ink); background: var(--ink); color: #fff; cursor: pointer; }
button:hover { background: #333; }
button.ghost { background: #fff; color: var(--ink); border-color: #bbb; }
button.ghost:hover { background: #f0f0f0; }
.search { display: flex; gap: 6px; }
.pair { display: flex; gap: 12px; margin-top: 12px; }
.pair > div { flex: 1; }
.pair label { margin-top: 0; }
.search input { flex: 1; min-width: 0; }
.found { list-style: none; margin: 4px 0 0; padding: 0; }
.found button { width: 100%; text-align: left; background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 6px; margin-top: 4px; font-size: 14px; }
.found button:hover { background: #fff4e5; border-color: var(--accent); }
.hint { color: var(--mute); font-size: 13px; margin: 8px 0 0; }
.msg { margin: 14px 0 0; padding: 8px 10px; border-radius: 6px; background: #f0f0f0; }
.msg.bad { background: #fdecea; color: var(--bad); }

#result { margin-top: 16px; }
.route { display: flex; gap: 24px; padding: 10px 12px; background: #fff4e5; border-radius: 8px; }
.route b { display: block; font-size: 22px; }
.route span { font-size: 13px; color: var(--mute); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 8px 0 0; font-size: 13px; color: var(--mute); }
.legend i { display: inline-block; width: 22px; height: 5px; border-radius: 3px; vertical-align: middle; margin-right: 6px; }
.l-before { background: #555; }
.l-billed { background: var(--accent); outline: 1.5px solid #111; }
table { width: 100%; border-collapse: collapse; margin-top: 12px; }
th, td { text-align: right; padding: 7px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th:first-child, td:first-child { text-align: left; }
th { font-size: 12px; color: var(--mute); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.calc td { white-space: nowrap; }
.calc td:first-child { white-space: normal; font-weight: 600; }
.calc td small { display: block; font-weight: 400; font-size: 12px; color: var(--mute); }
.calc td:last-child { font-weight: 700; }
tr.none td { color: var(--mute); font-weight: 400; }
#copy { margin-top: 12px; }
#later h2 { margin: 0 0 6px; font-size: 18px; }
#later p { margin: 0 0 8px; }

.pin { width: 28px; height: 28px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--ink); color: #fff; font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); cursor: grab; }
.pin.to { background: var(--accent); color: #000; }
.pin span { transform: rotate(45deg); line-height: 1; }

/* страница настроек */
.page { max-width: 980px; width: 100%; margin: 0 auto; padding: 20px 16px 40px; }
.page h2 { font-size: 18px; margin: 28px 0 4px; }
.page h2:first-child { margin-top: 0; }
.page table input { text-align: right; min-width: 90px; }
.page table td:first-child input, .page table input.text { text-align: left; }
.page td { padding: 4px 4px; border-bottom: 0; }
.page td.x { width: 1%; }
.page .row { display: flex; gap: 8px; margin-top: 10px; align-items: center; flex-wrap: wrap; }
.page .save { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; margin-top: 24px; border-top: 1px solid var(--line); }
.page .ro { padding: 8px 10px; background: #fff4e5; border-radius: 6px; }
.page .scroll { overflow-x: auto; }
.page .ok { color: #1b6e2d; }

@media (max-width: 760px) {
  body { height: auto; }
  main { flex-direction: column; }
  .panel { width: 100%; border-right: 0; border-bottom: 1px solid var(--line); overflow: visible; }
  #map { flex: none; height: 60vh; }
  header h1 { font-size: 16px; }
  header img { height: 56px; }
}
[hidden] { display: none !important; }
