:root {
    /* гірчичне жовте, чорне й біле, Helvetica, написи великими з розрядкою */
    --gold: #E8BE17;      /* шапка, головні кнопки */
    --ink: #111111;       /* чорне: текст на жовтому, плашки */
    /* диспетчерська — світла, як сайт: --night фон панелей, --night-2 піднесене, --snow текст, --mist другорядне */
    --night: #FFFFFF;
    --night-2: #F4F4F2;
    --line: #DEDEDA;
    --snow: #1B1B1B;
    --mist: #62625E;
    --beacon: #E8BE17;    /* проблисковий маячок: техніка чистить, головні дії */
    --todo: #E4572E;      /* не почищено */
    --done: #22A447;      /* почищено */
    --off: #7A8794;
    --err: #B3261E;
    --ok: #146C2E;
    --gold-soft: #FBF1C7;
    --gold-text: #7A5C00; /* «чистить» тощо на світлому */
    --radius: 4px;
    --font: "Helvetica Neue", Helvetica, Arial, sans-serif;
    color-scheme: light;
}
/* водій і застосунок — темні (у кабіні вночі світлий екран сліпить), у тих самих кольорах */
.dark {
    --night: #121212;
    --night-2: #1F1F1E;
    --line: #363634;
    --snow: #F2F2EE;
    --mist: #A9A9A2;
    --err: #FF9D85;
    --ok: #86E29E;
    --gold-soft: #3A2F06;
    --gold-text: #E8BE17;
    color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
    font: 400 15px/1.45 var(--font);
    font-variant-numeric: tabular-nums;
    background: var(--night); color: var(--snow);
    -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: .02em; line-height: 1.15; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--beacon); outline-offset: 2px; }
.muted { color: var(--mist); }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 40px; padding: 8px 14px; border-radius: var(--radius);
    border: 1px solid var(--line); background: var(--night-2); color: var(--snow); cursor: pointer; font-weight: 600; text-decoration: none;
}
.btn:hover { border-color: var(--mist); }
/* головна кнопка — як «READ MORE» на сайті: жовта, чорні великі літери з розрядкою */
.btn.primary { background: var(--gold); border-color: var(--gold); color: var(--ink); text-transform: uppercase; letter-spacing: .08em; font-weight: 700; font-size: 14px; }
.btn.primary:hover { border-color: var(--ink); }
.btn.danger { color: var(--err); }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.btn.ghost { background: transparent; }
.field { display: grid; gap: 4px; margin-bottom: 12px; }
.field > span { font-size: 13px; color: var(--mist); }
.field input:not([type=checkbox]):not([type=color]), .field select {
    min-height: 40px; padding: 6px 10px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--night); width: 100%;
}
.check { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--beacon); flex: none; }

