/* Візуальний стиль — за макетом docs/ui-design (теплий «папір», IBM Plex Sans, світла шапка). */

/* IBM Plex Sans 5.3.0 (OFL-1.1, static/vendor/fonts/LICENSE-IBM-Plex.txt) — локальні файли, без зовнішніх запитів. */
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 400; font-display: swap;
  src: url(vendor/fonts/ibm-plex-sans-cyrillic-ext-400-normal.woff2?v=e2580ad78906) format("woff2"); unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 400; font-display: swap;
  src: url(vendor/fonts/ibm-plex-sans-cyrillic-400-normal.woff2?v=69afad88a074) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 400; font-display: swap;
  src: url(vendor/fonts/ibm-plex-sans-latin-400-normal.woff2?v=3b646991d300) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 500; font-display: swap;
  src: url(vendor/fonts/ibm-plex-sans-cyrillic-ext-500-normal.woff2?v=08578d906af6) format("woff2"); unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 500; font-display: swap;
  src: url(vendor/fonts/ibm-plex-sans-cyrillic-500-normal.woff2?v=200be3a2a6b1) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 500; font-display: swap;
  src: url(vendor/fonts/ibm-plex-sans-latin-500-normal.woff2?v=0717336fb31f) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 600; font-display: swap;
  src: url(vendor/fonts/ibm-plex-sans-cyrillic-ext-600-normal.woff2?v=d60d3d0b1827) format("woff2"); unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 600; font-display: swap;
  src: url(vendor/fonts/ibm-plex-sans-cyrillic-600-normal.woff2?v=730becc6f005) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 600; font-display: swap;
  src: url(vendor/fonts/ibm-plex-sans-latin-600-normal.woff2?v=8960851d691c) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  /* Шари: --bg найтемніший, --panel світліший на крок, --card — ще на крок. */
  --bg: #ece8e1;
  --panel: #f4f1eb;
  --card: #fbf9f5;
  --line: #d8d2c7;
  --line-soft: #e7e2d9;    /* розділи всередині картки — світліші за її рамку, щоб край картки читався як межа */
  --text: #2a2824;
  --muted: #6b665d;
  --accent: #2f6293;       /* лише дії, активні стани, посилання, фокус */
  --accent-soft: #dce6f0;
  --danger: #b3261e;
  --danger-soft: #f4dbd7;
  --warn: #8a5a00;
  --warn-soft: #f5e6c3;
  --info: #2f6293;
  --info-soft: #dce6f0;
  --success: #2e6b3f;
  --success-soft: #dae9db;
  --hover: #e8e4dc;
  --active: #ded9cf;
  --shadow-sm: 0 1px 2px rgba(50, 40, 20, .10);
  --shadow-md: 0 4px 14px rgba(50, 40, 20, .14);
  --radius: 6px;
  --route: #3451d1;        /* лінія й точки маршруту; те саме значення — MAP_COLORS.route в app.js */
  --unverified: #7c8290;
  --font: "IBM Plex Sans", system-ui, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 14px/20px var(--font); font-variant-numeric: tabular-nums; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); }
::placeholder { color: var(--muted); opacity: 1; }
a { color: var(--accent); }

/* ---------------------------------------------------------------- каркас */

header { height: 48px; display: flex; align-items: center; gap: 14px; padding: 0 14px; background: var(--panel); border-bottom: 1px solid var(--line); }
header .brand { font-weight: 600; font-size: 15px; letter-spacing: -.01em; }
header .muted-light { color: var(--muted); font-size: 12px; }
/* кнопка облікового запису — логін; довгий обрізається */
#account { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
header .spacer { flex: 1; }
header label { display: flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; }
/* «Інструкція»: на телефоні — лише «?», підпис не вмістився б поряд з «Excel» і логіном */
.help-q { display: none; }

.layout { display: grid; grid-template-columns: 450px 1fr; height: calc(100vh - 48px); }
aside { position: relative; z-index: 1; display: flex; flex-direction: column; min-height: 0; background: var(--panel);
  border-right: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; height: 44px; border: 0; border-radius: 0; background: none; padding: 0 4px; font-weight: 500; color: var(--muted); }
.tabs button:hover { background: var(--hover); color: var(--text); }
.tabs button.active { color: var(--accent); font-weight: 600; background: var(--card); box-shadow: inset 0 -2px 0 var(--accent); }
#panel { flex: 1; overflow: auto; padding: 12px 12px 40px; }

.map-wrap { position: relative; z-index: 0; }
#map { position: absolute; inset: 0; }
#map.picking, #map.picking .leaflet-grab, #map.picking .leaflet-interactive { cursor: crosshair; }
/* по центру через left/right + margin: з left: 50% смужка могла займати лише половину карти — підказка ставала стовпчиком */
#modeBar { position: absolute; top: 12px; left: 0; right: 0; width: max-content; margin: 0 auto; z-index: 1000; display: flex; gap: 8px; align-items: center;
  max-width: 90%; padding: 6px 8px 6px 12px; background: var(--card); border: 1px solid var(--accent); border-radius: var(--radius); box-shadow: var(--shadow-md); }
#modeBar::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
#mbKm { flex: none; white-space: nowrap; }
#mbKm:empty { display: none; }
#modeBar .mb-warn { color: var(--danger); background: var(--danger-soft); border-color: var(--danger); }
#modeBar .mb-err { color: var(--warn); background: var(--warn-soft); border-color: var(--warn); }
#modeBar .mb-tip-btn { flex: none; width: 32px; padding: 0; border-radius: 50%; }
#modeBar .mb-tip { cursor: pointer; }

/* ---------------------------------------------------------------- кнопки й поля */

button, a.button { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-height: 32px; padding: 0 12px;
  font: inherit; font-weight: 500; color: inherit; text-decoration: none; white-space: nowrap;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; }
