:root {
  --red: #e3262f;
  --red-dark: #c81e27;
  --red-text: #c81e27;
  --red-soft: #fdecec;
  --ink: #1d2230;
  --muted: #6b7280;
  --line: #e7e9ee;
  --bg: #f4f5f8;
  --card: #fff;
  --blue: #1e6fe8;
  --green: #22a45d;
  --surface: #fff;
  --surface-2: #f4f5f8;
  --surface-3: #eef0f4;
  --border: #dfe2e8;
  --border-strong: #c5cad3;
  --text-2: #3b4150;
  --text-3: #5b6272;
  --faint: #9aa1ad;
  --red-tint: #fff7f7;
  --backdrop: rgba(16, 20, 30, .45);
  --hint-bg: rgba(29, 34, 48, .88);
  --toast-bg: #1d2230;
  --popup-shadow: 0 12px 32px rgba(16, 24, 40, .16);
  --logo-rail: #2a2f3a;
  --radius: 14px;
  color-scheme: light;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 6px 20px rgba(16, 24, 40, .06);
  font-family: Inter, "Segoe UI", Roboto, system-ui, -apple-system, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

/* ---------- шапка */
.top {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 28px;
  height: 64px; padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 800; font-size: 26px; letter-spacing: -.6px; white-space: nowrap; }
.logo b { color: var(--red); font-weight: 800; }
.logo .logo-mark { width: 56px; height: 40px; display: block; flex: none; }
.search { position: relative; flex: 1; max-width: 760px; }
.search input {
  width: 100%; height: 44px; padding: 0 16px 0 46px; border: 0; border-radius: 10px;
  background: var(--surface-3); outline: none; font-size: 15px;
}
.search input:focus { background: var(--surface); box-shadow: 0 0 0 2px var(--red) inset; }
.search > svg { position: absolute; left: 14px; top: 12px; color: var(--ink); }
.results {
  position: absolute; left: 0; right: 0; top: 50px; max-height: 360px; overflow: auto; z-index: 60;
  background: var(--surface); border-radius: 12px; box-shadow: var(--popup-shadow); padding: 6px;
}
.results button {
  display: flex; width: 100%; align-items: center; gap: 10px; padding: 10px 12px;
  border: 0; background: none; border-radius: 8px; text-align: left;
}
.results button:hover, .results button.active { background: var(--surface-2); }
.results .sub { color: var(--muted); font-size: 13px; margin-left: auto; }
.results .empty { padding: 12px; color: var(--muted); }
.nav { display: flex; align-items: stretch; gap: 26px; height: 100%; margin-left: auto; }
.nav a {
  display: flex; align-items: center; gap: 8px; color: var(--text-2); text-decoration: none; font-size: 15px;
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.nav a.active { color: var(--red); border-color: var(--red); }
.nav a:hover { color: var(--red); }
.account { position: relative; }
.login {
  display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 16px 0 6px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); font-weight: 600;
}
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-3); display: grid; place-items: center; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.menu {
  position: absolute; right: 0; top: 52px; min-width: 240px; background: var(--surface); border-radius: 12px;
  box-shadow: var(--popup-shadow); padding: 8px; z-index: 60;
}
.menu .who { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; font-size: 14px; color: var(--muted); }
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; padding: 10px; border-radius: 8px; text-align: left; }
.menu button:hover { background: var(--surface-2); }

