:root {
  --accent: #2456C7; --accent-dark: #1a44a0; --accent-soft: #E6F0FF;
  --ink: #1a1a1a; --muted: #5c5c5c; --faint: #8a8a8a; --line: #e0e0e0; --bg: #f4f5f7; --card: #ffffff;
  --ok-bg: #E8F5EC; --ok: #1B5E3A; --warn-bg: #FFF1E6; --warn: #8a3410; --bad: #B5461D; --bad-bg: #FBEBEB;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: Inter, -apple-system, "Segoe UI", Roboto, system-ui, sans-serif; font-size: 15px; line-height: 1.4; -webkit-text-size-adjust: 100%; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.app { max-width: 560px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
@media (min-width: 900px) { .app { max-width: 720px; } .wide .app { max-width: 1100px; } }
.loading { padding: 40px; text-align: center; color: var(--muted); }

/* Толгой */
.topbar { position: sticky; top: 0; z-index: 10; background: rgba(244,245,247,0.92); backdrop-filter: blur(8px); padding: calc(10px + env(safe-area-inset-top)) 16px 10px; display: flex; align-items: center; gap: 12px; }
.topbar h1 { font-size: 19px; margin: 0; flex: 1; font-weight: 700; }
.topbar .sub { font-size: 12px; color: var(--muted); font-weight: 400; display: block; }
.iconbtn { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); display: inline-flex; align-items: center; justify-content: center; position: relative; cursor: pointer; flex-shrink: 0; }
.iconbtn svg { width: 22px; height: 22px; stroke: var(--ink); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.badge { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0 5px; }
.dot { position: absolute; top: 8px; right: 8px; width: 9px; height: 9px; border-radius: 50%; background: var(--bad); }

main { padding: 6px 16px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; flex: 1; }

/* Карт, товч */
.card { background: var(--card); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.card.link { cursor: pointer; }
.card.link:active { background: #fafafa; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.title { font-size: 15px; font-weight: 600; }
.small { font-size: 13px; color: var(--muted); }
.tiny { font-size: 12px; color: var(--faint); }
.section { font-size: 15px; font-weight: 700; margin-top: 4px; }
.btn { height: 50px; border-radius: 12px; border: none; background: var(--accent); color: #fff; font-size: 16px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; cursor: pointer; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn.secondary { background: var(--card); color: var(--ink); border: 1.5px solid var(--line); }
.btn.outline { background: transparent; color: var(--accent); border: 1.5px solid var(--accent); }
.btn.danger { background: var(--card); color: var(--warn); border: 1.5px solid var(--line); }
.btn.dark { background: var(--ink); }
.btn.sm { height: 40px; font-size: 14px; width: auto; padding: 0 14px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.hero { background: var(--accent); color: #fff; border-radius: 16px; padding: 18px 20px; display: flex; align-items: center; gap: 14px; }
.hero .ic { width: 48px; height: 48px; border-radius: 12px; background: rgba(255,255,255,0.18); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.hero .ic svg { width: 26px; height: 26px; stroke: #fff; fill: none; stroke-width: 2; stroke-linecap: round; }
.tile { background: var(--card); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; min-height: 92px; color: var(--ink); }
.tile svg { width: 22px; height: 22px; stroke: var(--accent); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Пилл */
.pill { font-size: 11px; font-weight: 600; padding: 4px 8px; border-radius: 999px; white-space: nowrap; }
.pill.pending { background: var(--warn-bg); color: var(--warn); }
.pill.approved, .pill.checked { background: var(--accent-soft); color: var(--accent-dark); }
.pill.done { background: var(--ok-bg); color: var(--ok); }
.pill.returned, .pill.blocked, .pill.cancelled { background: var(--bad-bg); color: var(--bad); }
.pill.in_trip { background: var(--ink); color: #fff; }
.pill.gray { background: #ececec; color: var(--muted); }

/* Форм */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: #3a3a3a; }
.field input, .field select, .field textarea { height: 50px; border: 1.5px solid #d6d6d6; border-radius: 12px; padding: 0 14px; background: #fff; width: 100%; font-size: 16px; }
.field textarea { height: auto; min-height: 80px; padding: 12px 14px; }
.field .hint { font-size: 12px; color: var(--muted); }
.seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.seg button { height: 46px; border-radius: 12px; border: 1.5px solid #d6d6d6; background: #fff; font-size: 15px; cursor: pointer; }
.seg button.on { border: 2px solid var(--accent); background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; }
.choice { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1.5px solid #d6d6d6; border-radius: 12px; cursor: pointer; background: #fff; }
.choice.on { border: 2px solid var(--accent); background: var(--accent-soft); }
.choice.off { opacity: 0.5; cursor: not-allowed; }
.radio { width: 20px; height: 20px; border-radius: 50%; border: 2px solid #c4c4c4; flex-shrink: 0; }
.choice.on .radio { background: var(--accent); border-color: var(--accent); }
.error { background: var(--bad-bg); color: var(--bad); padding: 10px 14px; border-radius: 10px; font-size: 14px; }
.notice { background: var(--warn-bg); color: var(--warn); padding: 10px 14px; border-radius: 10px; font-size: 13px; }

/* Батлах шатлал */
.steps { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid #ececec; padding-top: 10px; }
.step { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.step .mark { width: 20px; height: 20px; border-radius: 50%; border: 2px solid #c4c4c4; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.step.ok .mark { background: #1B7F5C; border-color: #1B7F5C; }
.step.ok .mark::after { content: ""; width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0; transform: translateY(-1px) rotate(45deg); }
.step.now .mark { border-color: var(--accent); }
.step.now { font-weight: 600; }
.step.ret .mark { background: var(--bad); border-color: var(--bad); }
.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; font-size: 13px; }
.kv .k { font-size: 11px; color: var(--faint); }
.kv .v { font-weight: 500; }

/* Шалгах хуудас */
.check { display: flex; justify-content: space-between; align-items: center; min-height: 44px; gap: 8px; }
.check .opts { display: flex; gap: 6px; }
.check .opts button { font-size: 12px; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--faint); cursor: pointer; }
.check .opts button.ok { background: var(--ok-bg); color: var(--ok); font-weight: 600; border-color: transparent; }
.check .opts button.bad { background: var(--bad-bg); color: var(--bad); font-weight: 600; border-color: transparent; }
.instr { max-height: 260px; overflow-y: auto; white-space: pre-wrap; font-size: 13.5px; line-height: 1.5; background: #fafafa; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; color: #2a2a2a; }
.vicon { flex-shrink: 0; }
.cat-pick { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.cat-pick button { border: 1.5px solid #d6d6d6; border-radius: 12px; background: #fff; padding: 8px 4px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 10.5px; color: var(--muted); cursor: pointer; }
.cat-pick button.on { border: 2px solid var(--accent); background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; }
.sign { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1.5px dashed #b8b8b8; border-radius: 10px; cursor: pointer; }
.sign.on { border: 1.5px solid var(--accent); background: var(--accent-soft); }
.sign input { width: 20px; height: 20px; }

/* Хуваарь */
.days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.days button { height: 56px; border-radius: 10px; border: none; background: var(--card); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer; }
.days button span:first-child { font-size: 10px; color: var(--faint); }
.days button span:last-child { font-size: 15px; font-weight: 600; }
.days button.on { background: var(--accent); color: #fff; }
.days button.on span { color: #fff; }
.hours { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 3px; }
.hours div { height: 32px; border-radius: 6px; background: var(--ok-bg); }
.hours div.busy { background: var(--accent); }
.hours div.repair { background: #e0e0e0; }
.hourlbl { display: flex; justify-content: space-between; font-size: 10px; color: var(--faint); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.legend span::before { content: ""; display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -2px; background: var(--ok-bg); border: 1px solid #a9d6b7; }
.legend span.b::before { background: var(--accent); border-color: var(--accent); }
.legend span.r::before { background: #e0e0e0; border-color: #e0e0e0; }

/* Аялал */
.odo { background: var(--accent); color: #fff; border-radius: 16px; padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.odo .grid3 div { display: flex; flex-direction: column; gap: 2px; }
.odo .lbl { font-size: 11px; opacity: 0.8; }
.odo .num { font-size: 22px; font-weight: 700; }
.photo { height: 92px; border-radius: 10px; border: 1.5px dashed #b8b8b8; background: #fafafa; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 12px; color: #3a3a3a; cursor: pointer; overflow: hidden; position: relative; }
.photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo input { display: none; }
.photo svg { width: 22px; height: 22px; stroke: #3a3a3a; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Тайлан */
table.rep { width: 100%; border-collapse: collapse; font-size: 13px; }
table.rep th, table.rep td { padding: 8px 6px; border-bottom: 1px solid #eee; text-align: left; }
table.rep th { font-size: 11px; color: var(--faint); font-weight: 600; }
table.rep td.n, table.rep th.n { text-align: right; font-variant-numeric: tabular-nums; }
.stat { background: var(--card); border-radius: var(--radius); padding: 12px 14px; }
.stat b { display: block; font-size: 20px; color: var(--accent); }
.stat span { font-size: 12px; color: var(--muted); }

/* Доод таб */
.tabs { position: sticky; bottom: 0; background: var(--card); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(var(--n, 4), 1fr); padding: 6px 0 calc(6px + env(safe-area-inset-bottom)); }
.tabs a { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; color: var(--faint); padding: 4px; }
.tabs a.on { color: var(--accent); font-weight: 600; }
.tabs svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 50; max-width: 90vw; box-shadow: 0 6px 20px rgba(0,0,0,0.2); }
.toast.bad { background: var(--bad); }

/* Нэвтрэх */
.login { padding: 72px 28px 40px; display: flex; flex-direction: column; gap: 28px; flex: 1; }
.logo { width: 56px; height: 56px; border-radius: 16px; background: var(--accent); display: flex; align-items: center; justify-content: center; }
.logo svg { width: 30px; height: 30px; stroke: #fff; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.login h1 { font-size: 26px; margin: 0; line-height: 1.2; }
.notif { border-left: 3px solid var(--line); padding-left: 10px; }
.notif.unread { border-color: var(--accent); }
.empty { text-align: center; color: var(--faint); padding: 24px; font-size: 14px; }

/* ---- v3: цагийн шугам, маршрут, админ ---- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { height: 34px; padding: 0 12px; border-radius: 999px; border: 1.5px solid var(--line); background: #fff; font-size: 13px; color: var(--ink); cursor: pointer; }
.chips button:active { background: var(--accent-soft); }
.grid3 .field input[type=time], .grid3 .field input[type=date] { padding: 0 8px; }
.tl { position: relative; padding-bottom: 16px; }
.tl-track { position: relative; height: 34px; border-radius: 8px; background: var(--ok-bg); overflow: hidden; }
.tl.compact .tl-track { height: 22px; }
.tl-track.click { cursor: copy; }
.tl-track.repair { background: repeating-linear-gradient(45deg, #ececec, #ececec 6px, #e2e2e2 6px, #e2e2e2 12px); }
.tl-track i { position: absolute; top: 0; bottom: 0; width: 1px; background: rgba(0,0,0,0.07); }
.tl-bar { position: absolute; top: 3px; bottom: 3px; border-radius: 6px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 600; display: flex; align-items: center; padding: 0 6px; overflow: hidden; white-space: nowrap; min-width: 4px; text-decoration: none; }
.tl-bar span { overflow: hidden; text-overflow: ellipsis; }
.tl-bar.pend { background: #E8A13A; }
.tl-bar.sel { background: rgba(36,86,199,0.12); border: 2px dashed var(--accent); color: var(--accent-dark); }
.tl-bar.sel.bad { background: rgba(181,70,29,0.15); border-color: var(--bad); color: var(--bad); }
.tl.compact .tl-bar { top: 2px; bottom: 2px; font-size: 10px; padding: 0 4px; }
.tl-now { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--bad); }
.tl-repair { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; color: var(--muted); font-weight: 600; }
.tl-lbl { position: absolute; left: 0; right: 0; bottom: 0; height: 14px; }
.tl-lbl span { position: absolute; transform: translateX(-50%); font-size: 10px; color: var(--faint); }
.tl-lbl span:first-child { transform: none; }
.legend span.p::before { background: #E8A13A; border-color: #E8A13A; }
.legend span.h::before { display: none; }
.legend span.h { color: var(--faint); }
.slot { display: flex; gap: 10px; align-items: center; font-size: 13px; color: var(--ink); padding: 6px 0; border-top: 1px solid #f0f0f0; }
.slot b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.route { display: flex; align-items: center; gap: 8px; position: relative; padding: 2px 0; }
.route .rdot { width: 10px; height: 10px; border-radius: 50%; border: 2.5px solid var(--accent); flex-shrink: 0; background: #fff; }
.route.end .rdot { background: var(--accent); }
.route.via .rdot { border-color: var(--faint); width: 8px; height: 8px; margin: 0 1px; }
.search { height: 42px; border: 1.5px solid #d6d6d6; border-radius: 10px; padding: 0 12px; background: #fff; font-size: 15px; min-width: 0; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-dark); font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.perms { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 4px 10px; }
.pchk { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; padding: 4px 0; cursor: pointer; }
.pchk input { width: 18px; height: 18px; margin: 0; flex-shrink: 0; accent-color: var(--accent); }
.chainrow { gap: 8px; flex-wrap: wrap; }
.chainrow .sr { flex: 1 1 160px; }
.stepno { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.cards { display: flex; flex-direction: column; gap: 12px; }
@media (min-width: 900px) {
  .wide .cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); align-items: start; }
  .wide .tabs { max-width: 1100px; margin: 0 auto; width: 100%; }
}

/* v4: админ табууд, үйлдлийн бүртгэл */
.seg.admtabs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.seg.admtabs button { font-size: 14px; height: 42px; padding: 0 6px; }
@media (min-width: 900px) { .seg.admtabs { grid-template-columns: repeat(var(--n), minmax(0, 1fr)); } }
.card.audit { gap: 6px; display: flex; flex-direction: column; }
.card.audit.bad { border-left: 4px solid #c0392b; }
.card.audit details summary { cursor: pointer; color: var(--accent-dark); }
.card.audit details > div { padding: 4px 0 0 8px; border-left: 2px solid #e3e3e3; margin-top: 4px; overflow-wrap: anywhere; }

/* v5: гарах товч, газар сонгох, онцлог захиалга, шүүлтүүр */
.logout { display: inline-flex; align-items: center; gap: 6px; height: 44px; padding: 0 14px; border-radius: 12px; border: 1.5px solid var(--bad); background: var(--bad-bg); color: var(--bad); font-weight: 700; font-size: 15px; cursor: pointer; flex-shrink: 0; }
.logout svg { width: 20px; height: 20px; }
.pf { position: relative; }
.pf input { padding-right: 44px; width: 100%; }
.pfx { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; border-radius: 8px; border: 0; background: #eee; color: #555; font-size: 14px; cursor: pointer; }
.pf input:placeholder-shown + .pfx { display: none; }
.pill.star { background: #fff4d6; color: #8a5a00; }
.sign.star { border-color: #e0b44a; }
.sign.star.on { border: 1.5px solid #d49b16; background: #fff8e6; }
.pchk.star { background: #fff8e6; border-radius: 8px; padding: 6px 8px; font-weight: 600; color: #7a5200; }
.notice.star { background: #fff8e6; color: #7a5200; }
.card.filters { display: flex; flex-direction: column; gap: 10px; }

.card.warnbox { border: 2px solid var(--warn); background: var(--warn-bg); }
code { font-size: 12px; background: rgba(0,0,0,.05); padding: 1px 4px; border-radius: 4px; overflow-wrap: anywhere; }

.cards > [data-list="places"] { grid-column: 1 / -1; }

/* 1.4: албан лого, апп суулгах */
.brand { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; }
.brand img { width: 120px; height: auto; margin-bottom: 6px; }
.brand h1 { margin: 0; }
.card.install { display: flex; flex-direction: column; gap: 10px; border: 1.5px solid #c9d8f2; background: linear-gradient(180deg, #f4f8ff, #fff); }
.iconbtn.sm { width: 32px; height: 32px; border-radius: 8px; font-size: 13px; }