button:hover, a.button:hover { background: var(--hover); }
button:active { background: var(--active); }
button:disabled { opacity: .45; cursor: default; background: var(--card); }
button.primary, a.button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover, a.button.primary:hover { background: var(--accent); filter: brightness(1.1); }
button.primary:active { filter: brightness(.9); }
button.primary:disabled { filter: none; background: var(--accent); }
button.danger { color: var(--danger); }
button.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.ic { width: 16px; height: 16px; flex: none; }
button.icon-only { width: 32px; padding: 0; }
/* Зберегти / Скасувати редактора маршруту — завжди видно внизу панелі, хоч би який довгий редактор */
/* bottom: -40px — липкий блок не заходить у нижній відступ #panel (40px), без цього під кнопками видно вміст */
.save-bar { position: sticky; bottom: -40px; z-index: 2; display: flex; gap: 8px; margin: 12px -12px 0; padding: 10px 12px;
  background: var(--panel); border-top: 1px solid var(--line); box-shadow: 0 -4px 8px -6px rgba(40, 35, 30, .25); }
.save-bar button { min-height: 36px; }
.sec-tools { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.name-suggest { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12px; line-height: 16px; color: var(--muted); }
.name-suggest b { color: var(--text); font-weight: 500; }
.name-suggest button { min-height: 24px; padding: 0 8px; font-size: 12px; }
.hint-more { margin: 2px 0 6px 24px; }
.hint-more > summary { cursor: pointer; color: var(--muted); font-size: 12px; }
.hint-more > p { margin: 4px 0 0; }

input, select, textarea { font: inherit; color: inherit; width: 100%; padding: 0 10px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); }
input:not([type=checkbox]):not([type=radio]):not([type=file]), select { height: 36px; }
textarea { padding: 8px 10px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--accent); }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; margin: 0; flex: none; }
input[type=file] { padding: 6px 0; border: 0; background: none; }

.toolbar { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.toolbar button, .toolbar a.button { min-height: 36px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > select { flex: 1; min-width: 0; }
.row.checks { gap: 4px 16px; }
#rSort { min-width: 11em; } /* поруч із двома галочками: не стискатися, а перейти на новий рядок */
/* нижній рядок картки маршруту — завжди один: що не влізло, обрізається «…» (повністю — у title) */
.route-meta, .route-note { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* коментар маршруту в картці — один рядок курсивом, щоб не плутали з габаритами */
.route-note { font-style: italic; }
.hint { color: var(--muted); font-size: 12px; line-height: 16px; margin: 4px 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; line-height: 18px; }
.tiny { font-size: 12px; line-height: 16px; }
/* «Знайдено N, показано 40» — службовий рядок над списком: типові відступи <p> плюс gap списку давали зайву дірку */
.list-count { margin: 0; color: var(--muted); font-size: 12px; line-height: 16px; }
.warn-text { color: var(--warn); font-weight: 600; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: 16px; }

/* ---------------------------------------------------------------- картки */

.list { display: flex; flex-direction: column; gap: 8px; }
/* Картки організацій довгі й з внутрішніми розділами — зливались між собою: більший проміжок і тінь, щоб край картки був межею */
#cList { gap: 14px; }
#cList > .card { box-shadow: var(--shadow-sm); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.card > * + * { margin-top: 4px; }
.card.clickable { cursor: pointer; }
.card.clickable:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }
.card.lvl-bad { padding-left: 14px; box-shadow: inset 3px 0 0 var(--danger); }
.card.lvl-warn { padding-left: 14px; box-shadow: inset 3px 0 0 var(--warn); }
.card.lvl-bad.clickable:hover { box-shadow: inset 3px 0 0 var(--danger), var(--shadow-sm); }
.card.lvl-warn.clickable:hover { box-shadow: inset 3px 0 0 var(--warn), var(--shadow-sm); }
.imported-card { background: var(--panel); border-style: dashed; }
.card-head { display: flex; align-items: flex-start; gap: 8px; }
.card-head b { font-size: 14px; line-height: 20px; font-weight: 600; min-width: 0; }
/* align-items не чіпати: кнопки рядка мають розтягуватись до однакової висоти (на дотику «Поділитись» — 44 px) */
/* Лінія перед рядком кнопок: без неї він читається як частина останнього контакту, а не дії самої
   організації — і це помітно саме тоді, коли кнопка «Поділитись» переноситься на другий рядок
   (зауваження користувача 2026-09-18). */
.card-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line-soft); }
/* «оновлено» — дрібним у кінці рядка кнопок (повна дата, час і хто — у title), а не окремим рядком картки */
.card-when { align-self: center; margin-left: auto; font-size: 11px; color: var(--muted); white-space: nowrap; }
.card > .card-actions { margin-top: 10px; }
.tag { margin-left: auto; flex: none; display: inline-flex; align-items: center; height: 22px; padding: 0 8px; font-size: 12px; white-space: nowrap;
  color: var(--muted); background: var(--panel); border: 1px solid var(--line); border-radius: 4px; }