/* ---------- раскладка */
.layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 460px; gap: 20px;
  padding: 16px 20px 24px; max-width: 1760px; margin: 0 auto;
}
.left { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.layout > *, .left > * { min-width: 0; } /* элементы сетки не распирает содержимым */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ---------- карта */
.mapwrap { position: relative; height: calc(100vh - 64px - 16px - 20px - 230px); min-height: 460px; overflow: hidden; }
#map { position: absolute; inset: 0; }
.map-msg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); text-align: center; padding: 20px; }
.maptypes {
  position: absolute; left: 16px; top: 16px; z-index: 5; display: flex; gap: 12px;
}
.seg { display: flex; background: var(--surface); border-radius: 12px; padding: 4px; box-shadow: var(--shadow); }
.seg button {
  display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px; border: 1px solid transparent;
  background: none; border-radius: 9px; color: var(--text-2); font-size: 14px;
}
.seg button.on { border-color: var(--red); color: var(--red); background: var(--surface); box-shadow: 0 1px 3px rgba(227, 38, 47, .15); }
.iconbtn {
  width: 46px; height: 46px; border: 0; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow);
  display: grid; place-items: center; color: var(--ink);
}
.iconbtn.on { color: var(--red); box-shadow: 0 0 0 2px var(--red) inset, var(--shadow); }
.mapctl { position: absolute; right: 16px; bottom: 40px; z-index: 5; display: flex; flex-direction: column; gap: 12px; }
.zoom { display: flex; flex-direction: column; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.zoom button { width: 46px; height: 46px; border: 0; background: none; display: grid; place-items: center; }
.zoom button + button { border-top: 1px solid var(--line); }
.map-hint {
  position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 5;
  background: var(--hint-bg); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; white-space: nowrap;
}

/* метки на карте */
.pm-stop {
  width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%;
  background: #fff; border: 3px solid var(--red); box-shadow: 0 1px 3px rgba(0, 0, 0, .25); cursor: pointer;
}
.pm-stop.dim { border-color: #9aa1ad; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-width: 2.5px; }
.pm-stop:hover { transform: scale(1.3); }
.pm-sel {
  display: inline-flex; align-items: center; gap: 10px; transform: translate(-22px, -50%);
  background: #fff; border-radius: 24px; padding: 4px 16px 4px 4px; box-shadow: 0 4px 14px rgba(0, 0, 0, .18);
  font-weight: 700; font-size: 15px; white-space: nowrap; color: #1d2230;
}
.pm-sel i { width: 36px; height: 36px; border-radius: 50%; background: var(--red); display: grid; place-items: center; color: #fff; }
.pm-sel svg { width: 20px; height: 20px; }
.pm-tram {
  position: relative; width: 28px; height: 28px; margin: -14px 0 0 -14px; border-radius: 50%;
  background: var(--red); color: #fff; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .3);
  display: grid; place-items: center; font-weight: 800; font-size: 12.5px; letter-spacing: -.3px; cursor: pointer;
}
.pm-tram span { position: relative; z-index: 1; }
/* стрелка направления «обходит» кружок по кругу — как у Яндекса */
.pm-dir { position: absolute; inset: -9px; pointer-events: none; will-change: transform; }
.pm-dir::before {
  content: ""; position: absolute; left: 50%; top: 0; transform: translateX(-50%);
  border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 8px solid var(--red);
  filter: drop-shadow(0 -1px 0 #fff);
}
.pm-tram.other { background: #5b6272; }
.pm-tram.other .pm-dir::before { border-bottom-color: #5b6272; }
/* тот же маршрут, но едет в обратную сторону — развернётся на конечной */
.pm-tram.rev { background: #f07f85; }
.pm-tram.rev .pm-dir::before { border-bottom-color: #f07f85; }
/* вне рейса (в депо / из депо): бледная, без стрелки */
.pm-tram.off { background: #9aa1ad; opacity: .85; font-size: 11px; }
.pm-tram.off .pm-dir { display: none; }

/* ---------- панель настройки */
.panel { align-self: start; position: sticky; top: 80px; }
.panel-head { display: flex; gap: 20px; padding: 24px 24px 18px; border-bottom: 1px solid var(--line); }
.panel-head .panel-mark { width: 70px; height: 50px; flex: none; }
.panel-head h1 { margin: 0 0 6px; font-size: 23px; letter-spacing: -.3px; }
.panel-head p { margin: 0; color: var(--muted); font-size: 14.5px; line-height: 1.4; }
.steps { padding: 6px 24px 24px; }
.step { padding-top: 18px; }
.step h3 { display: flex; align-items: center; gap: 14px; margin: 0 0 12px; font-size: 16.5px; }
.num {
  width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(180deg, #ff3d44, #d9131c); color: #fff;
  display: grid; place-items: center; font-size: 14px; font-weight: 700; flex: none;
  /* окантовка: мягкий ореол в тон + лёгкая тень */
  box-shadow: 0 0 0 4px var(--red-soft), 0 3px 8px rgba(227, 38, 47, .35);
}
.row { display: flex; align-items: center; gap: 12px; }
.row > svg { color: var(--ink); }
.field {
  position: relative; flex: 1; display: flex; align-items: center; height: 44px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); min-width: 0;
}
.field:focus-within { border-color: var(--red); box-shadow: 0 0 0 3px rgba(227, 38, 47, .12); }
.field input { border: 0; outline: none; flex: 1; min-width: 0; height: 100%; font-weight: 500; background: none; }
.field .x { border: 0; background: none; color: var(--faint); padding: 4px; display: grid; }
.field select { appearance: none; border: 0; outline: none; background: var(--surface); color: var(--ink); width: 100%; height: 100%; font-weight: 500; padding-right: 22px; }
/* свои выпадающие списки: нативный select скрыт и хранит значение */
.field select.cs-native { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.cs-btn { flex: 1; min-width: 0; height: 100%; border: 0; background: none; padding: 0 24px 0 0; text-align: left; font-weight: 500; color: var(--ink); outline: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.field.open { border-color: var(--red); box-shadow: 0 0 0 3px rgba(227, 38, 47, .12); }
.field .chev { transition: transform .15s; }
.field.open .chev { transform: rotate(180deg); }
.cs-list {
  position: absolute; left: -1px; right: -1px; top: calc(100% + 6px); z-index: 70; max-height: 288px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--popup-shadow); padding: 6px;
  overscroll-behavior: contain;
}
.cs-list.up { top: auto; bottom: calc(100% + 6px); }
.cs-opt {
  display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: none; color: var(--ink);
  text-align: left; padding: 9px 10px; border-radius: 8px; font-weight: 500; white-space: nowrap;
}
.cs-opt.active { background: var(--surface-2); }
.cs-opt.sel { color: var(--red); font-weight: 700; }
.cs-opt.sel::after { content: "✓"; margin-left: auto; }
.cs-list::-webkit-scrollbar { width: 8px; }
.cs-list::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 2px solid var(--surface); }
.field .chev { position: absolute; right: 12px; pointer-events: none; color: var(--ink); width: 18px; height: 18px; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0 0 34px; }
.stop-results { top: 48px; }

.dirs { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 0 34px; }
.chip {
  border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 7px 12px; font-size: 13.5px;
}
.chip.on { border-color: var(--red); background: var(--red-soft); color: var(--red-text); font-weight: 600; }
.arrivals { margin: 10px 0 0 34px; font-size: 13.5px; color: var(--text-2); background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.arrivals b { color: var(--ink); }
.arrivals .live { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--green); margin-right: 6px; animation: pulse 2s infinite; }
.arrivals ul { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; }
.arrivals li { display: flex; gap: 8px; align-items: center; }
.arrivals li .to { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; }
.arrivals em { font-style: normal; font-size: 11.5px; font-weight: 600; padding: 1px 7px; border-radius: 99px; white-space: nowrap; }
.arrivals em.slow { background: #fff1db; color: #a15c00; }
.arrivals em.turn { background: var(--surface-3); color: var(--text-2); }
.arrivals em.warn { background: var(--red-soft); color: var(--red-text); }
:root[data-theme="dark"] .arrivals em.slow { background: #3a2c14; color: #ffc46b; }
.arrivals li .eta { margin-left: auto; font-weight: 700; color: var(--ink); white-space: nowrap; }
@keyframes pulse { 50% { opacity: .35; } }

.routes { display: flex; flex-wrap: wrap; gap: 10px; }
.rchip {
  display: inline-flex; align-items: center; height: 46px; border-radius: 10px; background: var(--red); color: #fff;
  font-weight: 800; font-size: 20px; overflow: hidden;
}
.rchip span { padding: 0 14px; }
.rchip small { font-size: 11px; font-weight: 500; opacity: .9; margin-left: -8px; padding-right: 10px; max-width: 120px; line-height: 1.1; }
.rchip button { height: 100%; width: 38px; border: 0; background: rgba(0, 0, 0, .08); color: #fff; display: grid; place-items: center; }
.rchip button:hover { background: rgba(0, 0, 0, .18); }
.addbtn {
  flex: 1; min-width: 180px; height: 46px; display: flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--border); background: var(--surface); border-radius: 10px; color: var(--text-2);
}
.addbtn:hover { border-color: var(--border-strong); }
.addbtn:disabled { color: var(--faint); cursor: default; }
.picker { position: relative; flex: 1; min-width: 180px; display: flex; }
.picker .results { top: 52px; }
.rbadge { display: inline-grid; place-items: center; min-width: 28px; height: 28px; padding: 0 6px; border-radius: 7px; background: var(--red); color: #fff; font-weight: 800; font-size: 14px; }

.periods { display: grid; gap: 14px; }
.period-block { display: grid; gap: 8px; }
.days { display: flex; gap: 6px; margin-left: 34px; margin-right: 42px; }
.day {
  flex: 1; min-width: 0; height: 32px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
  color: var(--text-3); font-size: 13px; font-weight: 600; padding: 0;
}
.day:hover { border-color: var(--border-strong); }
.day.on { background: var(--red-soft); border-color: var(--red); color: var(--red-text); }
.day.we:not(.on) { color: var(--faint); }
.period { display: grid; grid-template-columns: 24px 1fr 14px 1fr 32px; align-items: center; gap: 10px; }
.period .dash { text-align: center; }
.trash { border: 0; background: none; color: var(--faint); display: grid; place-items: center; height: 40px; border-radius: 8px; }
.trash:hover { color: var(--red); background: var(--red-soft); }
.addperiod {
  margin-left: 34px; height: 44px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
  display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--text-2);
}

.channels { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.channel {
  display: flex; align-items: center; gap: 12px; height: 60px; padding: 0 14px; border: 1px solid var(--border);
  border-radius: 12px; background: var(--surface); position: relative; text-align: left;
}
.channel.on { border-color: var(--red); background: var(--red-tint); }
.channel:disabled { cursor: default; opacity: .75; }
.channel .logo-c { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.channel .name { font-weight: 600; }
.channel .soon { position: absolute; top: -9px; right: 10px; background: var(--surface-3); color: var(--text-3); font-size: 11px; padding: 2px 8px; border-radius: 99px; }
.check { margin-left: auto; width: 22px; height: 22px; border-radius: 5px; border: 2px solid var(--border-strong); display: grid; place-items: center; flex: none; }
.channel.on .check { background: var(--red); border-color: var(--red); color: #fff; }
.channel.max-c .check.blue { background: var(--blue); border-color: var(--blue); color: #fff; }
.check svg { width: 14px; height: 14px; stroke-width: 3; }
.tgstate { margin: 8px 0 0 2px; font-size: 13px; color: var(--muted); }
.tgstate.ok { color: var(--green); }

.grid2 { display: grid; grid-template-columns: 1fr; gap: 10px; }
.create {
  width: 100%; height: 58px; margin-top: 22px; border: 0; border-radius: 12px; background: var(--red); color: #fff;
  font-size: 18px; font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 12px;
  box-shadow: 0 6px 16px rgba(227, 38, 47, .28);
}
.create:hover { background: var(--red-dark); }
.create:disabled { opacity: .5; box-shadow: none; cursor: default; }
.cancel-edit { width: 100%; margin-top: 10px; border: 0; background: none; color: var(--muted); padding: 8px; }
.err { color: var(--red-text); font-size: 13.5px; margin-top: 10px; text-align: center; }

/* ---------- мои уведомления */
.subs { padding: 18px 20px 12px; }
.subs-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.subs-head h2 { margin: 0; font-size: 19px; }
.subs-head svg { color: var(--red); fill: var(--red); }
.count { background: var(--surface-3); border-radius: 99px; padding: 2px 10px; font-weight: 700; font-size: 14px; }
.subs-head a { margin-left: auto; color: var(--blue); text-decoration: none; font-size: 14.5px; display: flex; gap: 6px; align-items: center; }
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 13.5px; background: var(--surface-2); padding: 10px 14px; white-space: nowrap; }
th:first-child { border-radius: 8px 0 0 8px; } th:last-child { border-radius: 0 8px 8px 0; text-align: right; }
td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td .sub2 { color: var(--muted); font-size: 12.5px; }
td.routes-td { white-space: nowrap; }
td.routes-td .rbadge { margin-right: 4px; min-width: 36px; height: 36px; font-size: 17px; border-radius: 8px; }
.ch { display: inline-flex; align-items: center; gap: 8px; }
.status { display: inline-flex; align-items: center; gap: 8px; border: 0; background: none; padding: 4px 6px; border-radius: 8px; white-space: nowrap; }
.status:hover { background: var(--surface-2); }
.status i { width: 9px; height: 9px; border-radius: 50%; background: var(--green); }
.status.off i { background: var(--faint); }
.actions { display: flex; justify-content: flex-end; gap: 8px; }
.actions button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); display: grid; place-items: center; color: var(--text-2); }
.actions button:hover { border-color: var(--border-strong); }
.actions button.danger { color: var(--red); border-color: var(--red); background: var(--red-soft); width: auto; padding: 0 10px; font-size: 13px; }
.subs-empty { color: var(--muted); padding: 18px 4px 14px; font-size: 14.5px; }
.subs-empty a { color: var(--blue); }

/* ---------- модалки и тосты */
.modal-bg { position: fixed; inset: 0; background: var(--backdrop); z-index: 100; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--surface); border-radius: 18px; width: min(460px, 100%); padding: 26px; box-shadow: 0 24px 60px rgba(0, 0, 0, .25); max-height: 90vh; overflow: auto; }
.modal h2 { margin: 0 0 8px; font-size: 21px; }
.modal p, .modal li { color: var(--text-2); line-height: 1.5; font-size: 14.5px; }
.code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 34px; letter-spacing: 6px; font-weight: 800; text-align: center; padding: 14px; background: var(--surface-2); border-radius: 12px; margin: 14px 0; user-select: all; }
.btn { height: 48px; border-radius: 12px; border: 0; padding: 0 18px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 10px; text-decoration: none; }
.btn.tg { background: #2aabee; color: #fff; width: 100%; }
.btn.ghost { background: var(--surface-3); color: var(--ink); width: 100%; margin-top: 10px; }
.wait { display: flex; align-items: center; gap: 10px; justify-content: center; color: var(--muted); margin-top: 14px; font-size: 14px; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--red); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--toast-bg); color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 200; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); max-width: calc(100% - 32px); }
.toast.bad { background: var(--red-dark); }


/* ---------- тёмная тема (по умолчанию светлая; выбор хранится в браузере и в профиле) */
:root[data-theme="dark"] {
  --ink: #e8eaf0; --muted: #9ba3b4; --line: #2a303c; --bg: #0f1218; --card: #171b23;
  --surface: #1d222c; --surface-2: #222834; --surface-3: #2a303c;
  --border: #343b49; --border-strong: #4a5263; --text-2: #c3c8d3; --text-3: #a3aab8; --faint: #6f7788;
  --red-soft: #3a1a1d; --red-tint: #2b1a1e; --red-text: #ff7a80; --logo-rail: #9aa3b5; --backdrop: rgba(0, 0, 0, .6); --hint-bg: rgba(10, 12, 18, .9);
  --toast-bg: #2a303c; --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .35);
  --popup-shadow: 0 12px 32px rgba(0, 0, 0, .55); --blue: #5b9bff; --green: #34c374;
  color-scheme: dark;
}
.theme-btn { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); display: grid; place-items: center; color: var(--ink); flex: none; }
.theme-btn:hover { border-color: var(--border-strong); }

/* ---------- адаптив */
@media (max-width: 1180px) {
  .layout { grid-template-columns: 1fr; }
  .panel { position: static; }
  .mapwrap { height: 56vh; min-height: 360px; }
  .left { display: contents; }
  .mapcard { order: 1; } .panel { order: 2; } .subs { order: 3; }
}
@media (max-width: 860px) {
  /* шапка в две строки: логотип и кнопки сверху, поиск — во всю ширину */
  .top { position: relative; flex-wrap: wrap; height: auto; gap: 8px 6px; padding: 8px 12px 10px; }
  .logo { order: 1; font-size: 18px; gap: 6px; letter-spacing: -.4px; min-width: 0; }
  .logo .logo-mark { width: 42px; height: 30px; }
  .nav { order: 2; gap: 0; height: 38px; margin-left: auto; }
  .nav a { border: 0; width: 36px; justify-content: center; border-radius: 10px; }
  .nav a:hover { background: var(--surface-2); }
  .nav a span { display: none; }
  #navMap { display: none; }
  .theme-btn { order: 3; width: 38px; height: 38px; border-radius: 10px; }
  .account { order: 4; }
  .login { height: 38px; padding: 0 3px; border-radius: 10px; }
  .avatar { width: 30px; height: 30px; }
  .login .lbl { display: none; }
  .search { order: 5; flex: 1 0 100%; max-width: none; }
  .search input { height: 42px; font-size: 16px; } /* 16px — чтобы iOS не зумил при фокусе */
  .search > svg { top: 11px; }
  .results { top: 48px; }

  .layout { padding: 10px 10px 24px; gap: 12px; }
  .mapwrap { height: 48vh; min-height: 300px; border-radius: 12px; }
  .maptypes { left: 10px; top: 10px; gap: 8px; }
  .seg { padding: 3px; border-radius: 10px; }
  .seg button { height: 34px; padding: 0 10px; }
  .seg button span { display: none; }
  .iconbtn { width: 40px; height: 40px; border-radius: 10px; }
  .mapctl { right: 10px; bottom: 34px; gap: 8px; }
  .zoom { border-radius: 10px; }
  .zoom button { width: 40px; height: 40px; }
  .map-hint { bottom: 44px; font-size: 13px; padding: 8px 12px; }

  .panel-head { gap: 14px; padding: 16px; align-items: center; }
  .panel-head .panel-mark { width: 48px; height: 34px; }
  .panel-head h1 { font-size: 19px; margin-bottom: 3px; }
  .panel-head p { font-size: 13.5px; }
  .steps { padding: 0 14px 18px; }
  .step { padding-top: 16px; }
  .step h3 { font-size: 16px; margin-bottom: 10px; }
  .field input, .cs-btn { font-size: 16px; }
  .dirs, .arrivals, .hint { margin-left: 0; }
  .period { grid-template-columns: 20px minmax(0, 1fr) 10px minmax(0, 1fr) 32px; gap: 8px; }
  .days { margin: 0 0 0 28px; gap: 5px; }
  .day { height: 36px; }
  .addperiod { margin-left: 0; width: 100% !important; }
  .channels { grid-template-columns: 1fr 1fr; gap: 10px; }
  .channel { height: 54px; padding: 0 10px; gap: 8px; }
  .channel .logo-c { width: 30px; height: 30px; }
  .create { height: 54px; font-size: 17px; }

  /* «Мои уведомления» — карточками */
  .subs { padding: 14px 12px 6px; }
  thead { display: none; }
  table, tbody { display: block; width: 100%; }
  tr {
    display: grid; grid-template-columns: auto 1fr 1fr auto; gap: 6px 10px; padding: 12px 2px;
    grid-template-areas: "r s s a" "r p p p" "r c l t"; border-bottom: 1px solid var(--line); align-items: center;
  }
  tr:last-child { border-bottom: 0; }
  td { display: block; border: 0; padding: 0; font-size: 14px; }
  td:nth-child(1) { grid-area: r; align-self: start; }
  td:nth-child(2) { grid-area: s; }
  td:nth-child(3) { grid-area: p; color: var(--text-2); }
  td:nth-child(4) { grid-area: c; }
  td:nth-child(5) { grid-area: l; }
  td:nth-child(6) { grid-area: t; }
  td:nth-child(7) { grid-area: a; align-self: start; }
  td.routes-td { white-space: normal; display: flex; flex-direction: column; gap: 4px; }
  td.routes-td .rbadge { margin: 0; }
  .ch .logo-c { width: 22px !important; height: 22px !important; }
  .status { padding: 2px 0; }
}
@media (max-width: 370px) {
  .logo span { display: none; }
  .channels { grid-template-columns: 1fr; }
}
