:root {
  /* Завжди темна тема (незалежно від Telegram і системи) */
  color-scheme: dark;
  --bg: #1c1c1e;          /* шапка, картки-листи */
  --text: #f2f2f7;
  --hint: #9a9aa0;
  --link: #5b9cff;
  --btn: #3e88f7;
  --btn-text: #ffffff;
  --sec-bg: #2c2c2e;      /* поля, чіпи, другорядні кнопки */
  --page-bg: #0e0e10;     /* фон сторінки */
  --card: #1c1c1e;
  --sep: rgba(255,255,255,.12);
  --ok: #30d158;
  --ok-bg: rgba(48,209,88,.18);
  --bad: #ff453a;
  --bad-bg: rgba(255,69,58,.18);
  --warn: #ffd60a;
  --warn-bg: rgba(255,214,10,.16);
  --info-bg: rgba(91,156,255,.2);
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--page-bg); color: var(--text); font: 16px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
body { min-height: 100vh; overscroll-behavior-y: contain; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--link); text-decoration: none; }
.loading { padding: 40px; text-align: center; color: var(--hint); }

/* ---- layout ---- */
.topbar { position: fixed; top: 0; left: 0; right: 0; z-index: 30; padding-top: calc(10px + env(safe-area-inset-top, 0px)); background: var(--bg); border-bottom: 1px solid var(--sep); padding: 10px 14px; display: flex; align-items: center; gap: 10px; }
.topbar h1 { margin: 0; font-size: 17px; font-weight: 700; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .sub { font-size: 12px; color: var(--hint); font-weight: 500; }
.topbar .back { font-size: 22px; line-height: 1; padding: 4px 6px; color: var(--link); }
.content { padding: calc(var(--topbar-h, 54px) + 12px) 12px calc(84px + var(--safe-bottom)); }
.content.no-tabs { padding-bottom: calc(24px + var(--safe-bottom)); }
:root { --topbar-h: 54px; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; background: var(--bg); border-top: 1px solid var(--sep); padding-bottom: var(--safe-bottom); }
.tabs button { flex: 1; padding: 8px 4px 6px; font-size: 11px; color: var(--hint); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tabs button .ic { font-size: 20px; line-height: 1.1; }
.tabs button.active { color: var(--link); font-weight: 600; }

.card { background: var(--card); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; box-shadow: 0 1px 0 var(--sep); }
.card h3 { margin: 0 0 8px; font-size: 15px; }
.hint { color: var(--hint); font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; }
.row .grow { flex: 1; min-width: 0; }
.muted { color: var(--hint); }
.right { text-align: right; }
.mt { margin-top: 10px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--btn); color: var(--btn-text); border-radius: 12px; padding: 12px 16px; font-weight: 600; font-size: 15px; width: 100%; }
.btn.secondary { background: var(--sec-bg); color: var(--text); }
.btn.ok { background: var(--ok); color: #fff; }
.btn.bad { background: var(--bad); color: #fff; }
.btn.small { padding: 8px 12px; font-size: 13px; width: auto; border-radius: 10px; }
.btn:disabled { opacity: .5; }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }
.field { margin-bottom: 10px; }
.field label { display: block; font-size: 12px; color: var(--hint); margin-bottom: 4px; }
.input, select.input, textarea.input { width: 100%; background: var(--sec-bg); border: 1px solid transparent; border-radius: 10px; padding: 10px 12px; font-size: 16px; outline: none; }
.input:focus { border-color: var(--link); }
textarea.input { resize: vertical; min-height: 56px; }
.inline-fields { display: flex; gap: 8px; }
.inline-fields .field { flex: 1; min-width: 0; }
.inline-fields .field.narrow { flex: 0 0 96px; }

/* ---- trips list ---- */
.trip-card { display: block; width: 100%; text-align: left; }
.trip-card .title { font-weight: 700; font-size: 16px; }
.trip-card .meta { color: var(--hint); font-size: 13px; margin-top: 2px; }
.trip-card .stats { display: flex; gap: 12px; margin-top: 8px; font-size: 13px; }
.progress { height: 6px; border-radius: 3px; background: var(--sec-bg); overflow: hidden; margin-top: 8px; display: flex; }
.progress i { display: block; height: 100%; }
.progress .ok { background: var(--ok); }
.progress .bad { background: var(--bad); }

/* ---- passengers ---- */
.search { position: sticky; top: var(--topbar-h, 54px); z-index: 15; background: var(--page-bg); padding: 4px 0 8px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; padding: 6px 12px; border-radius: 999px; background: var(--card); font-size: 13px; color: var(--hint); border: 1px solid var(--sep); }
.chip.active { background: var(--btn); color: var(--btn-text); border-color: var(--btn); }
.group { margin: 12px 0 6px; display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; padding: 7px 10px; background: var(--card); border-radius: 12px; border-left: 4px solid var(--link); }
.group .t { font-weight: 700; font-size: 15px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.group .c { color: var(--hint); font-size: 13px; white-space: nowrap; }
.group .acts { display: flex; gap: 6px; margin-left: auto; }
.group .acts .chip-btn { flex: 0 0 auto; width: auto; height: 28px; padding: 0 8px; font-size: 12px; }
.group .c { margin-left: auto; }
.group .acts + .c, .group .c + .acts { margin-left: 0; }
.group.passed { border-left-color: var(--ok); background: var(--ok-bg); }
.group.passed .t { color: var(--hint); }
.chip-btn { display: inline-flex; align-items: center; gap: 4px; height: 30px; padding: 0 10px; border-radius: 8px; font-size: 13px; font-weight: 600; border: 1px solid var(--sep); background: var(--sec-bg); color: var(--text); }
.chip-btn.pass { color: var(--hint); }
.chip-btn.pass.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.chip-btn.drop { color: #b9a6ff; border-color: rgba(185,166,255,.5); }
.eta-status.warn { color: #ffd60a; }
.pass { display: flex; align-items: center; gap: 10px; background: var(--card); border-radius: 12px; padding: 10px 12px; margin-bottom: 6px; width: 100%; text-align: left; border-left: 4px solid transparent; }
.pass.boarded { border-left-color: var(--ok); }
.pass.noshow { border-left-color: var(--bad); opacity: .75; }
.pass.noshow .name { text-decoration: line-through; }
.seat-badge { flex: 0 0 44px; height: 44px; border-radius: 10px; background: var(--sec-bg); display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; line-height: 1; }
.seat-badge small { font-size: 9px; color: var(--hint); font-weight: 500; margin-top: 3px; }
.pass.boarded .seat-badge { background: var(--ok-bg); color: var(--ok); }
.pass.noshow .seat-badge { background: var(--bad-bg); color: var(--bad); }
.pass > .info { flex: 1; min-width: 0; }
.pass .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 6px; }
.pass .name .dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; }
.pass .dest { font-size: 13px; color: var(--hint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pass .tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 3px; }
.tag { flex: 0 0 auto; display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 6px; background: var(--sec-bg); color: var(--hint); }
.tag.warn { background: var(--warn-bg); color: #ffd60a; }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.pick { background: var(--info-bg); color: var(--link); }
.pass .amt { text-align: right; font-weight: 600; font-size: 14px; white-space: nowrap; }
.pass .amt small { display: block; font-size: 11px; color: var(--hint); font-weight: 400; }
.pass .st { font-size: 20px; flex: 0 0 auto; }
.empty { text-align: center; color: var(--hint); padding: 30px 10px; }

/* ---- seat map ---- */
.bus-title { font-weight: 700; margin: 6px 0 8px; display: flex; align-items: center; gap: 8px; }
.bus-grid { display: grid; gap: 5px; justify-content: center; margin: 0 auto 16px; }
.seat { height: 44px; border-radius: 9px; background: var(--card); border: 1.5px solid var(--sep); display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; line-height: 1; padding: 0; color: var(--text); }
.seat small { font-size: 9px; font-weight: 500; color: var(--hint); margin-top: 2px; white-space: nowrap; overflow: hidden; max-width: 100%; }
.seat.pending { background: var(--info-bg); border-color: var(--link); }
.seat.boarded { background: var(--ok); border-color: var(--ok); color: #fff; }
.seat.boarded small { color: rgba(255,255,255,.85); }
.seat.noshow { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }
.seat.service { border-style: dashed; color: var(--hint); }
.seat.free { opacity: .8; }
.seat.booked { background: var(--warn-bg); border-color: var(--warn); }
.cell-empty { }
.cell-aisle { }
.cell-stairs { display: flex; align-items: center; justify-content: center; font-size: 10px; color: var(--hint); border: 1px dashed var(--sep); border-radius: 9px; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--hint); margin-bottom: 10px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 4px; border: 1px solid var(--sep); }

/* ---- cash ---- */
.big { font-size: 26px; font-weight: 800; }
.kv { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--sep); font-size: 15px; }
.kv:last-child { border-bottom: 0; }
.kv b { font-weight: 700; }
.kv.total { font-size: 17px; }
.pos { color: var(--ok); }
.neg { color: var(--bad); }
.counts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 4px; }
.counts div { background: var(--sec-bg); border-radius: 10px; padding: 8px 4px; text-align: center; }
.counts b { display: block; font-size: 20px; }
.counts span { font-size: 11px; color: var(--hint); }
.list-item { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--sep); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .t { font-weight: 600; }
.list-item .s { font-size: 12px; color: var(--hint); }
.list-item .a { font-weight: 700; white-space: nowrap; }
.del { color: var(--bad); font-size: 18px; padding: 6px; }
pre.report { white-space: pre-wrap; font: 13px/1.4 ui-monospace, Menlo, Consolas, monospace; color: var(--text); background: var(--sec-bg); border-radius: 10px; padding: 10px; margin: 0; }

/* ---- sheet ---- */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50; display: flex; align-items: flex-end; animation: fade .15s; }
.sheet { position: relative; background: var(--bg); width: 100%; max-height: 92vh; overflow-y: auto; overscroll-behavior: contain; border-radius: 18px 18px 0 0; padding: 8px 16px calc(16px + var(--safe-bottom)); animation: up .2s; }
.sheet-close { position: absolute; top: 10px; right: 10px; width: 34px; height: 34px; border-radius: 50%; background: var(--sec-bg); color: var(--hint); font-size: 16px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.sheet h2 { padding-right: 40px; }
.sheet .handle { width: 36px; height: 4px; border-radius: 2px; background: var(--sep); margin: 4px auto 12px; }
.sheet h2 { margin: 0 0 2px; font-size: 19px; display: flex; align-items: center; gap: 8px; }
.sheet .meta { color: var(--hint); font-size: 14px; margin-bottom: 12px; }
.phones { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.phones a { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 12px; font-weight: 600; line-height: 1; }
.phones a.tel { background: var(--sec-bg); border-radius: 10px 0 0 10px; }
.phones a.viber { background: #7360f2; color: #fff; border-radius: 0 10px 10px 0; font-size: 14px; }
.status-btns { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin: 10px 0 14px; }
.status-btns .btn { padding: 12px 6px; font-size: 14px; }
.status-btns .btn.inactive { background: var(--sec-bg); color: var(--text); }
@keyframes up { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

#toast { position: fixed; left: 50%; bottom: calc(90px + var(--safe-bottom)); transform: translateX(-50%); background: rgba(60,60,64,.96); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 100; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; }

/* ---- sync badge ---- */
.sync { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; gap: 4px; height: 26px; line-height: 1; align-self: center; font-size: 11px; font-weight: 600; padding: 0 9px; border-radius: 999px; background: var(--sec-bg); color: var(--hint); white-space: nowrap; }
.sync.ok { color: var(--ok); }
.sync.pend { background: var(--warn-bg); color: #ffd60a; }
.sync.off { background: var(--bad-bg); color: var(--bad); }
.sync.busy { color: var(--link); }

.steps { margin: 0; padding-left: 20px; font-size: 14px; }
.steps li { margin-bottom: 6px; }

/* ---- групи «їдуть разом» ---- */
.tag.grp { background: rgba(153,102,255,.22); color: #b9a6ff; }
.group-box { background: var(--sec-bg); border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; }
.group-box .t { font-weight: 700; margin-bottom: 6px; }
.group-box .member { display: flex; justify-content: space-between; align-items: center; width: 100%; text-align: left; padding: 7px 0; border-bottom: 1px solid var(--sep); font-size: 14px; gap: 8px; }
.group-box .member:last-of-type { border-bottom: 0; }


.phone-row { display: inline-flex; }

/* ---- перемикач Посадка / Висадка ---- */
.seg { display: flex; background: var(--card); border: 1px solid var(--sep); border-radius: 10px; padding: 3px; margin-top: 6px; }
.seg button { flex: 1; padding: 7px 4px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--hint); }
.seg button.active { background: var(--btn); color: var(--btn-text); }

/* ---- порядок висадки ---- */
.seg .order-btn { flex: 0 0 auto; background: var(--sec-bg); color: var(--text); margin-left: 3px; }
.order-row { display: flex; align-items: center; gap: 8px; padding: 8px 4px; border-bottom: 1px solid var(--sep); font-size: 15px; background: var(--bg); }
.order-row .n { color: var(--hint); width: 24px; }
.order-row .grow { flex: 1; }
.order-row .mv { width: 40px; height: 36px; border-radius: 8px; background: var(--sec-bg); font-size: 14px; }
.order-row .mv:disabled { opacity: .3; }

/* ---- прогноз прибуття ---- */
.eta { display: inline-block; margin-top: 2px; font-size: 12px; font-weight: 600; color: var(--link); }
.eta.done { color: var(--ok); }
.eta-status { font-size: 12px; color: var(--hint); padding: 6px 4px 0; }
.eta-status.bad { color: var(--bad); }
.group .pass-btn { flex: 0 0 auto; width: 30px; height: 26px; border-radius: 8px; background: var(--card); border: 1px solid var(--sep); font-size: 13px; color: var(--ok); margin-left: 6px; }
.group .pass-btn.done { color: var(--hint); }
.seg .order-btn.active { background: var(--btn); color: var(--btn-text); }
.order-row .pt { display: block; font-size: 11px; color: var(--hint); font-weight: 400; }
.order-row .nav { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.point-form { padding: 8px 4px 10px 28px; border-bottom: 1px solid var(--sep); }

#upd-bar { position: fixed; left: 12px; right: 12px; bottom: calc(70px + var(--safe-bottom)); z-index: 250; display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--btn); color: var(--btn-text); padding: 10px 14px; border-radius: 12px; box-shadow: 0 4px 16px rgba(0,0,0,.25); font-size: 14px; }
#upd-bar button { background: #fff; color: var(--btn); border-radius: 8px; padding: 6px 12px; font-weight: 700; }

.seg.mini { margin-top: 6px; }
.seg.mini button { padding: 5px 4px; font-size: 12px; }
.pass .eta { margin-top: 0; }

/* ---- статус «висадили» ---- */
.pass.dropped { border-left-color: #8e8e93; opacity: .8; }
.pass.dropped .seat-badge { background: rgba(142,142,147,.2); color: #b0b0b5; }
.seat.dropped { background: var(--card); border-color: var(--sep); color: var(--hint); border-style: dotted; }
.btn.drop { background: #5e5ce6; color: #fff; }
.status-btns.four { grid-template-columns: 1fr 1fr; }
.status-btns .btn.drop.inactive { background: var(--sec-bg); color: var(--text); }
.group .pass-btn.drop { width: auto; padding: 0 8px; color: #5e5ce6; font-size: 12px; }
.counts.five { grid-template-columns: repeat(5, 1fr); }
.counts.five b { font-size: 18px; }
.progress .ok { background: var(--ok); }

.eta-status.me { color: var(--text); font-size: 13px; }

select.input option { background: #2c2c2e; color: #fff; }
.btn.secondary { border: 1px solid var(--sep); }

/* ---- таблиця каси ---- */
.cash-wrap { overflow-x: auto; }
.cash-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.cash-table th, .cash-table td { padding: 7px 6px; text-align: right; border-bottom: 1px solid var(--sep); white-space: nowrap; }
.cash-table th:first-child, .cash-table td:first-child { text-align: left; color: var(--hint); font-weight: 500; }
.cash-table th { color: var(--text); font-weight: 700; }
.cash-table tr.total td { font-weight: 800; font-size: 15px; border-bottom: 0; padding-top: 10px; }
.cash-table td.neg { color: var(--bad); }
.cash-table td.pos { color: var(--ok); }

/* ---- квитанції ---- */
.file-btn { display: flex; align-items: center; gap: 8px; background: var(--sec-bg); border: 1px dashed var(--sep); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; font-weight: 600; cursor: pointer; }
.file-btn input { display: none; }
.file-btn .hint { font-weight: 400; margin-left: auto; }
.rcpt { font-size: 18px; padding: 6px; position: relative; cursor: pointer; }
.rcpt small { position: absolute; right: 0; bottom: 0; font-size: 10px; }
.rcpt.add { opacity: .6; }
.rcpt input { display: none; }
.receipt-img { width: 100%; border-radius: 12px; background: #000; max-height: 70vh; object-fit: contain; }

/* ---- карта ---- */
.map { height: calc(100vh - var(--topbar-h, 54px) - 150px - var(--safe-bottom)); min-height: 320px; border-radius: 14px; overflow: hidden; background: #1c1c1e; }
.leaflet-container { background: #1c1c1e; font: inherit; }
.map:not(.sat) .leaflet-tile { filter: brightness(.82) contrast(1.05) saturate(.9); }
.map.sat .leaflet-tile { filter: none; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: #2c2c2e; color: var(--text); }
.leaflet-popup-content a { color: var(--link); }
.leaflet-control-zoom a { background: #2c2c2e; color: var(--text); border-color: var(--sep); }
.leaflet-control-attribution { background: rgba(28,28,30,.7); color: var(--hint); font-size: 10px; }
.city-pin .pin { width: 26px; height: 26px; border-radius: 50%; color: #fff; font-weight: 800; font-size: 13px; display: flex; align-items: center; justify-content: center; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.5); }
.bus-pin .bus { width: 86px; height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; }
.bus-pin .bus .mk { font: 700 17px/1 "Fredoka", "Arial Rounded MT Bold", "Varela Round", Arial, sans-serif; color: #fff; letter-spacing: 0; white-space: nowrap; text-shadow: 0 0 2px #000, 0 1px 4px rgba(0,0,0,.95), 0 0 6px rgba(0,0,0,.8); display: flex; align-items: baseline; }
.bus-pin .bus .mk span { color: #3e88f7; font-weight: 700; font-style: normal; font-size: 14px; margin-left: 1px; }
.bus-pin .bus .mk span i { color: #fff; font-style: normal; }
.bus-pin .bus img { height: 32px; width: auto; display: block; filter: drop-shadow(0 0 1.5px #000) drop-shadow(0 1px 5px rgba(0,0,0,.95)); }
.topbar .logo { height: 30px; width: auto; border-radius: 6px; flex: 0 0 auto; }
.me-pin .me { width: 30px; height: 30px; border-radius: 50%; background: #ff9f0a; display: flex; align-items: center; justify-content: center; font-size: 17px; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.5); }
.map-ctl { display: flex; gap: 6px; margin: 8px 0 6px; flex-wrap: wrap; }
.tabs button { font-size: 10px; }