.contacts a { color: var(--accent); text-decoration: none; }
.contacts a:hover { text-decoration: underline; }
/* Контакти організації — на картці (.people) і у вікні «Контакти» (.pd-row): ☆/★, ім'я, кожен телефон окремим рядком */
.people { list-style: none; margin: 8px 0 0; padding: 6px 0 0; border-top: 1px solid var(--line-soft); }
.person-item, .pd-row { display: flex; align-items: flex-start; gap: 4px; }
.person-item + .person-item { margin-top: 10px; }
/* картка організації: трохи більше повітря між блоками; мітки «Коли звертатися:» тощо — сірі, значення — звичайні */
.card[data-org] > .org-type, .card[data-org] > .tiny { margin-top: 6px; }
.meta-label { color: var(--muted); }
.pd-body { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.pd-body > * + * { margin-top: 1px; }
.pd-body .contacts { font-size: 13px; line-height: 18px; }
/* .pd-note було окремим виглядом нотатки контакту — з 2026-09-18 усі нотатки через notesHtml (.notes, .notes-sm) */
/* ім'я — темне: синім у картці лише те, що натискають, щоб подзвонити чи написати (2026-09-19) */
.person-name { font-weight: 600; color: var(--text); text-decoration: none; }
.person-name:hover { text-decoration: underline; }
.pd-acts { display: flex; flex: none; }
.person-item .star-btn, .pd-row .star-btn { margin: -6px 0 0 -6px; }
.linked-tag { display: inline-block; padding: 0 5px; font-size: 11px; font-weight: 500; line-height: 16px; white-space: nowrap;
  color: var(--accent); background: var(--accent-soft); border-radius: 4px; }
/* Нотатка (notesHtml): обрізана до NOTES_CLAMP_LINES рядків; кнопка «розгорнути» — лише коли не вмістилась
   (клас .clipped ставить clampNotes). Текст звичайний — виділяють і копіюють мишею (шапка листа). */
/* Нотатка — як цитата: світла підкладка й смужка зліва. Сіра плашка з рамкою (--hover, до 2026-09-19) була схожа
   на вимкнене поле, а приглушений текст нотатки контакту на ній мав контраст нижче 4,5:1 */
.notes { display: flex; flex-direction: column; margin-top: 8px; background: var(--panel);
  border-left: 3px solid var(--line); border-radius: 0 4px 4px 0; padding: 6px 10px; font-size: 13px; line-height: 18px; --notes-lines: 10; }
/* нотатка контакту — лише смужка під контактом, без підкладки; текст приглушений */
.notes-sm { color: var(--muted); background: none; border-left-width: 2px; padding: 1px 8px; margin-top: 4px; }
.notes-text { white-space: pre-wrap; overflow: hidden; max-height: calc(var(--notes-lines) * 18px); }
.notes.open .notes-text { max-height: none; }
/* останній рядок згасає — видно, що текст триває; маскою по самому тексту, а не підкладкою поверх нього */
.notes.clipped:not(.open) .notes-text { -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 20px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 20px), transparent); }
/* кнопка — у потоці під текстом праворуч: поверх тексту вона накривала слова (2026-09-18) */
.notes-more { display: none; align-self: flex-end; margin: 2px -4px -2px 0; }
.notes.clipped > .notes-more, .notes.open > .notes-more { display: inline-flex; }
.notes.open .notes-more .ic { transform: rotate(180deg); }
.linked { font-weight: 600; }
.icon-btn { min-height: 0; width: 24px; height: 24px; padding: 0; margin-left: 2px; font-size: 12px; flex: none;
  border-color: transparent; background: transparent; color: var(--muted); }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.star-btn { min-height: 0; width: 32px; height: 32px; padding: 0; margin-left: -6px; flex: none; border: 0; border-radius: 50%;
  background: transparent; font-size: 18px; line-height: 1; color: var(--muted); }
.star-btn:hover { background: var(--hover); color: var(--text); }
.star-btn.on, .star-on { color: var(--warn); }
.route-title { display: flex; align-items: center; gap: 2px; }
.route-title .route-name { flex: 1; min-width: 0; }
/* три дії маршруту — в один ряд і на вузькій панелі (45vw на екранах до 1100 px); ще вужче — переносяться */
.route-actions button { flex: 1 1 auto; padding: 0 8px; }
.route-title #rDel { margin-left: 6px; font-size: 14px; } /* кошик — у рядку назви, окремо від дій маршруту */

/* Кружок типу об'єкта: піктограма білим на кольорі типу (кольори — OBJ_TYPES у dicts.js). */
.obj-badge { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 18px; height: 18px;
  border-radius: 50%; color: #fff; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .28), 0 1px 2px rgba(0, 0, 0, .25); }
.obj-badge.sm { width: 18px; height: 18px; border-width: 1px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .18); }
.card-head .obj-badge { margin-top: 1px; }
.obj-marker { background: none; border: 0; }
.obj-badge.unverified { background: #fff !important; color: var(--unverified); border: 2px dashed var(--unverified); box-shadow: none; opacity: .92; }
.obj-badge.sm.unverified { border-width: 1px; }
/* Офіс організації: квадрат з піктограмою типу, більший за кружечки об'єктів (docs/ui-design/office-icons.html).
   Колір --office — колір пари серед об'єктів (icons.js, officeColor): рамка й піктограма кольорові, фон — лише
   блідий відтінок, щоб квадрат не зливався з суцільними кружечками об'єктів того ж кольору. */
.office-badge { --office: var(--text); display: inline-flex; align-items: center; justify-content: center; flex: none; width: 20px; height: 20px;
  box-sizing: border-box; background: #fff; background: color-mix(in srgb, var(--office) 14%, #fff); color: var(--office);
  border: 2px solid var(--office); border-radius: 6px; box-shadow: 0 1px 3px rgba(0, 0, 0, .35); }
.office-badge.sm { width: 20px; height: 20px; border-width: 1.5px; border-radius: 4px; box-shadow: none; }
.office-marker { background: none; border: 0; }
/* Значки, що накладаються (app.js, «павук»): сірий під перевіреним чи офісом і розкладені оригінали не видно */
.leaflet-marker-icon.marker-covered, .leaflet-marker-icon.marker-spread { display: none; }
/* Картка організації: рядок «значок офісу · тип · зони» під назвою; значок — кнопка «офіс на карті», без офісу блідий */
.org-type { display: flex; align-items: flex-start; gap: 6px; margin-top: 2px; }
.org-type > .small { line-height: 20px; min-width: 0; }
button.office-type { display: inline-flex; flex: none; width: auto; height: auto; min-height: 0; padding: 0; border: 0; background: none; border-radius: 4px; }
button.office-type:hover { background: none; }
button.office-type:hover .office-badge { border-color: var(--accent); color: var(--accent); }
.office-type.off { display: inline-flex; flex: none; opacity: .35; }
/* «офіс» у вікнах карти і «Прибрати» у формі — посилання, а не кнопки в рамці */
button.office-show { display: inline; width: auto; height: auto; min-height: 0; padding: 0; border: 0; background: none;
  color: var(--accent); font-weight: 400; cursor: pointer; }
button.office-show:hover { background: none; text-decoration: underline; }
.field.office-field { flex-direction: row; align-items: center; gap: 10px; font-size: 13px; }
.office-state { display: inline-flex; align-items: center; gap: 6px; }
.office-state .office-badge.sm { width: 18px; height: 18px; }
.office-pick .zp-filter { width: 100%; margin: 6px 0; }
.office-list { display: flex; flex-direction: column; gap: 2px; } /* прокручується саме вікно (.popup) */
.legend-offices { margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--line); }
.office-org { display: flex; align-items: center; justify-content: flex-start; gap: 8px; box-sizing: border-box; width: 100%; min-width: 0; height: auto;
  min-height: 0; padding: 5px 6px; text-align: left; background: none; border: 1px solid transparent; font-weight: 400; }