/* ---------- маркер техніки ---------- */
.vm-wrap { background: none; border: 0; }
.vm { --c: #2E5EAA; position: relative; width: 36px; height: 36px; }
.vm-dot {
    position: absolute; inset: 5px; border-radius: 50%; background: var(--c); border: 3px solid #fff;
    display: grid; place-items: center; color: #fff; font: 700 13px/1 var(--font);
    box-shadow: 0 1px 4px rgba(0, 0, 0, .45);
}
.vm-dir { position: absolute; inset: 0; transition: transform .4s; }
.vm-dir i {
    position: absolute; left: 50%; top: -6px; margin-left: -6px; width: 0; height: 0;
    border: 6px solid transparent; border-bottom: 9px solid var(--c); border-top: 0;
    filter: drop-shadow(0 0 1px #fff) drop-shadow(0 0 1px #fff);
}
.vm.no-dir .vm-dir { display: none; }
.vm-halo { position: absolute; inset: -4px; border-radius: 50%; border: 3px solid var(--beacon); opacity: 0; }
.vm.is-working .vm-halo { opacity: 1; animation: beacon 1.6s ease-out infinite; }
.vm.is-offline .vm-dot { background: var(--off); }
.vm.is-offline { opacity: .8; }
.vm-name {
    position: absolute; top: 38px; left: 50%; transform: translateX(-50%); white-space: nowrap;
    background: var(--ink); color: #fff; font: 600 12px/1 var(--font);
    padding: 4px 6px 3px; border-radius: 6px; pointer-events: none;
}
.hide-labels .vm-name { display: none; }
@keyframes beacon { 0% { transform: scale(.85); opacity: 1; } 100% { transform: scale(1.5); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .vm.is-working .vm-halo { animation: none; } .vm-dir { transition: none; } }

.leaflet-container { font: inherit; background: #e6e4dc; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--night); color: var(--snow); }
.leaflet-popup-content { margin: 12px 14px; }
.leaflet-container a.leaflet-popup-close-button { color: var(--mist); }
.flag { background: var(--ink); color: #fff; border: 2px solid var(--gold); border-radius: 6px; font-weight: 800; font-size: 12px; padding: 3px 6px 1px; white-space: nowrap; }

#toast {
    position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 2000;
    background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--radius); font-weight: 600; box-shadow: 0 4px 16px rgba(0,0,0,.3);
    max-width: calc(100vw - 32px); transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.bar { height: 8px; border-radius: 4px; background: var(--todo); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--done); border-radius: 4px; transition: width .4s; }

/* ---------- диспетчер ---------- */
.disp #app { display: grid; grid-template-columns: 380px 1fr; height: 100%; }
#panel { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; margin-bottom: 14px; background: var(--gold); color: var(--ink); }
.brand .btn { background: transparent; border-color: rgba(17, 17, 17, .35); color: var(--ink); text-transform: uppercase; letter-spacing: .08em; font-size: 12px; font-weight: 700; }
.brand .btn:hover { border-color: var(--ink); background: rgba(255, 255, 255, .25); }
.brand-actions { display: flex; gap: 6px; flex: none; }
.lang-switch { min-width: 48px; letter-spacing: .04em; }
.lang-login { float: right; margin: -8px 0 8px; }
.brand-id { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
.brand-id .logo { height: 46px; width: auto; flex: none; }
.brand-id h1 { font-size: 12px; color: var(--ink); font-weight: 700; text-transform: uppercase; letter-spacing: .16em; line-height: 1.2; }
.login-logo { display: block; width: min(280px, 80%); height: auto; margin: 0 auto 26px; }
.dbar-id { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.dbar-id > div { min-width: 0; }
.dbar-id b, .dbar-id small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dbar-logo { height: 34px; width: auto; flex: none; }
.summary { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin: 0 18px 14px; background: #333; border-radius: var(--radius); overflow: hidden; }
.summary div { background: var(--ink); color: #fff; padding: 10px 14px; }
.summary b { display: block; font-size: 24px; font-weight: 700; color: var(--gold); }
.summary span { font-size: 12px; color: #c9c9c4; letter-spacing: .04em; }
.tabs { display: flex; gap: 4px; padding: 0 18px; border-bottom: 1px solid var(--line); }
.tabs button { background: none; border: 0; padding: 10px 12px; cursor: pointer; font-weight: 700; color: var(--mist); border-bottom: 4px solid transparent; margin-bottom: -1px; text-transform: uppercase; letter-spacing: .08em; font-size: 13px; }
.tabs button[aria-selected=true] { color: var(--ink); border-bottom-color: var(--gold); }
.dark .tabs button[aria-selected=true] { color: var(--snow); }
.tab { flex: 1; overflow-y: auto; padding: 14px 18px 24px; }
.tab-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.list { list-style: none; margin: 0; padding: 0; }
.empty { color: var(--mist); padding: 8px 0; }

.veh { display: grid; grid-template-columns: 32px 1fr auto; gap: 12px; align-items: start; padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.veh:hover .veh-name { text-decoration: underline; }
.badge { width: 32px; height: 32px; border-radius: 50%; background: var(--c); border: 2px solid #fff; display: grid; place-items: center; font-weight: 800; font-size: 13px; color: #fff; }
.badge.off { background: var(--off); }
.veh-name { font-weight: 600; }
.veh-sub { font-size: 13px; color: var(--mist); }
.st { font-weight: 600; }
.st.work { color: var(--gold-text); }
.st.drive { color: var(--snow); }
.st.off { color: var(--off); }
.veh-side { display: grid; justify-items: end; gap: 6px; font-size: 13px; color: var(--mist); }

.rt-find { position: sticky; top: -14px; z-index: 5; background: var(--night); padding: 4px 0 8px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.rt-find input { width: 100%; min-height: 42px; padding: 6px 12px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--night-2); font-size: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chips:empty { display: none; }
.chips button { min-height: 32px; padding: 4px 12px; border-radius: 99px; border: 1px solid var(--line); background: none; font-weight: 600; cursor: pointer; }
.chips button[aria-pressed=true] { background: var(--ink); border-color: var(--ink); color: #fff; }
.rt-count { margin: 8px 0 0; font-size: 13px; color: var(--mist); }
.rt { padding: 12px 0 14px; border-bottom: 1px solid var(--line); }
.rt.on { background: var(--night-2); margin: 0 -10px; padding-left: 10px; padding-right: 10px; border-radius: var(--radius); }
.rt[style*="--prio"] .rt-name::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--prio); margin-right: 8px; }
.rt-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; margin-bottom: 8px; }
.rt-name { background: none; border: 0; padding: 0; font-weight: 600; text-align: left; cursor: pointer; }
.rt-name:hover { text-decoration: underline; }
.rt-pct { font-weight: 800; }
.rt-meta { font-size: 13px; color: var(--mist); margin: 8px 0; }
.rt-actions { display: flex; flex-wrap: wrap; gap: 6px; }

.draw-box { background: var(--night-2); border: 1px solid var(--line); border-top: 4px solid var(--gold); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }
.draw-box p { margin: 0 0 10px; font-size: 14px; }
.compose-list { margin: 0 0 12px; padding-left: 22px; font-size: 14px; display: grid; gap: 4px; }
.compose-list:empty { display: none; }
.compose-list li button { background: none; border: 0; color: var(--mist); cursor: pointer; padding: 0 4px; font-size: 13px; text-decoration: underline; }
.rt.picked { background: var(--night-2); margin: 0 -10px; padding-left: 10px; padding-right: 10px; border-radius: var(--radius); }
.draw-box .tab-actions { margin: 0; }
.ends { display: grid; gap: 8px; margin: 0 0 10px; }
.end-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.end-text { flex: 1; min-width: 120px; display: grid; font-size: 14px; }
.end-text span { color: var(--mist); font-size: 13px; }
.pin {
    flex: none; width: 26px; height: 26px; border-radius: 50%; display: inline-grid; place-items: center;
    font-weight: 800; font-size: 13px; color: #fff; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .45);
}
.pin.a { background: #22A447; }
.pin.b { background: #D62728; }
.pin.ab { background: linear-gradient(90deg, #22A447 50%, #D62728 50%); font-size: 11px; }
.plan-info { background: var(--night); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; }
.plan-no {
    width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center;
    color: var(--ink); border: 2px solid var(--ink); background: var(--gold); font: 700 11px/1 var(--font);
}
.picking #map { cursor: crosshair; }

#mapwrap { position: relative; min-height: 0; }
#map { position: absolute; inset: 0; }
.drawing #map { cursor: crosshair; }
.layers {
    position: absolute; top: 12px; right: 12px; z-index: 1000; width: 230px;
    background: var(--night); border-radius: var(--radius); padding: 12px 14px; box-shadow: 0 2px 12px rgba(0, 0, 0, .25); border-top: 4px solid var(--gold);
}
.layers .check { margin-bottom: 8px; font-size: 14px; }
.layers .field { margin: 4px 0 10px; }
.legend { display: grid; gap: 6px; font-size: 13px; color: var(--mist); border-top: 1px solid var(--line); padding-top: 10px; }
.legend div { display: flex; align-items: center; gap: 8px; }
.sw { width: 34px; height: 12px; flex: none; position: relative; }
.sw::after { content: ''; position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%); }
.sw.todo::after { height: 6px; background: var(--todo); }
.sw.done::after { height: 6px; background: var(--done); }
.sw.half::after { height: 6px; background: repeating-linear-gradient(90deg, var(--done) 0 7px, #FF8C00 7px 14px); }
.sw.two::after { height: 6px; background: linear-gradient(var(--todo) 0 2px, #fff 2px 4px, var(--todo) 4px 6px); }
.sw.trail::after { height: 3px; background: #2E5EAA; }
.sw.band::after { height: 12px; background: var(--done); opacity: .35; border-radius: 6px; }
.layers-toggle { display: none; }
/* вибраний маршрут: на карті лише він; панель — що це за маршрут і кому його дати */
.focus-bar { position: absolute; z-index: 1000; left: 12px; right: 64px; bottom: 24px; max-width: 460px; background: var(--night); border: 1px solid var(--line); border-left: 6px solid var(--prio, var(--todo)); border-radius: var(--radius); padding: 10px 12px; box-shadow: 0 6px 24px rgba(0,0,0,.35); }
.focus-head { display: flex; justify-content: space-between; align-items: start; gap: 10px; }
.focus-head b { display: block; font-size: 16px; }
.focus-head small { display: block; color: var(--mist); font-size: 13px; margin-top: 2px; }
.focus-assign { display: grid; gap: 4px; margin-top: 8px; font-size: 13px; color: var(--mist); }
.focus-head > div { min-width: 0; }
.focus-head .btn { flex: none; }
.focus-assign { min-width: 0; }
.focus-assign select { width: 100%; min-width: 0; min-height: 38px; padding: 4px 8px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--night-2); color: var(--snow); font-size: 15px; }

dialog { background: var(--night); color: var(--snow); border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto; }
dialog::backdrop { background: rgba(10, 10, 10, .55); }
dialog h2 { text-transform: uppercase; letter-spacing: .06em; }
dialog form { padding: 20px; }
dialog h2 { font-size: 20px; margin-bottom: 16px; }
.dlg-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin: 8px -20px -20px; padding: 12px 20px 20px; position: sticky; bottom: -20px; background: var(--night); border-top: 1px solid var(--line); }
.driver-box { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 14px; }
.driver-box h3 { font-size: 16px; margin-bottom: 8px; }
.driver-box p { margin: 0 0 10px; font-size: 14px; }
.qr-row { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 12px; }
.qr { background: #fff; border-radius: 8px; padding: 4px; flex: none; line-height: 0; }
.link-box { word-break: break-all; font-size: 13px; background: var(--night-2); padding: 8px 10px; border-radius: 8px; margin-bottom: 8px; user-select: all; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; margin: 0 0 12px; }
.kv dt { color: var(--mist); }
.kv dd { margin: 0; word-break: break-all; user-select: all; }

.login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.login form { width: min(360px, 100%); }
.login h1 { font-size: 24px; margin-bottom: 6px; text-transform: uppercase; letter-spacing: .1em; text-align: center; }
.login { border-top: 10px solid var(--gold); }
.login p { text-align: center; }
.login p { margin: 0 0 22px; color: var(--mist); }
.err { color: var(--err); min-height: 1.4em; margin: 0 0 8px; font-size: 14px; }

@media (max-width: 760px) {
    /* телефон: карта зверху, під нею панель, яка гортається вся (рядок minmax(0, 1fr) не дає їй вилізти за екран) */
    body.disp { overflow: hidden; }
    .disp #app { grid-template-columns: 1fr; grid-template-rows: 45vh minmax(0, 1fr); height: 100dvh; }
    .disp.focused #app { grid-template-rows: 62vh minmax(0, 1fr); }   /* вибраний маршрут: низ карти займає його панель */
    .disp #panel > * { flex-shrink: 0; }   /* панель гортається вся: нічого не стискати (зведення обрізало текст) */
    .brand-id .logo { height: 40px; }
    .brand-id h1 { font-size: 11px; }
    .summary b { font-size: 19px; }
    /* вибраний маршрут на вузькій карті: компактно, лівіше кнопок масштабу і над підписом OpenStreetMap */
    .focus-bar { left: 8px; right: 54px; bottom: 22px; padding: 8px 10px; border-left-width: 5px; }
    .focus-head b { font-size: 15px; }
    .focus-head small { font-size: 12px; }
    .focus-head .btn { min-height: 30px; padding: 2px 10px; font-size: 13px; }
    .focus-assign { margin-top: 6px; }
    .focus-assign span { display: none; }
    .focus-assign select { min-height: 34px; font-size: 14px; }
    .disp #panel { order: 2; border-right: 0; border-top: 1px solid var(--line); overflow-y: auto; overscroll-behavior: contain; }
    .disp .tab { flex: none; overflow: visible; }
    .rt-find { top: 0; }
    .disp #mapwrap { order: 1; }
    .brand { padding: 10px 16px; margin-bottom: 10px; }
    .summary { margin: 0 16px 10px; }
    .tabs, .tab { padding-left: 16px; padding-right: 16px; }
    .layers { width: auto; left: 12px; right: auto; top: 12px; }
    .layers-toggle { display: inline-flex; }
    .layers.collapsed .layers-body { display: none; }
    /* розгорнута легенда — над панеллю маршруту і не довша за карту */
    .layers { z-index: 1001; }
    .layers-body { max-height: calc(45vh - 84px); overflow-y: auto; margin-top: 8px; }
}

/* прибирання: строки за пріоритетами */
.op { margin: 0 18px 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--night-2); }
.op:empty { display: none; }
.op.idle { background: none; border-style: dashed; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.op-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.op-head b { font-size: 16px; }
.op-head span { font-size: 13px; color: var(--mist); }
.op-dl { display: grid; gap: 4px; margin: 10px 0; font-size: 14px; }
.op-dl div { display: flex; justify-content: space-between; gap: 8px; }
.op-dl i { font-style: normal; width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 6px; background: var(--prio); }
.op .tab-actions { margin: 0; }
.dl { display: inline-block; font-size: 13px; font-weight: 600; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--line); margin-top: 8px; }
.dl.ok { border-color: var(--done); color: var(--ok); }
.dl.warn { border-color: var(--gold); color: var(--snow); background: var(--gold-soft); }
.dl.late { border-color: var(--todo); color: var(--err); }
.op-dl .late { color: var(--err); font-weight: 600; }
.op-prios { border: 0; padding: 0; margin: 0 0 8px; }
.op-prios legend { font-size: 13px; color: var(--mist); margin-bottom: 8px; padding: 0; }
.op-info { font-size: 14px; color: var(--mist); margin: 0 0 8px; }
.ops-item { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.ops-item small { display: block; color: var(--mist); }
@media (max-width: 760px) { .op { margin: 0 16px 10px; } }

/* ---------- водій ---------- */
.drv { display: flex; flex-direction: column; height: 100%; overflow: hidden; }
.dbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 14px; padding-top: max(8px, env(safe-area-inset-top)); background: var(--gold); color: var(--ink); }
.dbar b { font-size: 17px; font-weight: 700; display: block; text-transform: uppercase; letter-spacing: .04em; }
.dbar small { color: #3d3410; font-size: 13px; display: block; }
.dbar .pill { background: var(--ink); border-color: var(--ink); color: #fff; }
.dbar .lang-switch { flex: none; min-height: 30px; padding: 2px 10px; background: transparent; border-color: rgba(17, 17, 17, .4); color: var(--ink); font-weight: 700; }
.dbar .pill.good { color: #86E29E; }
.dbar .pill.bad { color: #FF9D85; }
.pill { font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 99px; background: var(--night-2); border: 1px solid var(--line); white-space: nowrap; }
.pill.good { border-color: var(--done); color: var(--ok); }
.pill.bad { border-color: var(--todo); color: var(--err); }
.drv #mapwrap { flex: 1; }
.fab { position: absolute; z-index: 1000; left: 12px; bottom: 12px; }
.dcard { padding: 12px 14px; padding-bottom: max(14px, env(safe-area-inset-bottom)); display: grid; gap: 12px; border-top: 1px solid var(--line); }
.next { display: grid; grid-template-columns: 48px 1fr auto; gap: 12px; align-items: center; }
.arrow { width: 48px; height: 48px; border-radius: 50%; background: var(--night-2); border: 2px solid var(--beacon); display: grid; place-items: center; }
.arrow svg { transition: transform .4s; }
.next-text { font-size: 20px; font-weight: 800; line-height: 1.15; }
.next-sub { font-size: 13px; color: var(--mist); }
.prog { display: grid; gap: 6px; font-size: 14px; }
.prog-row { display: flex; justify-content: space-between; gap: 12px; }
.mode { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mode button {
    min-height: 64px; border-radius: 12px; border: 2px solid var(--line); background: var(--night-2);
    font-size: 20px; font-weight: 800; cursor: pointer; line-height: 1.1;
}
.mode button small { display: block; font-size: 12px; font-weight: 600; color: var(--mist); margin-top: 2px; }
.mode button[aria-pressed=true] { border-color: var(--snow); background: var(--snow); color: var(--night); }
.mode button[aria-pressed=true] small { color: #3b4a56; }
.mode #m-work[aria-pressed=true] { background: var(--gold); border-color: var(--gold); color: var(--ink); }
.mode #m-work[aria-pressed=true] small { color: #4d3800; }
.drow { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 13px; }
.linkbtn { background: none; border: 0; color: var(--mist); text-decoration: underline; cursor: pointer; padding: 6px 0; }

.overlay { position: fixed; inset: 0; z-index: 3000; background: var(--night); display: grid; place-items: center; padding: 24px 20px; overflow-y: auto; }
.overlay > div { width: min(420px, 100%); }
.overlay h1 { font-size: 26px; margin-bottom: 10px; text-transform: uppercase; letter-spacing: .06em; }
.overlay .brand-logo { display: block; width: min(220px, 62%); height: auto; margin: 0 0 24px; padding: 12px 16px; background: var(--gold); border-radius: var(--radius); }   /* чорне «JROSS» на чорному не видно — на жовтій плашці, як шапка сайту */
.overlay p { color: var(--mist); margin: 0 0 14px; }
.overlay .start-more { margin-top: 18px; display: grid; gap: 10px; justify-items: center; text-align: center; }
.login .start-more { margin: 14px 0 0; text-align: center; }
.overlay .start-more a { color: var(--gold); font-weight: 700; }
.link-form { display: grid; gap: 6px; }
.scan-btn { width: 100%; min-height: 52px; font-size: 17px; margin-bottom: 6px; }
.scanner { position: fixed; inset: 0; z-index: 4000; background: #000; display: grid; grid-template-rows: 1fr auto auto; justify-items: center; gap: 12px; padding: 0 20px calc(24px + env(safe-area-inset-bottom)); }
.scanner[hidden] { display: none; }
.scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scan-frame { position: relative; align-self: center; width: min(68vw, 300px); aspect-ratio: 1; border: 3px solid #fff; border-radius: 22px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .45); }
.scan-hint { position: relative; margin: 0; color: #fff; text-align: center; font-weight: 600; text-shadow: 0 1px 4px #000; }
.scanner .btn { position: relative; min-width: 180px; min-height: 48px; }
.link-form input { min-height: 48px; padding: 8px 12px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--night-2); color: var(--snow); font: inherit; width: 100%; }
.linkish { background: none; border: 0; color: var(--mist); text-decoration: underline; font: inherit; cursor: pointer; padding: 6px; }
.overlay .btn.primary { width: 100%; min-height: 64px; font-size: 19px; border-radius: 32px; margin-top: 8px; letter-spacing: .1em; }
/* ---------- мітки з дороги ---------- */
.nm { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--night); border: 2px solid #fff; font-size: 16px; line-height: 1; box-shadow: 0 1px 4px rgba(0, 0, 0, .5); }
.nm.wait { border-style: dashed; border-color: var(--beacon); }
.nm.done { opacity: .5; filter: grayscale(1); }
.np b { display: block; font-size: 15px; }
.np p { margin: 4px 0; }
.np small { color: var(--mist); display: block; }
.np img { display: block; max-width: 230px; max-height: 230px; border-radius: 8px; margin-top: 8px; }
.np-act { display: flex; gap: 6px; margin-top: 10px; }
.np-wait { color: var(--gold-text); font-size: 13px; }
.veh.note .nm { width: 32px; height: 32px; box-shadow: none; }
.veh.note.resolved { opacity: .6; }
.field textarea { min-height: 64px; padding: 8px 10px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--night); width: 100%; resize: vertical; font: inherit; color: inherit; }
.kinds { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.kinds button { min-height: 56px; display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--night-2); font-weight: 700; font-size: 14px; text-align: left; cursor: pointer; }
.kinds button span { min-width: 0; }
.kinds button[aria-pressed=true] { border-color: var(--gold); background: var(--gold-soft); }
.note-photo { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 8px; }
.note-photo img { flex-basis: 100%; max-width: 100%; max-height: 200px; object-fit: contain; border-radius: 8px; }
#note-dlg .muted { font-size: 13px; margin: 4px 0 0; }
.fabs { position: absolute; z-index: 1000; top: 12px; right: 12px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.fabs .btn { box-shadow: 0 2px 8px rgba(0, 0, 0, .4); }
#voice { min-width: 44px; font-size: 18px; }
#voice[aria-pressed=true] { background: var(--beacon); border-color: var(--beacon); }
.drow .warn { color: var(--err); font-weight: 600; }
body:has(.drv) #toast { bottom: auto; top: max(64px, calc(env(safe-area-inset-top) + 56px)); transform: translate(-50%, -20px); }
body:has(.drv) #toast.show { transform: translate(-50%, 0); }

/* шари з карт тендеру: шкільні зони, зупинки, адреси */
.sw.school{background:#F06FD6;opacity:.6;height:6px}
.fdot{display:inline-block;width:10px;height:10px;border-radius:50%;border:1.5px solid #111;margin:0 8px 0 3px;vertical-align:middle}
.fdot.stop{background:#2BD62B}.fdot.at_stop{background:#16B4EE}
.fico{display:inline-block;width:16px;margin-right:6px;text-align:center}
.fm{display:flex;align-items:center;justify-content:center;width:22px;height:22px;border-radius:50%;background:#fff;border:1.5px solid #111;font-size:13px;line-height:1;box-shadow:0 1px 3px rgba(0,0,0,.35)}
.rt-tags{display:flex;flex-wrap:wrap;gap:4px;margin:4px 0 2px}
.rt-tags span{font-size:11px;letter-spacing:.04em;text-transform:uppercase;padding:2px 6px;border-radius:3px;background:#f1f1ec;color:#333;border:1px solid #deded8}
.rt-tags .warn{background:#fff4d6;border-color:#E8BE17}
.dark .rt-tags span{background:#26261f;color:#ddd;border-color:#3a3a32}
.dinfo{display:block;font-size:12px;color:#E8BE17;margin-top:2px}
/* карта водія в режимі навігатора: лежить під нахилом (дорога попереду йде вдалину), значки стоять */
#mapwrap { --tilt: 52deg; }
#mapwrap.tilt { overflow: hidden; perspective: 760px; perspective-origin: 50% 30%; }
#mapwrap.tilt #map { inset: auto; left: -45%; width: 190%; bottom: 0; height: 230%; transform: rotateX(var(--tilt)); transform-origin: 50% 100%; transform-style: preserve-3d; overflow: visible; }  /* обрізання «сплющує» 3D: краї обрізає #mapwrap */
#mapwrap.tilt .leaflet-pane, #mapwrap.tilt .leaflet-marker-icon { transform-style: preserve-3d; }
#mapwrap.tilt .leaflet-marker-icon > * { transform: rotateX(calc(-1 * var(--tilt))); transform-origin: 50% 100%; }
#mapwrap.tilt .leaflet-marker-pane, #mapwrap.tilt .leaflet-tooltip-pane, #mapwrap.tilt .leaflet-popup-pane { transform: translateZ(3px); }   /* значки — над площиною карти */
#mapwrap.tilt .leaflet-control-container { display: none; }
.tilt-zoom, .tilt-attr { display: none; }
#mapwrap.tilt .tilt-zoom { display: flex; flex-direction: column; gap: 6px; position: absolute; right: 10px; bottom: 34px; z-index: 1000; }
#mapwrap.tilt .tilt-zoom .btn { width: 42px; height: 42px; padding: 0; font-size: 22px; line-height: 1; }
#mapwrap.tilt .tilt-attr { display: block; position: absolute; right: 0; bottom: 0; z-index: 1000; font-size: 11px; padding: 1px 6px; background: rgba(255,255,255,.75); color: #333; }
#mapwrap.tilt .tilt-attr a { color: #1a5fb4; }
#mapwrap.tilt .vm-name { top: auto; bottom: 40px; }   /* підпис машини під нахилом — над значком (під ним — «під землею») */

/* фільтри маршрутів: підпис над кожним рядом */
.flt { margin-top: 10px; }
.flt .chips { margin-top: 4px; }
.flt-l { display: block; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #6b6b64; }
#route-sheet, #compose-sheet { width: 100%; margin-top: 4px; min-height: 38px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font: inherit; font-weight: 600; }
#route-sheet.on { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.rt-count { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }

/* ліву панель і «Шари і легенда» можна сховати — більше місця для мапи */
.panel-toggle { position: absolute; top: 12px; left: 12px; z-index: 1000; min-width: 36px; min-height: 36px; padding: 4px 10px; box-shadow: 0 2px 8px rgba(0, 0, 0, .25); }
.disp #app.panel-hidden { grid-template-columns: 1fr; }
.disp #app.panel-hidden #panel { display: none; }
.layers-toggle { display: inline-flex; width: 100%; justify-content: space-between; }
.layers.collapsed { width: auto; padding: 8px; }
.layers.collapsed .layers-body { display: none; }
.layers:not(.collapsed) .layers-body { margin-top: 10px; max-height: calc(100vh - 160px); overflow-y: auto; }
@media (max-width: 760px) {
    .panel-toggle { left: auto; right: 12px; }
    .disp #app.panel-hidden { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr); }
}

/* складання маршруту — окремий зрозумілий екран: кроки 1–3, кнопки «Зберегти / Скасувати» завжди видно внизу */
.disp.composing .summary, .disp.composing .op, .disp.composing .tabs, .disp.composing #reset-all { display: none; }
.disp.composing #tab-routes { display: flex; flex-direction: column; }
.disp.composing #compose-box { order: -1; }
.cmp { display: grid; gap: 12px; margin-bottom: 14px; }
.cmp-head { display: flex; justify-content: space-between; align-items: center; border-bottom: 4px solid var(--gold); padding-bottom: 8px; }
.cmp-head b { font-size: 17px; text-transform: uppercase; letter-spacing: .06em; }
.cmp-step { background: var(--night-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: grid; gap: 8px; }
.cmp-step h3 { margin: 0; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.cmp-step h3 i { font-style: normal; display: inline-flex; width: 24px; height: 24px; border-radius: 50%; background: var(--ink); color: #fff; align-items: center; justify-content: center; font-size: 13px; }
.cmp-step h3 small { font-weight: 400; color: var(--mist); }
.cmp-hint { margin: 0; font-size: 13px; color: var(--mist); }
.cmp-big { width: 100%; min-height: 46px; font-size: 15px; }
.cmp-picked { font-size: 15px; font-weight: 700; padding: 8px 10px; border-radius: 8px; background: #fff; border: 1px solid var(--line); }
.cmp-picked.empty { font-weight: 400; color: var(--mist); }
.cmp-list summary { cursor: pointer; font-size: 14px; }
.cmp-list .compose-list { margin: 8px 0; max-height: 220px; overflow-y: auto; }
#compose-name { width: 100%; min-height: 40px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.cmp-foot { position: fixed; left: 0; bottom: 0; width: 380px; z-index: 1100; display: flex; gap: 8px; padding: 10px 18px; background: var(--night); border-top: 1px solid var(--line); box-shadow: 0 -4px 12px rgba(0, 0, 0, .08); }
.disp.composing #tab-routes { padding-bottom: 90px; }
@media (max-width: 760px) { .cmp-foot { width: 100%; } }
.cmp-foot .btn { flex: 1; min-height: 46px; }
.cmp-sep { margin: 4px 0 0; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--mist); }

@media (max-width: 760px) {
    /* складання на телефоні: мапа нижча — більше місця для кроків; кнопки внизу не накривають останній крок */
    .disp.composing #app { grid-template-rows: 30vh minmax(0, 1fr); }
    .disp.composing #panel { padding-bottom: 84px; }
    .disp.composing #tab-routes { padding-bottom: 24px; }
    .cmp-foot { padding: 8px 12px; }
    .cmp-foot .btn { min-height: 48px; }
}
.disp.composing #toast { bottom: 96px; }   /* повідомлення — над кнопками «Зберегти / Скасувати» */
/* фільтри більше не закріплені вгорі: з пріоритетом, типом і картою тендеру вони займали всю панель на телефоні,
   і список під ними не було видно (здавалось, що панель не гортається) */
.rt-find { position: static; }
.veh-pop { line-height: 1.45; }
.veh-pop-act { margin-top: 8px; }
/* машина, на яку натиснули: угорі панелі її маршруту */
.focus-veh { display: flex; align-items: center; gap: 10px; padding-bottom: 8px; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.focus-veh > div { flex: 1; min-width: 0; }
.focus-veh b { display: block; font-size: 15px; }
.focus-veh small { display: block; font-size: 13px; color: var(--mist); }
.focus-veh .badge { flex: none; width: 28px; height: 28px; font-size: 12px; }
.focus-veh .btn { flex: none; }
@media (max-width: 760px) { .focus-veh { padding-bottom: 6px; margin-bottom: 6px; } .focus-veh small { font-size: 12px; } }
/* вибраний маршрут: кнопки праворуч у панелі */
.focus-btns { display: flex; flex-direction: column; gap: 6px; align-items: stretch; flex: none; }
/* зміна лінії маршруту: на час зміни — лише вона (ні списку маршрутів, ні панелі вибраного маршруту) */
.edit-box .cmp-head { border-bottom: 0; padding-bottom: 0; display: flex; justify-content: space-between; align-items: start; gap: 8px; margin-bottom: 10px; }
.seg-switch { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.seg-switch .btn { flex: 1; }
.edit-box .tab-actions { margin-bottom: 10px; }
.edit-box .tab-actions:last-child { margin-bottom: 0; }
.edit-sum { color: var(--mist); font-size: 13px !important; }
.editing #route-find, .editing #route-actions, .editing #route-list, .editing #reset-all, .editing .focus-bar { display: none !important; }
@media (max-width: 760px) {
    .disp.editing #app { grid-template-rows: 55vh minmax(0, 1fr); }
    .edit-box { padding: 10px 12px; }
    .edit-box p { margin-bottom: 8px; }
}
@media (max-width: 760px) { .disp.editing .summary, .disp.editing .op, .disp.editing .tabs, .disp.editing .brand { display: none; } }

/* команди */
.teams { margin-top: 18px; }
.teams-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.teams-head h3 { margin: 0; font-size: 15px; }
.teams-hint { margin: 4px 0 8px; font-size: 13px; color: var(--mist); }
.team { display: grid; grid-template-columns: 14px 1fr auto; gap: 10px; align-items: start; }
.team .dot { width: 14px; height: 14px; border-radius: 50%; margin-top: 4px; background: var(--c); }
.team-sub { font-size: 13px; color: var(--mist); }
.team-acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.rt-teams { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0; }
.rt-teams button { border: 1px solid var(--line); background: var(--night-2); border-radius: 99px; padding: 3px 10px; font-size: 13px; cursor: pointer; color: inherit; }
.rt-teams button i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--c); margin-right: 5px; }
.focus-assign-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 760px) { .focus-assign-row { grid-template-columns: 1fr; } }

/* поділ маршруту між командами */
#focus-split { margin-top: 8px; width: 100%; }
#split-dlg { width: min(460px, calc(100vw - 24px)); }
.split-teams { display: grid; gap: 6px; margin: 10px 0; }
.split-teams label { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.split-teams i { width: 12px; height: 12px; border-radius: 50%; background: var(--c); }
.split-sum { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 4px; font-size: 14px; }
.split-sum li { display: flex; gap: 8px; align-items: center; }
.split-sum i { width: 22px; height: 6px; border-radius: 3px; background: var(--c); flex: none; }
#split-dlg[open] { position: fixed; left: 12px; top: 80px; margin: 0; z-index: 2000; max-height: calc(100vh - 100px); overflow-y: auto; }
@media (max-width: 760px) { #split-dlg[open] { left: 8px; right: 8px; top: auto; bottom: 8px; width: auto; max-height: 55vh; } }

/* покроковий перегляд маршруту */
.plan-steps { margin-top: 8px; width: 100%; font-weight: 700; }
.stepping .focus-bar { display: none !important; }
.step-bar { position: absolute; z-index: 1001; left: 12px; right: 64px; bottom: 24px; max-width: 460px; background: var(--night); border: 1px solid var(--line); border-left: 6px solid var(--gold); border-radius: var(--radius); padding: 10px 12px; box-shadow: 0 6px 24px rgba(0,0,0,.35); display: grid; gap: 6px; }
.step-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.step-head b { flex: none; font-size: 15px; text-transform: uppercase; letter-spacing: .06em; }
.step-head span { flex: 1; min-width: 0; color: var(--mist); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step-what { font-size: 17px; font-weight: 700; }
.step-how { font-size: 14px; color: var(--mist); }
.step-how::before { content: ''; display: inline-block; width: 18px; border-top: 3px dashed #D62728; vertical-align: middle; margin-right: 6px; }
.step-prog { height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.step-prog i { display: block; height: 100%; background: var(--gold); transition: width .3s; }
.step-btns { display: grid; grid-template-columns: 56px 1fr 56px; gap: 8px; }
.step-btns .btn { font-size: 16px; }
.step-btns .btn:disabled { opacity: .35; cursor: default; }
@media (max-width: 760px) { .step-bar { left: 8px; right: 54px; bottom: 22px; padding: 8px 10px; } .step-what { font-size: 15px; } }

/* ручний порядок маршруту */
.plan-mode { align-items: center; margin-top: 10px; }
.plan-mode .flt-l { margin-right: 4px; color: var(--mist); font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }
.manual-box { margin-top: 8px; display: grid; gap: 8px; }
.manual-list { margin: 0; padding-left: 26px; display: grid; gap: 4px; max-height: 260px; overflow-y: auto; font-size: 14px; }
.manual-list:empty { display: none; }
.manual-list li > * { vertical-align: middle; }
.manual-list li span { margin-right: 4px; }
.manual-list .btn { min-height: 28px; padding: 2px 8px; }
.manual-list .btn:disabled { opacity: .35; }
.manual-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.manual-btns .btn:disabled { opacity: .4; cursor: default; }

/* точки маршруту, що малюється */
.wp { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font: 800 11px/1 var(--font); color: var(--ink);
    background: var(--gold); border: 2px solid #111; box-shadow: 0 1px 4px rgba(0,0,0,.45); cursor: grab; }
.wp.a { background: #22A447; color: #fff; }
.wp.b { background: #D62728; color: #fff; }

.plan-no.drag { width: 22px; height: 22px; cursor: grab; box-shadow: 0 1px 4px rgba(0,0,0,.45); }

/* зони */
.zone-box { margin-top: 8px; display: grid; gap: 8px; }
.zone-km { display: grid; gap: 4px; font-size: 13px; color: var(--mist); }
.zone-km select { min-height: 38px; padding: 4px 8px; border-radius: 8px; border: 1px solid var(--line); font: inherit; font-weight: 600; }
.zone-no { display: inline-block; white-space: nowrap; padding: 3px 8px; border-radius: 99px; background: var(--c); color: #fff; font: 800 12px/1.2 var(--font);
    border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.45); transform: translateX(-50%); margin-left: 35px; }

/* головний у команді: корона, більший значок, підпис видно завжди */
.vm.is-leader .vm-name { font-weight: 800; }
.vm.my-leader { transform: scale(1.3); }
.vm.my-leader .vm-dot { box-shadow: 0 0 0 3px #E8BE17, 0 1px 4px rgba(0,0,0,.5); }
.hide-labels .vm.my-leader .vm-name { display: block; }
.leader-fab { bottom: 92px !important; max-width: 70vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }   /* над «Показати мене», не закриває мапу посередині */
.team-lead { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 13px; }
.team-lead select { min-height: 32px; padding: 2px 6px; border-radius: 8px; border: 1px solid var(--line); font: inherit; }
.vm.my-leader::after { content: '👑'; position: absolute; left: 50%; top: -15px; transform: translateX(-50%); font-size: 16px; line-height: 1; filter: drop-shadow(0 1px 1px rgba(0,0,0,.6)); pointer-events: none; }