.office-org-name { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; line-height: 18px; }
.office-org:hover { border-color: var(--accent); background: var(--accent-soft); }
.office-org[hidden] { display: none; }
.imported-note { margin-top: 6px; padding: 6px 8px; border-radius: 4px; background: var(--hover); color: var(--muted); font-size: 12px; line-height: 16px; }
/* Розділи картки маршруту, що згортаються (sec у renderRouteDetails): заголовок h4 — у summary, стрілка замість маркера */
details.sec > summary { cursor: pointer; list-style: none; }
details.sec > summary::-webkit-details-marker { display: none; }
details.sec > summary > h4::before { content: "▸"; flex: none; width: 10px; color: var(--muted); }
details.sec[open] > summary > h4::before { content: "▾"; }
details.sec > summary:hover > h4 { color: var(--accent); }
details.sec:not([open]) > summary > h4 { margin-bottom: 0; }
.sec-alert { color: var(--danger); }

/* ---------------------------------------------------------------- розділи, статуси */

h3 { margin: 4px 0 8px; font-size: 15px; line-height: 20px; font-weight: 600; }
h4 { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 15px; line-height: 20px; font-weight: 600; }
h4::after { content: ""; flex: 1; height: 1px; background: var(--line); }
section { margin-top: 20px; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; margin: 4px 0 8px; }
.chip { display: inline-flex; align-items: center; min-height: 22px; padding: 1px 8px; font-size: 12px; line-height: 16px; border-radius: 4px;
  color: var(--muted); background: var(--panel); border: 1px solid var(--line); }
.chip[class*=st-] { font-size: 11.5px; font-weight: 600; border-color: transparent; }
.chip[class*=st-]::before { content: ""; flex: none; width: 6px; height: 6px; margin-right: 5px; border-radius: 50%; background: currentColor; }
.chip.st-approved { background: var(--success-soft); color: var(--success); }
.chip.st-requested { background: var(--info-soft); color: var(--info); }
.chip.st-changes { background: var(--warn-soft); color: var(--warn); }
.chip.st-rejected { background: var(--danger-soft); color: var(--danger); }
.chip.st-expired { background: var(--danger); color: #fff; }
.issue { font-size: 12.5px; line-height: 16px; margin-top: 4px; padding: 5px 8px; border-radius: 4px; }
.issue.bad { background: var(--danger-soft); color: var(--danger); }
.issue.warn { background: var(--warn-soft); color: var(--warn); }
.issue.info { background: var(--info-soft); color: var(--info); }
.issue.ok { background: var(--success-soft); color: var(--success); }
input[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 1px var(--danger); }
.issue-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.issue-actions button { font-size: 12px; padding: 2px 8px; }
.issue.clickable { cursor: pointer; }
.issue.bad.clickable:hover { box-shadow: inset 3px 0 0 var(--danger); }
.draft-card { margin-bottom: 10px; border-color: var(--accent); }
.reminders { margin: 0; padding-left: 18px; }
.reminders li + li { margin-top: 2px; }
.group { margin-bottom: 14px; }
.group-title { margin: 10px 0 6px; font-size: 12px; line-height: 16px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.need { margin-bottom: 8px; padding: 10px 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.need > * + * { margin-top: 4px; }
.need .row { margin-top: 8px; }
/* «Потрібно» — не червоне: червоний лишається лише для проблем на маршруті. */
.badge { flex: none; display: inline-flex; align-items: center; height: 22px; padding: 0 8px; font-size: 11.5px; font-weight: 600; border-radius: 4px; }
.badge.yes { background: var(--accent-soft); color: var(--accent); }
.badge.maybe { background: var(--panel); color: var(--muted); border: 1px solid var(--line); }
table.ap { width: 100%; border-collapse: collapse; font-size: 12.5px; line-height: 16px; margin-top: 8px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); }
table.ap th { padding: 6px 8px; text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--panel); border-bottom: 1px solid var(--line); }
table.ap td { padding: 6px 8px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
table.ap tr:last-child td { border-bottom: 0; }
table.ap tr[data-ap] { cursor: pointer; }
table.ap tr[data-ap]:hover { background: var(--hover); }

/* ---------------------------------------------------------------- форми зв'язків */

/* Згорнутий список вибору: видно лише підсумок і кнопку «Вибрати» (pickerShell в app.js) */
.picker-summary { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 4px 0 10px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.picker-value { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.picker-toggle { flex: none; }
.picker-body { margin-top: 6px; }
.zp-list { max-height: 190px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 8px; margin-top: 6px;
  /* стільки колонок, скільки вміщується (3 у широкому діалозі, 2 у вузькому) — 27 областей без внутрішньої прокрутки */
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 4px 8px; background: var(--card); }
.zp-list.resp-list { display: block; max-height: 220px; }
.resp-org { padding: 4px 0; border-bottom: 1px solid var(--line); }
.resp-org:last-child { border-bottom: 0; }
.check.person { padding-left: 24px; font-size: 13px; }
.resp-picker .row input[type=search] { flex: 1; width: auto; min-width: 0; }
.resp-picker > .tiny { margin-top: 4px; }

/* ---------------------------------------------------------------- діалоги */

dialog { width: min(660px, 94vw); padding: 0; color: var(--text); background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-md); }
dialog::backdrop { background: rgba(40, 35, 30, .35); }
dialog > form > h3 { margin: 0; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; max-height: 65vh; overflow: auto; padding: 14px 18px; }
.form-grid:focus, .zp-list:focus { outline: none; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field > label, .field > .label { display: flex; align-items: center; gap: 4px; font-size: 12px; line-height: 16px; font-weight: 500; color: var(--muted); }
.dlg-actions { display: flex; gap: 8px; }
.dlg-actions .spacer { flex: 1; }
.dlg-actions button { min-height: 36px; }
dialog > form > .dlg-actions { padding: 12px 18px; background: var(--panel); border-top: 1px solid var(--line); }
/* Вікно «Контакти»: шапка й кнопки внизу на місці, прокручується лише список */
#peopleDlg { width: min(560px, 94vw); }
.pd { display: flex; flex-direction: column; max-height: 90vh; max-height: 90dvh; }
.pd-head { display: flex; align-items: flex-start; gap: 8px; padding: 12px 12px 12px 18px; border-bottom: 1px solid var(--line); }
.pd-title { flex: 1; min-width: 0; }
.pd-title h3 { margin: 0; }
.pd-list { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 0 18px; }
.pd-row { padding: 12px 0 10px; border-bottom: 1px solid var(--line); }
.pd-row:last-child { border-bottom: 0; }
.pd-empty { margin: 16px 0; }
.pd-edit { margin: 10px -8px; padding: 10px 8px; background: var(--panel); border: 1px solid var(--accent); border-radius: var(--radius); }
.pd-edit-title { margin-bottom: 8px; font-weight: 600; overflow-wrap: anywhere; }
.pd-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.pd-edit textarea { min-height: 96px; max-height: 50vh; max-height: 50dvh; line-height: 20px; }
.pd-edit .dlg-actions { flex-wrap: wrap; margin-top: 10px; }
.pd > .dlg-actions { padding: 12px 18px; background: var(--panel); border-top: 1px solid var(--line); }
.xls { padding: 16px 18px; }
.xls > h3 { margin-top: 0; }
.xls section { margin-top: 14px; }
.xls h4::after { display: none; }
.xls input[type=file] { margin: 6px 0 10px; }
.xls > .dlg-actions { margin-top: 16px; }
#xlsReport { max-height: 45vh; overflow: auto; }
/* «Маршрут з тексту»: текст замовника → перелік пунктів на перевірку (✓ знайдено, ? перевірити, ✗ немає) */
.rt-body { display: flex; flex-direction: column; gap: 8px; max-height: 70vh; max-height: 70dvh; overflow: auto; padding: 14px 18px; }
.rt-body textarea { width: 100%; min-height: 110px; }
.rt-list { list-style: none; margin: 4px 0 0; padding: 0; }
.rt-row { display: flex; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line-soft); }
.rt-mark { flex: none; display: flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%;
  font-size: 12px; font-weight: 600; }
.rt-row.ok .rt-mark { color: var(--success); background: var(--success-soft); }
.rt-row.warn .rt-mark { color: var(--warn); background: var(--warn-soft); }
.rt-row.miss .rt-mark { color: var(--danger); background: var(--danger-soft); }
.rt-row.skip .rt-mark, .rt-row.info .rt-mark { color: var(--muted); background: var(--hover); }
.rt-row.info .rt-raw { color: var(--muted); }
.rt-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.rt-raw { overflow-wrap: anywhere; }
.rt-main select { width: 100%; }
.rt-open { margin: 0 0 10px; }
.account-body { max-height: 65vh; overflow: auto; padding: 14px 18px; }
.account-body h4 { margin: 0 0 8px; }
.account-body h4::after { display: none; }
#accountDlg .dlg-actions { flex-wrap: wrap; }
/* вхід: пристрій чекає дозволу — не помилка вводу */
.error.notice { color: var(--warn); }
.xls-list { margin: 6px 0; padding-left: 18px; font-size: 12.5px; }
.xls-list li { margin: 2px 0; }

/* Прокрутка: з інструкцією й QR-кодом форма вища за екран телефона — поле коду внизу мало бути досяжним.
   margin: auto замість align-items: center — центр, коли вміщується, і не обрізаний верх, коли ні */
.overlay { position: fixed; inset: 0; z-index: 5000; display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; padding: 16px; background: var(--bg); }
.overlay > .login-box { margin: auto; }
.login-box { width: 360px; max-width: 100%; display: flex; flex-direction: column; gap: 12px; padding: 24px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.login-box h2 { margin: 0; font-size: 18px; line-height: 24px; font-weight: 600; letter-spacing: -.01em; }
.login-box p { margin: 0 0 6px; font-size: 12px; line-height: 16px; }
.login-box input:not([type=checkbox]) { height: 40px; padding: 0 12px; }
.login-box button { min-height: 40px; }
.error { color: var(--danger); min-height: 1.2em; }
.totp-setup { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.totp-setup[hidden], #lQr[hidden] { display: none; }
.totp-setup p { align-self: stretch; }
#lQr, #iQr { width: 196px; height: 196px; image-rendering: pixelated; }
.totp-help-slot { align-self: stretch; }
.totp-help { font-size: 12px; line-height: 17px; }
.totp-help summary { cursor: pointer; font-weight: 600; }
.totp-help ol { margin: 6px 0 0; padding-left: 18px; }
.totp-help li { margin-bottom: 4px; }
.login-box .totp-copy { min-height: 32px; padding: 0 12px; font-size: 13px; }
/* Поле коду TOTP (otpField в app.js): прозоре справжнє поле поверх 6 клітинок; поле приховане — зникає весь блок */
.otp { display: flex; flex-direction: column; gap: 6px; align-self: stretch; }
.otp:has(input[hidden]) { display: none; }
.otp-label { font-size: 12px; line-height: 16px; font-weight: 500; color: var(--muted); }
.otp-cells { position: relative; display: flex; align-items: center; gap: 6px; }
.otp-cell { flex: none; width: 40px; height: 48px; display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 600;
  font-variant-numeric: tabular-nums; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.otp-cell.cur { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.otp-gap { flex: none; width: 8px; height: 2px; background: var(--line); }
/* font-size 16px — iPhone не наближає сторінку при фокусі */
.otp .otp-cells > input.otp-input { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; background: transparent;
  color: transparent; caret-color: transparent; font-size: 16px; }
.otp .otp-cells > input.otp-input:focus-visible { outline: none; }
.admin-h { margin: 16px 0 6px; font-size: 14px; line-height: 20px; font-weight: 600; }
.admin-acts button { min-height: 26px; padding: 0 8px; margin: 0 4px 4px 0; font-size: 12px; }
table.ap tr.admin-bad td { color: var(--danger); }
.admin-link { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.changes { display: flex; flex-direction: column; gap: 8px; }
.change .change-what { min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.change-fields { font-size: 12.5px; line-height: 17px; overflow-wrap: anywhere; }
.change-more > summary { cursor: pointer; color: var(--muted); }
#conflictDlg { width: min(520px, 94vw); }
.conflict-body { padding: 14px 18px; }
.conflict-body p { margin: 0 0 8px; }
/* Підтвердження дії (app.js, ask) — замість системного confirm(), вигляд якого свій на кожній ОС */
#askDlg { width: min(460px, 94vw); }
.ask-body { padding: 14px 18px; }
.ask-body p { margin: 0; overflow-wrap: anywhere; }
/* згода на видалення — суцільно червона, а не лише червоним текстом: дію не скасувати */
#askYes.danger { color: #fff; font-weight: 600; background: var(--danger); border-color: var(--danger); }
#askYes.danger:hover { background: var(--danger); filter: brightness(1.1); }
#askYes.danger:active { filter: brightness(.9); }
.changes-filter { margin-bottom: 6px; }
.admin-link input { height: 32px; font-size: 12px; }
/* перенос — між групами з 4 символів, не посеред групи (легше переписати вручну) */
#lSecret, #iSecret { font-size: 13px; line-height: 18px; letter-spacing: .04em; text-align: center; overflow-wrap: anywhere; }

#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 6000; display: flex; flex-direction: column; gap: 8px; }
.toast { max-width: 420px; padding: 10px 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: inset 3px 0 0 var(--success), var(--shadow-md); }
.toast.error { color: var(--danger); border-color: var(--danger); box-shadow: inset 3px 0 0 var(--danger), var(--shadow-md); }

/* ---------------------------------------------------------------- карта */

.leaflet-container { font: 13px/18px var(--font); background: var(--bg); }
.leaflet-container a { color: var(--accent); }
.leaflet-bar { border: 1px solid var(--line) !important; border-radius: var(--radius); box-shadow: var(--shadow-sm) !important; overflow: hidden; }
.leaflet-bar a, .leaflet-bar a:hover { width: 32px; height: 32px; line-height: 32px; color: var(--text); background: var(--card); border-bottom-color: var(--line); }
.leaflet-bar a:hover { background: var(--hover); }
.leaflet-popup-content-wrapper { color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-md); }
.leaflet-popup-content { margin: 10px 12px; font-size: 13px; line-height: 18px; }
.leaflet-popup-tip { background: var(--card); box-shadow: none; border: 1px solid var(--line); }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
.leaflet-tooltip { color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 4px; box-shadow: var(--shadow-sm); font-size: 12px; }
.leaflet-tooltip-top::before { border-top-color: var(--line); }

.popup { max-height: 340px; overflow: auto; min-width: 250px; }
/* Leaflet дає всім svg у .leaflet-map-pane z-index 200 (для шарів карти). Значки у вікні — flex-елементи кнопок, а для
   них z-index діє і без position: «Поділитись» малювався поверх притиснутого рядка дій (z-index 1). */
.leaflet-map-pane .leaflet-popup-content svg { z-index: auto; }
.popup-title { font-weight: 600; font-size: 14px; line-height: 20px; }
.popup-sub { margin-top: 8px; font-weight: 600; font-size: 12.5px; }
.popup .mini { padding: 6px 0; border-top: 1px solid var(--line); margin-top: 6px; }
.popup .mini .contacts { display: block; }
/* «Хто відповідає тут»: рядок на організацію, картка — після кліку */
.who-org { border-top: 1px solid var(--line); margin-top: 4px; }
.who-org > summary { padding: 5px 0 3px; cursor: pointer; }
.who-org > summary:hover b { text-decoration: underline; }
.popup .who-org .mini { border-top: 0; margin-top: 0; padding: 0 0 6px 16px; }
/* тип організації — окремим рядком під назвою: у рядку з ✎ і «Поділитись» він переносився посеред фрази */
.mini-type { line-height: 16px; margin-bottom: 2px; }
/* Рядок дій притиснутий до низу вікна: .popup сам прокручується (max-height), і без sticky кнопки
   ховаються під довгим списком організацій — в усіх чотирьох спливаючих вікнах карти
   (зауваження користувача 2026-09-18). Підкладка кольору вікна — щоб текст не просвічував. */
.popup-actions { position: sticky; bottom: 0; z-index: 1; margin-top: 10px; padding-top: 8px;
  display: flex; gap: 6px; flex-wrap: wrap; background: var(--card); border-top: 1px solid var(--line); }

.legend { padding: 10px 12px; font-size: 13px; line-height: 18px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-md); }
.legend summary { cursor: pointer; font-weight: 600; }
.legend-row { display: flex; align-items: center; gap: 8px; min-height: 24px; margin-top: 2px; cursor: pointer; }
.legend-row input { margin: 0; }
.legend-note, .legend-zoom { font-weight: 400; font-size: 12px; color: var(--muted); }
.legend-actions { display: flex; gap: 4px; margin: 8px 0 4px; }
.legend-actions button { min-height: 24px; padding: 0 8px; font-size: 12px; font-weight: 400; border-radius: 4px; }
.legend-hint { max-width: 260px; margin-top: 8px; color: var(--muted); font-size: 12px; line-height: 16px; }

.map-search { width: min(360px, calc(100vw - 90px)); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-md); }
.map-search input { border: none; background: transparent; }
.ms-results { max-height: 60vh; overflow: auto; border-top: 1px solid var(--line); padding-bottom: 4px; }
.ms-group { padding: 8px 12px 2px; font-size: 11px; font-weight: 600; letter-spacing: .06em; color: var(--muted); text-transform: uppercase; }
.ms-group + .ms-item { margin-top: 2px; }
.ms-item { display: flex; align-items: center; justify-content: flex-start; gap: 8px; width: 100%; min-height: 0; padding: 6px 12px;
  text-align: left; white-space: normal; font-weight: 400; border: 0; border-radius: 0; background: transparent; }
.ms-item:hover, .ms-item.active { background: var(--hover); }
.ms-pin { width: 18px; text-align: center; color: var(--accent); flex: none; }
.ms-sub { color: var(--muted); font-size: 12px; }
.ms-more, .ms-empty { padding: 4px 12px 6px; font-size: 12px; color: var(--muted); }
button.ms-more { display: block; width: 100%; min-height: 0; text-align: left; font-weight: 400; color: var(--accent); background: transparent;
  border: 0; border-radius: 0; cursor: pointer; }
button.ms-more:hover { background: var(--hover); }
/* Підпис знайдених координат: клік — «Хто відповідає тут» */
.coords-label { text-align: center; font-variant-numeric: tabular-nums; cursor: pointer; }

/* Редактор маршруту: список точок і підказки населених пунктів. */
.wp-list { list-style: none; margin: 0 0 10px; padding: 0; }
.wp-list:empty { display: none; }
/* «Звідки» / «Куди» у редакторі маршруту: без overflow — список підказок має виходити за межі */
.place-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; margin-bottom: 10px; }
.wp-row { display: flex; align-items: center; gap: 4px; min-height: 30px; }
.wp-row + .wp-row { border-top: 1px solid var(--line); }
.wp-mark { flex: none; display: flex; align-items: center; justify-content: center; width: 20px; height: 20px; margin-right: 4px; border-radius: 50%;
  background: #fff; color: var(--route); font-weight: 700; font-size: 11px; border: 2px solid var(--route); }
.wp-mark.via { width: 12px; height: 12px; margin: 0 8px 0 4px; }
.wp-name { flex: 1; min-width: 0; min-height: 0; padding: 4px 2px; justify-content: flex-start; text-align: left; white-space: normal;
  font-weight: 400; border: 0; background: transparent; }
.suggest { position: relative; }
.suggest .ms-results { position: absolute; z-index: 5; top: calc(100% + 2px); left: 0; right: 0; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-md); }

/* Точки маршруту на карті: A/B — білий круг з літерою кольором лінії; проміжні й кружечок на лінії — малі без підпису. */
/* Іконка маркера — прозора зона дотику (на сенсорному екрані більша за саму точку), точка — span по центру. */
.wp-via, .wp-icon { display: flex; align-items: center; justify-content: center; }
.wp-via span { flex: none; width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 2px solid var(--route); box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.wp-menu { min-width: 180px; }
.wp-ghost { opacity: .9; }
#map.picking .leaflet-marker-icon.wp-via, #map.picking .leaflet-marker-icon.wp-icon { cursor: move; }
.wp-icon span { flex: none; display: flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; color: var(--route); font-weight: 700; font-size: 12px; border: 2px solid var(--route); box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
/* «Об'їзна X» з тексту замовника: точка в центрі міста, доки її не перетягнули на об'їзну, — помаранчева, з підписом */
.wp-bypass span { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }
.wp-via.wp-bypass span { width: 16px; height: 16px; }
.leaflet-tooltip.wp-bypass-label { padding: 1px 6px; font-size: 12px; font-weight: 600; color: var(--warn); background: var(--warn-soft);
  border: 1px solid var(--warn); box-shadow: none; }
.leaflet-tooltip.wp-bypass-label::before { display: none; }
.wp-row.bypass .wp-mark { border-color: var(--warn); color: var(--warn); background: var(--warn-soft); }
.wp-row.bypass .wp-name { color: var(--warn); }
/* ✎ у списку точок: поле з підказками на місці назви */
.wp-edit { flex: 1; min-width: 0; padding: 2px 0; }
.wp-edit input { width: 100%; }
.wp-row .icon-btn.on { color: var(--accent); background: var(--accent-soft); }

/* ---------------------------------------------------------------- вузькі екрани */

.view-switch { display: none; }

/* Планшет: панель вужча, щоб лишалось місце для карти. */
@media (max-width: 1100px) {
  .layout { grid-template-columns: min(450px, 45vw) 1fr; }
}

/* Телефон (те саме значення — phoneQuery в app.js): або список, або карта на весь екран, перемикач унизу — showView().
   Приховане — visibility, а не display: карта зберігає розмір (Leaflet не треба перераховувати), список — прокрутку. */
@media (max-width: 700px) {
  header { gap: 6px; padding: 0 10px; }
  header .muted-light { display: none; }
  /* логін стискається (обрізається «…»), а не виштовхує кнопки за край екрана 360 px */
  #account { max-width: 96px; min-width: 40px; flex-shrink: 1; }
  /* «Обліковий запис»: «Закрити» і «Вийти» — першим рядком праворуч, «Вийти на всіх пристроях» — другим на всю ширину */
  #accountDlg #accLogoutAll { order: 1; flex-basis: 100%; }
  header button { padding: 0 10px; }
  #helpLink { flex: none; width: 36px; padding: 0; font-weight: 600; }
  .help-q { display: inline; }
  .help-label { display: none; }
  .layout { position: relative; display: block; height: calc(100vh - 48px - 52px); height: calc(100dvh - 48px - 52px); }
  aside, .map-wrap { position: absolute; inset: 0; }
  aside { border-right: 0; box-shadow: none; }
  body[data-view=map] aside, body[data-view=list] .map-wrap { visibility: hidden; }

  .view-switch { display: flex; height: 52px; background: var(--panel); border-top: 1px solid var(--line); }
  .view-switch button { flex: 1; height: 100%; border: 0; border-radius: 0; background: none; font-weight: 500; color: var(--muted); }
  .view-switch button.active { color: var(--accent); font-weight: 600; background: var(--card); box-shadow: inset 0 2px 0 var(--accent); }

  /* 16 px — інакше iPhone наближає сторінку при фокусі на полі */
  input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea { font-size: 16px; }
  .form-grid, .zp-list, .place-pair { grid-template-columns: 1fr; }
  /* «оновлено» на телефоні ховаємо: воно розсувало б кнопки картки на два ряди (повна дата — у формі) */
  .card-when { display: none; }
  .popup { min-width: 0; }
  /* панель режиму — унизу карти, щоб не накладалась на пошук угорі */
  #modeBar { top: auto; bottom: 10px; left: 8px; right: 8px; width: auto; margin: 0; max-width: none; font-size: 13px; line-height: 17px; }
  /* легенда й підпис карти — над панеллю режиму, а не під нею (висоту панелі ставить app.js, прихована — 0) */
  .map-wrap .leaflet-bottom { bottom: var(--mode-bar-h, 0px); }
  #toasts { left: 12px; right: 12px; bottom: 64px; }
  .toast { max-width: none; }

  /* «Контакти» — на весь екран (типові max-width / max-height модального вікна лишали б поля по краях) */
  #peopleDlg { width: 100%; max-width: 100%; height: 100%; max-height: 100%; margin: 0; border: 0; border-radius: 0; }
  .pd { height: 100%; max-height: none; }
  .pd-head { padding-left: 12px; }
  .pd-list { padding: 0 12px; }
  .pd > .dlg-actions { padding: 10px 12px; }
  /* компактніше: менші відступи між полями й навколо рядка редагування */
  .pd-fields { grid-template-columns: 1fr; gap: 6px; }
  .pd-edit { margin: 6px -6px; padding: 8px 6px; }
  .pd-edit .field { gap: 2px; }
  .pd-edit-title { margin-bottom: 4px; font-size: 13px; }
  .pd-edit .dlg-actions { margin-top: 8px; }
  /* номер чи email — рядок на всю ширину: легко влучити пальцем */
  .pd-body .contacts a { display: block; padding: 5px 0; }
}

/* Сенсорний екран (coarseQuery в app.js): кнопки списку точок маршруту — під палець, не 24 px. */
@media (pointer: coarse) {
  .wp-row .icon-btn { width: 40px; height: 40px; font-size: 16px; }
}

/* Телефон або дотик: ☆/★, «Поділитись», ✎ контактів і кнопки рядка редагування — 44 px */
@media (max-width: 700px), (pointer: coarse) {
  .person-item .star-btn, .pd-row .star-btn, .person-item .icon-btn, .pd-row .icon-btn { width: 44px; height: 44px; font-size: 22px; }
  .person-item .icon-btn .ic, .pd-row .icon-btn .ic { width: 20px; height: 20px; }
  .person-item .star-btn, .pd-row .star-btn { margin: -10px 0 0 -10px; }
  .person-item .icon-btn, .pd-row .icon-btn { margin: -10px 0 0; }
  .pd-edit .dlg-actions button, .pd > .dlg-actions button, #pdClose { min-height: 44px; }
  #pdClose { width: 44px; }
  .card-actions [data-share-org] { width: 44px; min-height: 44px; }
  /* Вузький екран: «Редагувати · Контакти (N) · На карті · Поділитись» не влазили в рядок — на телефоні
     користувача бракувало ≈12 px, і з'їдав їх саме лічильник «(1)». Тісніші проміжки й поля вертають
     кнопку в рядок; за довгих підписів («Контакти (12)») перенос лишається можливим — тоді рядок
     тримається купи лінією вище й правим краєм (рішення 2026-09-18). */
  .card-actions { gap: 4px; }
  .card-actions button, .card-actions a.button { padding: 0 6px; }
  .card-actions [data-share-org] { margin-left: auto; }
}

/* Дотик: ✎ і «Поділитись» у спливаючому вікні карти й картці маршруту — 32 px (44 розсунули б рядки контактів) */
@media (pointer: coarse) {
  .mini .icon-btn, .need .icon-btn { width: 32px; height: 32px; font-size: 14px; }
}

/* Дотик: «розгорнути» нотатку — під палець; без зсувів від правил кнопок контактів вище */
@media (pointer: coarse) {
  .notes-more { width: 36px; height: 36px; margin: 0; font-size: 16px; }
  .notes-more .ic { width: 18px; height: 18px; }
}

/* ---------------------------------------------------------------- щільність під мишу (2026-09-18)
   Лише там, де курсор: на дотику всі зони лишаються 44 px (рішення користувача; `tests/ui_phone.js`).
   Розходження з макетом docs/ui-design/ свідоме — див. DESIGN, «Вузькі екрани». */
@media (hover: hover) and (pointer: fine) {
  header { height: 40px; padding: 0 12px; }
  .tabs button { height: 36px; }
  #panel { padding: 10px 10px 36px; }
  /* смуга «Зберегти / Скасувати» — на ширину панелі з її відступами: з -12px вона виходила на 2 px за край,
     і в редакторі маршруту з'являлась горизонтальна прокрутка (скріншот користувача 2026-10-01) */
  .save-bar { bottom: -36px; margin: 12px -10px 0; padding: 10px; }
  button, a.button { min-height: 28px; padding: 0 10px; }
  button.icon-only { width: 28px; }
  .toolbar button, .toolbar a.button, .save-bar button, .dlg-actions button { min-height: 32px; }
  .toolbar { gap: 6px; margin-bottom: 8px; }
  .list { gap: 6px; }
  #cList { gap: 12px; }
  .card { padding: 8px 10px; }
  .card-actions, .card > .card-actions { margin-top: 8px; }
  dialog > form > h3 { padding: 10px 14px; }
  .form-grid { gap: 10px 12px; padding: 12px 14px; }
  dialog > form > .dlg-actions { padding: 10px 14px; }
  /* Спливаючі вікна карти: рядок контакту високий не через проміжки, а через кнопки ✎ і «Поділитись»
     (24 px при тексті 16 px) — під мишу вони 20 px, а саме вікно вище, тож гортати треба рідше. */
  .popup { max-height: 420px; }
  .popup .mini { padding: 4px 0; margin-top: 4px; }
  .popup .icon-btn { width: 20px; height: 20px; }
  .popup-actions { margin-top: 8px; padding-top: 6px; }
}
