/* «Современный диспетчерский» стиль. Шрифт Inter лежит на сервере (static/fonts, лицензия OFL). */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url(/static/fonts/inter-cyrillic.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url(/static/fonts/inter-latin.woff2) 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+20B4, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  color-scheme: light;
  --bg: #f4f5f8; --surface: #ffffff; --ink: #0f172a; --muted: #5b6577;
  --line: #f0f1f5; --border: #d5d9e2; --soft: #fafbfd; --chip: #eef0f4; --chip-ink: #3f4757;
  --blue: #2563eb; --blue-hover: #1d4ed8; --nav-on-bg: #e8f0fe; --nav-on-ink: #1d4ed8;
  --adr: #ffb020; --dark: #0f172a; --teal: #5eead4;
  --good: #0f6b3f; --good-bg: #e7f6ee; --bad: #a12318; --bad-bg: #fdeaea; --warn: #8a5a00; --accent: #d97706;
  --shadow: 0 1px 3px rgba(15, 23, 42, .06);
  --link: #1d4ed8; --card-border: #eceef3; --border-hover: #aab2c0; --border-soft: #e3e6ec; --hover: #f6f7fa; --side-border: #e6e8ee;
  --grid: #e9ebf0; --warn-bg: #fdf3dc; --kpi-dark: #0f172a; --kpi-dark-border: #0f172a; --side-shadow: 0 -2px 10px rgba(15, 23, 42, .06);
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%235b6577' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --tap: 40px; --side: 84px;
}
@media (pointer: coarse) { :root { --tap: 44px; } }

/* ---------- тёмная схема: «как в системе» или выбранная вручную ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #08130e; --surface: #0f1d16; --ink: #e5efe8; --muted:#98aea1;
    --line: #1a2e23; --border: #2e4a3b; --soft: #0b1912; --chip: #1a2e23; --chip-ink: #cfe3d6;
    --blue: #059669; --blue-hover: #047857; --nav-on-bg: #143726; --nav-on-ink: #6ee7b7; --link: #6ee7b7;
    --good: #4ade80; --good-bg: #0f2e1d; --bad: #fca5a5; --bad-bg: #3a1414; --warn: #fbbf24; --warn-bg: #33270a; --accent: #f59e0b;
    --shadow: 0 1px 3px rgba(0, 0, 0, .45); --card-border: #1a2e23; --border-hover: #46705a; --border-soft: #22392c; --hover: #142a1f; --side-border: #1a2e23;
    --grid: #1e3428; --kpi-dark: #03110a; --kpi-dark-border: #166534; --side-shadow: 0 -2px 12px rgba(0, 0, 0, .5);
    --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%2398aea1' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #08130e; --surface: #0f1d16; --ink: #e5efe8; --muted:#98aea1;
  --line: #1a2e23; --border: #2e4a3b; --soft: #0b1912; --chip: #1a2e23; --chip-ink: #cfe3d6;
  --blue: #059669; --blue-hover: #047857; --nav-on-bg: #143726; --nav-on-ink: #6ee7b7; --link: #6ee7b7;
  --good: #4ade80; --good-bg: #0f2e1d; --bad: #fca5a5; --bad-bg: #3a1414; --warn: #fbbf24; --warn-bg: #33270a; --accent: #f59e0b;
  --shadow: 0 1px 3px rgba(0, 0, 0, .45); --card-border: #1a2e23; --border-hover: #46705a; --border-soft: #22392c; --hover: #142a1f; --side-border: #1a2e23;
  --grid: #1e3428; --kpi-dark: #03110a; --kpi-dark-border: #166534; --side-shadow: 0 -2px 12px rgba(0, 0, 0, .5);
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%2398aea1' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.45 var(--font); font-variant-numeric: tabular-nums; }
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
[hidden], section[hidden] { display: none !important; }
.offtab { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- боковая панель ---------- */
.side { position: fixed; left: 0; top: 0; bottom: 0; width: var(--side); background: var(--surface); border-right: 1px solid var(--side-border);
  display: flex; flex-direction: column; align-items: center; gap: 18px; padding: calc(16px + env(safe-area-inset-top, 0px)) 6px 16px; z-index: 20; }
.plate { width: 44px; display: grid; grid-template-rows: 1fr 1fr; background: var(--adr); color: var(--ink); border: 2px solid var(--ink); border-radius: 8px;
  font-weight: 800; text-align: center; line-height: 1; flex: none; overflow: hidden; }
.plate span { display: flex; align-items: center; justify-content: center; font-size: 13px; padding: 4px 0; }
.plate span + span { border-top: 2px solid var(--ink); font-size: 11px; }
.side nav { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.side nav button { font: inherit; font-size: 11px; font-weight: 600; line-height: 1.2; color: var(--muted); background: none; border: 0; border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 9px 2px; min-height: 56px; cursor: pointer; text-align: center; }
.side nav button:hover { background: var(--hover); color: var(--ink); }
.side nav button[aria-selected="true"] { background: var(--nav-on-bg); color: var(--nav-on-ink); }
.side nav svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }

/* ---------- основная область ---------- */
.main { margin-left: var(--side); padding: 20px clamp(16px, 2vw, 40px) 48px; }   /* на всю ширину окна */
.top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; margin-bottom: 6px; }
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.truck { flex: none; height: clamp(40px, 3vw, 54px); aspect-ratio: 218 / 61; background-color: var(--muted);
  -webkit-mask: url(/static/truck.png?v=1) center / contain no-repeat; mask: url(/static/truck.png?v=1) center / contain no-repeat; }
@media (max-width: 700px) { .truck { height: 30px; } }
.titles h1 { font-size: clamp(20px, 1.5vw, 28px); line-height: 1.25; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.userbox { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; margin-left: 4px; }
.status { color: var(--muted); font-size: 13px; margin: 4px 0 14px; min-height: 1.4em; }
.status.err { color: var(--bad); font-weight: 600; }

/* ---------- кнопки ---------- */
.pill-btn { font: inherit; font-size: 14px; font-weight: 600; border-radius: 999px; padding: 0 18px; min-height: var(--tap); cursor: pointer; white-space: nowrap; }
.pill-btn.blue { background: var(--blue); color: #fff; border: 1px solid var(--blue); }
.pill-btn.blue:hover { background: var(--blue-hover); border-color: var(--blue-hover); }
.pill-btn.light { background: var(--surface); color: var(--ink); border: 1px solid var(--border); }
.pill-btn.light:hover { border-color: var(--border-hover); }
.linkbtn { font: inherit; font-size: 13px; color: var(--link); background: none; border: 0; padding: 0 6px; min-height: 32px; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
button.primary { font: inherit; font-weight: 600; border-radius: 999px; padding: 0 18px; min-height: var(--tap); cursor: pointer; background: var(--blue); color: #fff; border: 1px solid var(--blue); }
button.sec { font: inherit; font-weight: 600; border-radius: 999px; padding: 0 16px; min-height: var(--tap); cursor: pointer; background: var(--surface); color: var(--ink); border: 1px solid var(--border); }
button.ghost { font: inherit; font-size: 12px; font-weight: 500; color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 0 10px; min-height: 30px; cursor: pointer; }
button.ghost:hover { color: var(--bad); border-color: var(--bad); }
button.ghost.edit:hover { color: var(--blue); border-color: var(--blue); }
@media (pointer: coarse) { button.ghost { min-height: 44px; padding: 0 14px; } }
button.tog { font: inherit; background: none; border: 0; color: var(--muted); cursor: pointer; border-radius: 8px; min-width: 28px; min-height: 28px; font-size: 13px; }
button.tog:hover { background: var(--chip); }
@media (pointer: coarse) { button.tog { min-width: 44px; min-height: 44px; } }
button:disabled { opacity: .55; cursor: default; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }

/* ---------- поля ---------- */
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 500; }
input, select { font: inherit; font-size: 14px; color: var(--ink); background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 0 10px; min-height: var(--tap); min-width: 0; width: 100%; }
input:hover, select:hover { border-color: var(--border-hover); }
input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; accent-color: var(--blue); }
@media (pointer: coarse) { input, select { font-size: 16px; } }

/* ---------- фильтры ---------- */
.filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filters .search { flex: 1 1 220px; max-width: 340px; position: relative; }
.filters .search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; pointer-events: none; }
.filters .search input { border-radius: 999px; padding-left: 36px; background: var(--soft); }
.filters .pill-sel select { border-radius: 999px; padding: 0 30px 0 14px; width: auto; max-width: 220px; font-weight: 500; background-color: var(--soft);
  appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: var(--select-arrow);
  background-repeat: no-repeat; background-position: right 12px center; background-size: 11px 8px; }
.filters .pill-date { flex-direction: row; align-items: center; gap: 0; border: 1px solid var(--border); border-radius: 999px; background: var(--soft); padding-left: 14px; min-height: var(--tap); }
.filters .pill-date:hover { border-color: var(--border-hover); }
.filters .pill-date span { font-size: 13px; color: var(--muted); font-weight: 500; }
.filters .pill-date input { border: 0; background: transparent; min-height: calc(var(--tap) - 2px); width: auto; padding: 0 12px 0 6px; border-radius: 999px; }
.filtercard { padding: 12px 14px; margin-bottom: 14px; }
.tablehead { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.tablehead:empty { display: none; }

/* ---------- карточки ---------- */
.card { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); border: 1px solid var(--card-border); padding: 16px 18px; min-width: 0; }
.card h2 { font-size: 15px; margin-bottom: 2px; }
.hint { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.note { color: var(--muted); font-size: 12px; margin: 10px 2px 0; }
.note.pad { padding: 0 16px 14px; }
.msg { font-size: 13px; margin: 0 0 12px; color: var(--muted); }
.msg.pad { padding: 0 18px 14px; margin: 0; }
details.panel { padding: 0; margin-bottom: 14px; }
details.panel > summary { cursor: pointer; padding: 0 18px; min-height: 48px; display: flex; align-items: center; font-weight: 600; }
details.panel.editing { box-shadow: 0 0 0 2px var(--blue), var(--shadow); }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px 14px; padding: 4px 18px 18px; align-items: end; }
.fields .wide { grid-column: span 2; }
@media (max-width: 420px) { .fields .wide { grid-column: auto; } }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.grid2.docs { grid-template-columns: 3fr 2fr; }
@media (max-width: 960px) { .grid2, .grid2.docs { grid-template-columns: 1fr; } }

/* ---------- карточки итогов ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .kpis { grid-template-columns: 1fr; } }
.kpi { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); border: 1px solid var(--card-border); padding: 16px 18px; min-width: 0; }
#kpis { cursor: pointer; }
#kpis:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; border-radius: 16px; }
.kpis.mini { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 22px; background: var(--surface); border: 1px solid var(--card-border); border-radius: 14px; box-shadow: var(--shadow); padding: 10px 16px; }
.kpis.mini:hover { border-color: var(--border-hover); }
.kpis.mini .tog { color: var(--muted); font-size: 12px; margin-right: -12px; }
.kpis.mini .m { white-space: nowrap; font-size: 13px; }
.kpis.mini .m .k { color: var(--muted); }
.kpis.mini .m b { font-weight: 700; font-size: 15px; }
.kpis.mini .m.net b { color: var(--link); }
.kpis.mini .m.neg b { color: #dc2626; }
.kpis.mini .m.scope { color: var(--muted); font-size: 12px; margin-left: auto; }
.kpi .k { font-size: 13px; color: var(--muted); font-weight: 500; }
.kpi .v { font-size: clamp(24px, 1.8vw, 34px); font-weight: 700; letter-spacing: -.02em; line-height: 1.2; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .n { font-size: 12px; color: var(--muted); margin-top: 4px; }
.kpi.dark { background: var(--kpi-dark); border-color: var(--kpi-dark-border); color: #fff; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: end; }
.kpi.dark .k, .kpi.dark .n { color: #cbd5e1; }
.kpi.dark .v { color: var(--teal); }
.kpi.dark .v.neg { color: #fca5a5; }
.kpi.dark svg { width: clamp(110px, 9vw, 180px); height: auto; aspect-ratio: 110 / 52; grid-row: 1 / span 3; grid-column: 2; align-self: center; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 14px; }
.tile { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); border: 1px solid var(--card-border); padding: 14px 16px; }
.tile .k { font-size: 12px; color: var(--muted); font-weight: 500; }
.tile .v { font-weight: 700; font-size: 20px; line-height: 1.2; margin-top: 2px; }
.tile .n { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------- графики ---------- */
svg { width: 100%; height: auto; display: block; }
svg text { fill: var(--muted); font-family: var(--font); font-size: 11px; }
svg .grid { stroke: var(--grid); stroke-width: 1; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* ---------- таблицы ---------- */
.tablecard { padding: 0; border-radius: 18px; overflow: hidden; }
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.card:not(.tablecard) .tablewrap { border: 1px solid var(--line); border-radius: 12px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--surface); }
td.num, th.num { text-align: right; }
tbody tr:hover td { background: var(--hover); }
tbody tr:last-child td { border-bottom: 0; }
tfoot td { font-weight: 700; background: var(--soft); border-top: 1px solid var(--border-soft); border-bottom: 0; }
td.route { white-space: normal; min-width: 240px; }
#tripTable td.route { width: 34%; }   /* маршрут забирает свободную ширину, числа остаются компактными */
.pos { color: var(--good); font-weight: 600; }
.neg { color: var(--bad); font-weight: 600; }
.chip { display: inline-block; font-size: 12px; font-weight: 500; padding: 2px 10px; border-radius: 999px; background: var(--chip); color: var(--chip-ink); }
.pct { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; min-width: 52px; text-align: center; }
.pct.up { background: var(--good-bg); color: var(--good); }
.pct.down { background: var(--bad-bg); color: var(--bad); }
td.acts { white-space: nowrap; }
td.acts button + button { margin-left: 6px; }
button.ghost.ico { width: 30px; padding: 0; display: inline-flex; align-items: center; justify-content: center; vertical-align: middle; }
button.ghost.ico svg { width: 15px; height: 15px; }
@media (pointer: coarse) { button.ghost.ico { width: 40px; } }
#tripTable th, #tripTable td { padding-left: 9px; padding-right: 9px; }
tr.detail td { background: var(--soft); white-space: normal; }
tbody tr.detail:hover td { background: var(--soft); }
.dgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px 18px; font-size: 13px; padding: 2px 0; }
.dgrid div span { display: block; color: var(--muted); font-size: 12px; }
.dgrid label.chk { flex-direction: row; align-items: center; gap: 8px; font-size: 13px; color: var(--ink); }
.tablenote { font-size: 13px; margin: 10px 4px 0; color: var(--ink); }
.tablenote b { font-weight: 600; }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; }
.pill.good { color: var(--good); background: var(--good-bg); } .pill.warn { color: var(--warn); background: var(--warn-bg); } .pill.bad { color: var(--bad); background: var(--bad-bg); }
.src { font-size: 12px; color: var(--chip-ink); background: var(--chip); border-radius: 999px; padding: 2px 10px; }
.sevstripe { width: 4px; padding: 0 !important; }
.sev-good { background: #16a34a; } .sev-warn { background: #f59e0b; } .sev-bad { background: #dc2626; }
tbody tr:hover td.sev-good { background: #16a34a; } tbody tr:hover td.sev-warn { background: #f59e0b; } tbody tr:hover td.sev-bad { background: #dc2626; }
#docTable input[type="date"] { min-width: 140px; }

/* сортировка */
th:has(.sortbtn) { padding: 0; }
.sortbtn { font: inherit; font-weight: 600; color: inherit; background: none; border: 0; width: 100%; min-height: 40px; padding: 10px 12px;
  display: inline-flex; align-items: center; gap: 4px; cursor: pointer; text-align: left; white-space: nowrap; border-radius: 0; }
th.num .sortbtn { justify-content: flex-end; text-align: right; }
.sortbtn:hover { color: var(--ink); background: var(--hover); }
.sortbtn:focus-visible { outline-offset: -2px; }
.sortbtn.on { color: var(--ink); }
.sortbtn .arrow { display: inline-block; width: 1em; font-size: 10px; text-align: center; color: var(--link); }
@media (pointer: coarse) { .sortbtn { min-height: 44px; } }

/* ---------- списки, чат ---------- */
.list { margin: 0; padding: 0; list-style: none; font-size: 13px; }
.list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list small { color: var(--muted); display: block; font-size: 12px; }
.chat { background: var(--bg); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.bubble { background: var(--surface); border-radius: 14px 14px 14px 4px; padding: 8px 12px; font-size: 13px; max-width: 520px; box-shadow: var(--shadow); }
.bubble b { font-weight: 600; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }

/* ---------- импорт ---------- */
.imp { margin-bottom: 14px; }
.imp h2 { font-size: 16px; }
.imp h3 { font-size: 14px; margin: 16px 0 6px; }
.imp .sumrow { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 4px; }
.imp td { vertical-align: top; padding: 8px 10px; }
.imp .chg { white-space: normal; min-width: 240px; }
.imp .chg div { margin: 1px 0; }
.imp .chg s { color: var(--muted); }
.imp .chg b { color: var(--link); font-weight: 600; }
.imp .actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.imp details { margin-top: 12px; }
.imp details summary { cursor: pointer; color: var(--muted); min-height: 32px; display: flex; align-items: center; }
.imp .ok { color: var(--good); }

/* ---------- вход ---------- */
.loginpage main { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 14px; padding: 24px; }
.login-head { display: flex; gap: 14px; align-items: flex-start; }
.login-head h1 { font-size: 17px; line-height: 1.3; }
.err { color: var(--bad); margin: 0; font-size: 13px; font-weight: 600; }

/* ---------- телефон: панель внизу ---------- */
@media (max-width: 760px) {
  .side { top: auto; right: 0; width: auto; height: auto; flex-direction: row; border-right: 0; border-top: 1px solid var(--side-border);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px)); box-shadow: var(--side-shadow); }
  .side .plate { display: none; }
  .side nav { flex-direction: row; gap: 4px; }
  .side nav button { flex: 1 1 0; min-height: 52px; font-size: 10.5px; padding: 6px 2px; }
  .main { margin-left: 0; padding: 14px 16px calc(96px + env(safe-area-inset-bottom, 0px)); }
  .titles h1 { font-size: 18px; }
  .actions { width: 100%; }
  .actions .pill-btn { flex: 1 1 auto; }
  .userbox { margin-left: auto; }
  .filters .search { flex-basis: 100%; max-width: none; }
  .filters .pill-sel { flex: 1 1 calc(50% - 4px); }
  .filters .pill-sel select { width: 100%; max-width: none; }
  .filters .pill-date { flex: 1 1 calc(50% - 4px); }
  .filters .pill-date input { flex: 1; min-width: 0; }
  .kpi .v { font-size: 22px; }
}

/* импорт расходов из 1С: соответствие столбцов */
.mapgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px 12px; margin: 10px 0 4px; }
.mapgrid select, .mapgrid input { min-height: 40px; }
.imp .warnbox { background: var(--warn-bg); color: var(--warn); border-radius: 10px; padding: 8px 12px; font-weight: 600; margin: 8px 0; }

textarea { font: inherit; font-size: 14px; color: var(--ink); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; width: 100%; resize: vertical; min-height: var(--tap); }
@media (pointer: coarse) { textarea { font-size: 16px; } }
.tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; margin-left: 6px; vertical-align: 1px; }
.tag.ok { background: var(--good-bg); color: var(--good); } .tag.w { background: var(--warn-bg); color: var(--warn); } .tag.n { background: var(--chip); color: var(--chip-ink); }
td.alias { white-space: normal; color: var(--muted); font-size: 12px; max-width: 320px; }
@media (max-width: 760px) { .side nav button { font-size: 10px; } }

/* переключатель темы */
.themesel select { border-radius: 999px; padding: 0 30px 0 12px; width: auto; font-size: 13px; font-weight: 500; background-color: var(--soft);
  appearance: none; -webkit-appearance: none; cursor: pointer; background-image: var(--select-arrow); background-repeat: no-repeat; background-position: right 11px center; background-size: 11px 8px; }
.plate { color: #0f172a; border-color: #0f172a; }
.plate span + span { border-top-color: #0f172a; }

.msg.err { color: var(--bad); font-weight: 600; background: var(--bad-bg); border-radius: 10px; padding: 10px 14px; }

.catsel select { min-width: 190px; min-height: 36px; border-radius: 999px; padding: 0 30px 0 12px; font-size: 13px; font-weight: 500; background-color: var(--soft);
  appearance: none; -webkit-appearance: none; cursor: pointer; background-image: var(--select-arrow); background-repeat: no-repeat; background-position: right 11px center; background-size: 11px 8px; }
@media (pointer: coarse) { .catsel select { min-height: 44px; } }

/* обзор: статистика общих расходов */
.expstats { margin-bottom: 14px; }
.expstats h3 { font-size: 13px; color: var(--muted); font-weight: 600; margin: 0 0 8px; }
.expkpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-top: 6px; }
.expkpis div { background: var(--soft); border-radius: 12px; padding: 10px 12px; }
.expkpis .k { font-size: 12px; color: var(--muted); }
.expkpis .v { font-size: 20px; font-weight: 700; margin-top: 2px; }
.expkpis .n { font-size: 12px; color: var(--muted); }
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar { display: grid; grid-template-columns: minmax(110px, 30%) 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.bar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .track { height: 10px; background: var(--chip); border-radius: 999px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--accent); border-radius: 999px; min-width: 2px; }
.bar .val { text-align: right; white-space: nowrap; }
.bar .val small { color: var(--muted); margin-left: 6px; }
@media (max-width: 520px) { .bar { grid-template-columns: 1fr auto; } .bar .track { grid-column: 1 / -1; grid-row: 2; } }

.fuelbar { display: flex; gap: 8px 16px; align-items: center; flex-wrap: wrap; margin: 0 0 12px; }
.chk-inline { flex-direction: row; align-items: center; gap: 8px; font-size: 13px; color: var(--ink); cursor: pointer; min-height: 32px; }
tr.fuelrow td { color: var(--muted); }
tr.fuelrow td:nth-child(2)::after { content: " · не входит"; font-size: 11px; }

/* карточка поставщика и переходы к ней */
.linkname { font: inherit; font-weight: 600; color: var(--ink); background: none; border: 0; padding: 2px 0; cursor: pointer; text-align: left; text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 3px; }
.linkname:hover { color: var(--link); text-decoration-color: currentColor; }
button.bar { font: inherit; color: inherit; background: none; border: 0; width: 100%; text-align: left; padding: 4px 6px; margin: 0 -6px; border-radius: 8px; cursor: pointer; min-height: 32px; }
button.bar:hover { background: var(--hover); }
button.bar:hover .name { color: var(--link); text-decoration: underline; }
.supcard-head { margin-bottom: 14px; display: flex; gap: 10px 16px; align-items: center; flex-wrap: wrap; }
.supcard-head h2 { font-size: 20px; margin: 0; }
.supcard-head .grow { flex: 1 1 auto; }
@media (pointer: coarse) { button.bar { min-height: 44px; } .linkname { min-height: 44px; } }

/* первичка */
.pdoc .fields { padding: 8px 0; }
.pdoc label.radio { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; font-weight: 400; margin: 6px 0; cursor: pointer; }
.pdoc label.radio input { width: auto; min-height: 0; }
.pditems input { min-height: 34px; padding: 4px 8px; }
.pditems td { padding: 4px 6px; }
.pditems td:first-child { min-width: 240px; }
.pditems td.num input { width: 110px; text-align: right; }
.pdtext { white-space: pre-wrap; font-size: 12px; max-height: 320px; overflow: auto; background: var(--chip); color: var(--ink); padding: 10px; border-radius: 10px; }

/* расходы по поставщикам */
#expTable tr.grp, #supTable tr.grp { cursor: pointer; }
#expTable tr.grp.open td, #supTable tr.grp.open td { background: var(--soft); border-bottom-color: transparent; }
#expTable tr.sub td, #supTable tr.sub td { font-size: 13px; padding-top: 6px; padding-bottom: 6px; }
#expTable tr.sub td:nth-child(2), #supTable tr.sub td:nth-child(2) { padding-left: 22px; color: var(--muted); }
#expTable tr.sub td:nth-child(2)::before, #supTable tr.sub td:nth-child(2)::before { content: "↳ "; }
#expTable tr.sub.fuelrow td:nth-child(2)::after, #expTable tr.grp.fuelrow td:nth-child(2)::after { content: none; }
#expTable tr.sub.fuelrow td:nth-child(3)::after, #expTable tr.grp.fuelrow td:nth-child(3)::after { content: " · не входит"; font-size: 11px; }
.dgrid .warntxt { color: var(--warn); font-weight: 600; }

/* рейсы с подозрительными датами — оранжевая подсветка */
#tripTable tbody tr.dateissue td { background: var(--warn-bg); }
#tripTable tbody tr.dateissue td:first-child { box-shadow: inset 4px 0 0 var(--accent); }
#tripTable tbody tr.dateissue:hover td { background: var(--warn-bg); filter: brightness(0.97); }
.warntxt { color: var(--warn); font-weight: 600; }

/* путевые листы */
.wbcalc { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px 14px; background: var(--soft); border-radius: 12px; padding: 12px 14px; }
.wbcalc:empty { display: none; }
.wbcalc div span { display: block; font-size: 12px; color: var(--muted); }
.wbcalc div b { font-size: 16px; }
.wbcalc .cash b { color: var(--good); font-size: 18px; }
.wbcalc .wide2 { grid-column: 1 / -1; font-size: 13px; color: var(--muted); }
#wbTable td.cash { font-weight: 700; color: var(--good); }
.wbfiles { font-size: 13px; color: var(--muted); }
.wbfiles:empty { display: none; }
.ttnbox { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; align-self: end; }
.ttnbox .dropzone { min-height: 42px; }
td small.csub a { color: var(--link); text-decoration: none; }
.wbfiles .wbf { display: inline-flex; gap: 4px; align-items: center; margin-right: 10px; }
.wbflinks a { text-decoration: none; margin-left: 4px; font-size: 13px; }

/* рейсы путевого листа: цвет листа (4 чередующихся) */
:root { --wb0: #2563eb; --wb1: #9333ea; --wb2: #0d9488; --wb3: #db2777; }
#tripTable tbody tr.inwb.wbc0 td:nth-child(2) { box-shadow: inset 4px 0 0 var(--wb0); }
#tripTable tbody tr.inwb.wbc1 td:nth-child(2) { box-shadow: inset 4px 0 0 var(--wb1); }
#tripTable tbody tr.inwb.wbc2 td:nth-child(2) { box-shadow: inset 4px 0 0 var(--wb2); }
#tripTable tbody tr.inwb.wbc3 td:nth-child(2) { box-shadow: inset 4px 0 0 var(--wb3); }
.wbtag { font: inherit; font-size: 11px; font-weight: 600; border: 0; border-radius: 999px; padding: 2px 8px; margin-top: 3px; cursor: pointer; color: #fff; white-space: nowrap; }
.wbtag.wbc0 { background: var(--wb0); } .wbtag.wbc1 { background: var(--wb1); } .wbtag.wbc2 { background: var(--wb2); } .wbtag.wbc3 { background: var(--wb3); }
.wbtag:hover { filter: brightness(1.1); }
#wbTable tr.wbrow td:first-child { box-shadow: inset 4px 0 0 transparent; }
#wbTable tr.wbrow.wbc0 td:first-child { box-shadow: inset 4px 0 0 var(--wb0); } #wbTable tr.wbrow.wbc1 td:first-child { box-shadow: inset 4px 0 0 var(--wb1); }
#wbTable tr.wbrow.wbc2 td:first-child { box-shadow: inset 4px 0 0 var(--wb2); } #wbTable tr.wbrow.wbc3 td:first-child { box-shadow: inset 4px 0 0 var(--wb3); }
.wbfocus { display: flex; justify-content: space-between; align-items: center; gap: 10px 16px; flex-wrap: wrap; padding: 12px 18px; margin-bottom: 14px; border-left: 5px solid var(--wb0); }
.wbfocus.wbc1 { border-left-color: var(--wb1); } .wbfocus.wbc2 { border-left-color: var(--wb2); } .wbfocus.wbc3 { border-left-color: var(--wb3); }
@keyframes flashrow { from { background: var(--warn-bg); } to { background: transparent; } }
#wbTable tr.flashrow td { animation: flashrow 2.2s ease-out; }
.wbsum { margin: 0 0 14px; }
.wbsum .kmoff .v, #wbTable td.kmoff { color: var(--warn); }
.wbsum .cashk .v { color: var(--good); }
/* путевые листы: компактная таблица, умещается в ширину */
#wbTable td { vertical-align: top; padding-top: 10px; padding-bottom: 10px; }
td small.csub { display: block; font-size: 11.5px; color: var(--muted); font-weight: 400; margin-top: 2px; white-space: nowrap; }
#wbTable td .sub, #wbTable .sub { font-size: 12px; color: var(--muted); font-weight: 400; }
#wbTable td.kmoff .sub { color: var(--warn); opacity: .85; }
#wbTable td.wbacts { white-space: nowrap; }
#wbTable td.wbacts button { display: block; width: 100%; margin: 0 0 4px; }
@media (min-width: 1500px) { #wbTable td.wbacts button { display: inline-block; width: auto; margin: 0 0 0 4px; } }
/* итоги путевых листов: 12 карточек — ровными рядами (6 / 4 / 3 / 2 в ряд по ширине экрана) */
.wbsum { grid-template-columns: repeat(var(--n, 6), minmax(0, 1fr)); }
@media (max-width: 1400px) { .wbsum { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 900px) { .wbsum { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 600px) { .wbsum { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* заправки (Нафта-карти) */
#fuelTable select.fuellink { max-width: 260px; font-size: 12px; padding: 4px 6px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
#fuelTable tr.fuelown td { opacity: .75; }
#fuelTable td.route { max-width: 280px; white-space: normal; }
.fuelcards input, .fuelcards select { width: 100%; min-width: 120px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; }
.cardprice { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; font-weight: 400; }
.cardprice .linkbtn { font-size: 12px; padding: 0; }
/* итоги заправок: одним рядом (7–8 карточек), на узких экранах — 4 / 2 в ряд */
#fuelSum { grid-template-columns: repeat(var(--n, 8), minmax(0, 1fr)); gap: 8px; }
#fuelSum > div { padding: 10px; min-width: 0; }
#fuelSum .v { font-size: 18px; white-space: nowrap; }
#fuelSum .n { overflow-wrap: anywhere; }
@media (max-width: 1300px) { #fuelSum { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 600px) { #fuelSum { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.wbcalc .warn b { color: var(--warn); }
/* форма путевого листа: 12 коротких полей — одной строкой на широком экране; расчёт — во всю ширину под полями */
#wbForm .wbcalc, #wbForm .wbfiles { grid-column: 1 / -1; }
@media (min-width: 1500px) {
  #wbForm { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  #wbForm .wide { grid-column: span 4; }
  #wbForm > label { min-width: 0; }
  #wbForm input { min-width: 0; width: 100%; }
}

.weekcard { margin-bottom: 14px; }
#chartWeek { overflow-x: auto; }
#chartWeek svg { display: block; width: 100%; min-width: 560px; height: auto; }

/* область перетаскивания файлов — размером с кнопку, рядом с кнопками */
.dropzone { display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: transparent; color: var(--muted);
  border: 1.5px dashed var(--border-hover); transition: border-color .15s, background .15s, color .15s; }
.dropzone svg { width: 16px; height: 16px; flex: none; }
.dropzone:hover { color: var(--ink); border-color: var(--ink); }
.dropzone.over { border-style: solid; border-color: var(--blue); background: var(--nav-on-bg); color: var(--nav-on-ink); }

/* пункты выпадающих списков: в тёмной теме не белый текст на белом */
select option, select optgroup { background-color: var(--surface); color: var(--ink); }

/* справочник поставщиков: «Добавить поставщика» и поиск в одном ряду */
.suprow { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 14px; flex-wrap: wrap; }
.suprow > details.panel { flex: 1 1 320px; margin-bottom: 0; min-width: 0; }
.supsearch { flex: 0 1 420px; margin-left: auto; display: flex; align-items: center; gap: 8px; padding: 0 14px; min-height: 48px; color: var(--muted); min-width: 0; }
.supsearch input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 0; min-height: 46px; outline: none; }
.supsearch:focus-within { box-shadow: 0 0 0 2px var(--blue), var(--shadow); }
.supsearch svg { width: 16px; height: 16px; flex: none; display: block; }
.supqn { font-size: 12px; white-space: nowrap; }
@media (max-width: 700px) { .supsearch { flex-basis: 100%; } }
#supTable tr.sub td { background: var(--soft); }

/* под названием компании — название открытого раздела: крупнее подписи, мельче заголовка */
.titles .tabtitle { font-size: clamp(15px, 1.05vw, 19px); font-weight: 600; line-height: 1.3; margin-top: 2px; }
@media (max-width: 700px) { .titles .tabtitle { font-size: 14px; } }

/* число путевых листов — справа в строке фильтров */
.fstat { margin-left: auto; display: flex; align-items: baseline; gap: 10px; padding: 4px 14px; border-radius: 12px; background: var(--soft); min-height: var(--tap); flex-wrap: wrap; align-content: center; }
.fstat:empty { display: none; }
.fstat .k { font-size: 12px; color: var(--muted); }
.fstat .v { font-size: 20px; font-weight: 700; line-height: 1.1; }
.fstat .n { font-size: 12px; color: var(--muted); }
@media (max-width: 600px) { .fstat { margin-left: 0; width: 100%; } }
#wbTable .wbflinks { display: block; margin-top: 4px; font-size: 12px; white-space: nowrap; }
#wbTable .wbflinks a { text-decoration: none; margin: 0 8px 0 0; font-size: 12px; }
.gpswarn { color: var(--warn); font-weight: 600; }
/* карта */
.mapcard { padding: 14px; }
.mapbar { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; margin-bottom: 12px; }
.mapbar .seg { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.mapbar input.mapdt { width: auto; min-height: 38px; margin: 0; }
.mapbar label.mapfollow { margin: 0 0 0 auto; font-size: 13px; display: inline-flex; flex-direction: row; align-items: center; gap: 8px; white-space: nowrap; }
.mapbar label.mapfollow input { margin: 0; }
.mapwrap { border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
#map { height: min(72vh, 760px); min-height: 360px; background: var(--soft); }
#map svg { width: auto; height: auto; display: inline; }
.leaflet-container svg { max-width: none; }
.mapinfo { font-size: 13px; color: var(--muted); margin-top: 10px; line-height: 1.6; }
.mapinfo b { color: var(--ink); }
.maplegend { font-size: 12px; color: var(--muted); margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.maplegend i { display: inline-block; width: 18px; height: 6px; border-radius: 3px; background: var(--c); margin-right: 2px; vertical-align: middle; }
.truckmk { background: none; border: 0; }
.truckmk .tm { width: 34px; height: 34px; border-radius: 50%; background: #fff; color: #64748b; display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 6px rgba(0,0,0,.45); border: 2px solid #64748b; }
.truckmk .tm.mv { color: #059669; border-color: #059669; }
.truckmk svg { width: 22px !important; height: 22px !important; display: block; }
.destmk div { width: 22px; height: 22px; border-radius: 50%; background: #f59e0b; border: 3px solid #fff; box-shadow: 0 1px 6px rgba(0,0,0,.5); cursor: move; }
.destmk { background: none; border: 0; }
.leaflet-tooltip.desttip { font-weight: 600; font-size: 12px; }
.mapinfo .hint { font-size: 12px; }
.mapbar .mapcoord { display: inline-flex; gap: 6px; align-items: center; margin: 0; flex: 1 1 300px; max-width: 460px; }
.mapbar .mapcoord input { min-height: 38px; margin: 0; flex: 1; min-width: 0; }
/* точки маршрута в форме рейса */
.routepts { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 14px; align-items: start; }
.rpt { position: relative; min-width: 0; }
.rpt label { display: flex; flex-direction: column; }
.rpsug { position: absolute; left: 0; right: 0; top: 100%; z-index: 30; margin-top: 2px; max-height: 280px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.35); padding: 4px; }
.rpsug [role="option"] { padding: 8px 10px; border-radius: 7px; cursor: pointer; font-size: 13px; line-height: 1.3; }
.rpsug [role="option"] b { display: block; font-weight: 600; }
.rpsug [role="option"] span { color: var(--muted); font-size: 12px; }
.rpsug [role="option"][aria-selected="true"], .rpsug [role="option"]:hover { background: var(--hover); }
.rpsug .rpnone { padding: 8px 10px; color: var(--muted); font-size: 12px; }
.rpinfo { display: block; min-height: 16px; margin-top: 4px; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.rpinfo a { color: var(--link); }
.rpinfo.warn { color: var(--warn); }
.rpmk { background: none; border: 0; }
.rpmk b { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: #f59e0b; color: #111; font: 700 13px/1 var(--font); border: 3px solid #fff; box-shadow: 0 1px 6px rgba(0,0,0,.5); box-sizing: border-box; }
/* банк */
.bankbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.bankq input { min-width: 0; width: min(280px, 60vw); }
#bankTable tr.grp { cursor: pointer; }
#bankTable tr.grp.open td { background: var(--soft); border-bottom-color: transparent; }
#bankTable td.bankin { color: var(--good); font-weight: 600; }
#bankTable td.bankout { font-weight: 600; }
#bankTable td.bankpurp { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.bankdetail .pill-btn { margin: 2px 4px 2px 0; }
.bankdetail input[type="text"] { min-width: 0; width: min(260px, 70vw); }
.chip.bank-review { background: var(--warn-bg); color: var(--warn); }
.chip.bank-ignored { opacity: .7; }
td small.csub.paidok { color: var(--good); }
.bankupcard { padding: 14px 18px; display: grid; gap: 10px; }
.bankupcard .dropzone { min-height: 48px; width: 100%; }
.bankprev p { margin: 0 0 6px; }
.bankprevt td.bankin { color: var(--good); font-weight: 600; }
.bankprevt tr.dupe td { opacity: .55; }
.bankprevt td.bankpurp { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.bankprevbtns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.hint.err { color: var(--bad); }

#expTable td.code { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--muted); }
.chip.unpaid { background: var(--warn-bg); color: var(--warn); white-space: nowrap; }
#expTable .payok { color: var(--good); white-space: nowrap; }
#expTable .paynone { color: var(--muted); white-space: nowrap; font-size: .92em; }
#bankTable td.code, .bankprevt td.code { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--muted); }
/* компактные строки во всех таблицах (01.12.2026, по просьбе владельца) */
th, td { padding-top: 5px; padding-bottom: 5px; line-height: 1.3; }
.sortbtn { min-height: 30px; padding-top: 5px; padding-bottom: 5px; }
tr.sub td, #expTable tr.sub td, #supTable tr.sub td { padding-top: 4px; padding-bottom: 4px; }
#wbTable td, .imp td { padding-top: 5px; padding-bottom: 5px; }
td button.tog, th button.tog { min-height: 22px; min-width: 24px; }
td .linkname { padding: 0; }
td .linkbtn { min-height: 22px; }
td button.ghost { min-height: 24px; }
td .src, td .chip, td .pct { padding-top: 1px; padding-bottom: 1px; }
td .pill-btn { min-height: 30px; }
@media (pointer: coarse) { td button.tog, th button.tog { min-height: 36px; min-width: 36px; } td button.ghost, td .linkbtn { min-height: 34px; } }

/* назначение платежа вместо пустого описания расхода (01.12.2026): не выше двух строк, полностью — в подсказке */
.pdesc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* разница сумм оплаты и документа (01.12.2026) */
.chip.diff { background: var(--warn-bg); color: var(--warn); font-weight: 700; white-space: nowrap; }

/* порядок строк «Документов» (01.12.2026) */
#docTable td.docmove { white-space: nowrap; width: 1%; padding-left: 4px; padding-right: 4px; }
#docTable .dhandle { cursor: grab; color: var(--muted); font-size: 16px; padding: 0 6px; user-select: none; vertical-align: middle; }
#docTable td.docmove button.ico { width: 26px; min-width: 26px; padding: 0; }
#docTable td.docmove button:disabled { opacity: .3; cursor: default; }
#docTable tr.dragging { opacity: .5; background: var(--hover); }
#docTable tr.filedrop td { background: var(--nav-on-bg); }
.docdropcard { margin-bottom: 14px; }
.docdropcard .dropzone { width: 100%; min-height: 64px; border-radius: 14px; white-space: normal; }
#docTable .docfiles { display: block; margin-top: 2px; }
#docTable .docfiles a { margin-right: 2px; }
#docTable .docfdel { padding: 0 4px; min-height: 0; color: var(--muted); }
#docTable input.docedit { width: 100%; min-width: 120px; }
#docTable td.acts { white-space: nowrap; }
@media (pointer: coarse) { #docTable .dhandle { display: none; } #docTable td.docmove button.ico { width: 40px; min-width: 40px; } }

/* окно ручной связи банк ↔ расход (01.12.2026) */
.linkdlg { width: min(760px, calc(100vw - 24px)); max-height: min(86vh, 900px); padding: 0; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(15, 23, 42, .3); }
.linkdlg[open] { display: flex; flex-direction: column; }
.linkdlg::backdrop { background: rgba(15, 23, 42, .45); }
.linkdlg-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px 0; }
.linkdlg-head h3 { margin: 0; font-size: 16px; }
.linkdlg > .hint { margin: 4px 16px 8px; overflow-wrap: anywhere; }
.linkq { margin: 0 16px 8px; }
.linkq input { width: 100%; min-height: 40px; font-size: 15px; }
.linkres { overflow-y: auto; padding: 0 8px 10px; flex: 1; min-height: 0; }
.linkrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px; border-top: 1px solid var(--line); }
.linkrow.cur { background: var(--good-bg); border-radius: 10px; }
.linkinfo { min-width: 0; font-size: 13px; line-height: 1.35; overflow-wrap: anywhere; }
.linkinfo small { color: var(--muted); }
.linkrow .pill-btn { flex: none; min-height: 36px; }
button.chip.linkchip { border: 0; cursor: pointer; font: inherit; font-size: 12px; font-weight: 600; }
button.chip.linkchip:hover { filter: brightness(.95); text-decoration: underline; }
@media (pointer: coarse) { .linkrow .pill-btn { min-height: 44px; } .linkq input { font-size: 16px; min-height: 44px; } }

/* ================= ТЕЛЕФОН до 600 px: макет «Телефон B: плотный список» (01.12.2026). Компьютер не меняется ================= */
.mob { display: none; }
@media (max-width: 600px) {
  html, body { overflow-x: hidden; }
  .mob[hidden], .mob.offtab { display: none !important; }
  /* боковое меню и большая шапка заменены своими */
  .side, .top .brand, #kpis, .top .themesel, .top .userbox,
  #importBtn, #exportBtn, #addTripBtn, #gpsSyncBtn, #tab-trips > .tablecard, #tripNote, #tab-trips > .note,
  #tab-overview > .filtercard { display: none !important; }
  .main { margin-left: 0; padding: 0 12px calc(84px + env(safe-area-inset-bottom, 0px)); max-width: 100vw; overflow-x: clip; }
  .main > section, .card, .grid2 > *, .tablewrap { min-width: 0; max-width: 100%; }
  .top { margin: 0; gap: 8px; }
  .top .actions { width: 100%; gap: 8px; }
  .top .actions:not(:has(> :not(.offtab):not(#importBtn):not(#exportBtn):not(#addTripBtn):not(#gpsSyncBtn):not(.themesel):not(.userbox))) { display: none; }
  .top .actions .pill-btn { flex: 1 1 calc(50% - 4px); min-width: 0; min-height: 44px; white-space: normal; line-height: 1.2; padding: 6px 12px; font-size: 13px; }
  .top { padding-top: 8px; }
  .status { margin: 4px 0 8px; font-size: 12.5px; }
  .status:empty { display: none; }

  /* шапка */
  .mhead { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 30; background: var(--bg);
    margin: 0 -12px; padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 8px; border-bottom: 1px solid var(--side-border); }
  .mtruck { height: 26px; }   /* силуэт бензовоза, как в шапке на компьютере */
  .mtitles { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.2; }
  .mtitles b { font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mtitles small { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mmore { width: 44px; height: 44px; flex: none; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--ink);
    font: 700 20px/1 var(--font); cursor: pointer; }
  .mmenu { position: absolute; right: 12px; top: calc(100% + 4px); min-width: 220px; max-width: calc(100vw - 24px); background: var(--surface);
    border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 10px 30px rgba(15, 23, 42, .18); padding: 6px; display: flex; flex-direction: column; }
  .mmenu button, .mmenu .mtheme { min-height: 44px; display: flex; align-items: center; gap: 10px; text-align: left; font: 500 15px var(--font);
    color: var(--ink); background: none; border: 0; border-radius: 10px; padding: 0 12px; cursor: pointer; }
  .mmenu button:hover, .mmenu button:focus-visible { background: var(--hover); }
  .mmenu .mtheme { justify-content: space-between; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); border-radius: 0; margin: 4px 0; }
  .mmenu .mtheme select { min-height: 36px; font-size: 15px; width: auto; }
  .mmenu .mlogout { color: var(--bad); }

  /* мини-плашки итогов */
  .mkpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin: 8px 0; }
  .mk { background: var(--surface); border: 1px solid var(--card-border); border-radius: 12px; padding: 7px 9px; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
  .mk .k { font-size: 11px; color: var(--muted); font-weight: 600; }
  .mk b { font-size: 14px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mk small { font-size: 10.5px; color: var(--muted); }
  .mk.dark { background: #0f172a; border-color: #0f172a; }
  .mk.dark .k, .mk.dark small { color: #94a3b8; }
  .mk.dark b { color: #5eead4; }
  .mk.dark.neg b { color: #fca5a5; }

  /* поиск + фильтры */
  .mbar { display: flex; gap: 8px; margin: 0 0 8px; }
  .msearch { flex-direction: row !important; margin: 0; flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 0 10px; }
  .msearch svg { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
  .msearch input { flex: 1; min-width: 0; border: 0; background: none; min-height: 44px; font-size: 16px; padding: 0; outline: none; color: var(--ink); }
  .msearch:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 20%, transparent); }
  .mfiltbtn { min-height: 44px; flex: none; display: inline-flex; align-items: center; gap: 6px; border-radius: 12px; border: 1px solid var(--border);
    background: var(--surface); color: var(--ink); font: 600 14px var(--font); padding: 0 14px; cursor: pointer; }
  .mfn { min-width: 20px; height: 20px; border-radius: 10px; background: var(--blue); color: #fff; font-size: 12px; display: inline-flex; align-items: center; justify-content: center; padding: 0 5px; }

  /* рейсы плотным списком */
  .mtrips { display: block; background: var(--surface); border: 1px solid var(--card-border); border-radius: 14px; overflow: hidden; }
  .mt + .mt { border-top: 1px solid var(--line); }
  .mt.dateissue { box-shadow: inset 3px 0 0 var(--accent); }
  .mtrow { width: 100%; display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; gap: 8px; align-items: center; text-align: left;
    background: none; border: 0; padding: 7px 10px; min-height: 52px; font: inherit; color: var(--ink); cursor: pointer; }
  .mt.open .mtrow { background: var(--hover); }
  .mtd { display: flex; flex-direction: column; line-height: 1.15; }
  .mtd b { font-size: 13px; font-weight: 700; }
  .mtd small { font-size: 10.5px; color: var(--muted); }
  .mtc { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
  .mtr { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mtr .pill { font-size: 10px; padding: 0 5px; }
  .mts { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mtp { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; white-space: nowrap; }
  .mtp b { font-size: 14px; font-weight: 800; }
  .mtp small { font-size: 11.5px; font-weight: 600; }
  .mtp.pos, .mtot .pos { color: var(--good); }
  .mtp.neg, .mtot .neg { color: var(--bad); }
  .mtcard { padding: 4px 10px 12px 60px; background: var(--hover); }
  .mtcard dl { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
  .mtcard dl > div { min-width: 0; }
  .mtcard dt { font-size: 11px; color: var(--muted); }
  .mtcard dd { margin: 0; font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
  .mtbtns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 10px; }
  .mtbtns .pill-btn { min-height: 44px; padding: 0 6px; font-size: 13px; }
  .mtbtns .pill-btn:disabled { opacity: .45; cursor: default; }
  .mtot { margin: 0; padding: 9px 10px; font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--line); }
  .mempty { margin: 0; padding: 16px; color: var(--muted); }
  #tripBox, #wbFocusBar, #importPanel { margin-bottom: 10px; }
  #tripBox:not([open]) { display: none; }   /* добавление — плавающей кнопкой «+ Новый рейс» */

  /* плавающая кнопка и нижнее меню */
  .mfab { display: inline-flex; align-items: center; position: fixed; right: 14px; bottom: calc(72px + env(safe-area-inset-bottom, 0px)); z-index: 40;
    min-height: 48px; padding: 0 18px; border-radius: 999px; border: 0; background: var(--blue); color: #fff; font: 700 15px var(--font);
    box-shadow: 0 6px 18px rgba(15, 23, 42, .28); cursor: pointer; }
  .mnav { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    background: var(--surface); border-top: 1px solid var(--side-border); box-shadow: var(--side-shadow); padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px)); }
  .mnav button, .mmoregrid button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 52px; min-width: 0;
    background: none; border: 0; border-radius: 12px; color: var(--muted); font: 600 10.5px/1.15 var(--font); cursor: pointer; padding: 4px 2px; }
  .mnav button span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mnav svg, .mmoregrid svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
  .mnav [aria-current="page"], .mmoregrid [aria-current="page"] { background: var(--nav-on-bg); color: var(--nav-on-ink); }

  /* шторки снизу */
  .msheet-bg { display: block; position: fixed; inset: 0; z-index: 50; background: rgba(15, 23, 42, .45); }
  .msheet { display: flex; flex-direction: column; position: fixed; left: 0; right: 0; bottom: 0; z-index: 51; max-height: 85vh; background: var(--surface);
    border-radius: 18px 18px 0 0; padding: 6px 14px calc(12px + env(safe-area-inset-bottom, 0px)); box-shadow: 0 -8px 30px rgba(15, 23, 42, .25); }
  .mgrab { width: 40px; height: 4px; border-radius: 2px; background: var(--border); margin: 4px auto 8px; flex: none; }
  .msheet h3 { margin: 0 0 6px; font-size: 16px; }
  .msheet-body { overflow-y: auto; overscroll-behavior: contain; flex: 1; min-height: 0; }
  .msheet-body h4 { margin: 12px 0 6px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
  .mchips { display: flex; flex-wrap: wrap; gap: 6px; }
  .mchip { min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--ink);
    font: 500 14px var(--font); cursor: pointer; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mchip[aria-pressed="true"] { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }
  .mdates { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .mdates label { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted); min-width: 0; }
  .mdates input { min-height: 44px; font-size: 16px; width: 100%; min-width: 0; }
  .msheet-btns { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); margin-top: 10px; }
  .msheet-btns .pill-btn { min-height: 48px; }
  .mmoregrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; padding-bottom: 6px; }
  .mmoregrid button { min-height: 72px; font-size: 12px; background: var(--soft); border: 1px solid var(--line); }
  body.msheet-open { overflow: hidden; }

  /* остальные вкладки: всё по ширине экрана, широкие таблицы прокручиваются внутри себя */
  .tablewrap { overflow-x: auto; position: relative; }   /* скрытые подписи .sr внутри широких таблиц не растягивают страницу */
  .tablewrap td { max-width: 58vw; overflow: hidden; text-overflow: ellipsis; }   /* длинные названия не уводят суммы далеко вправо */
  .pill-btn.dropzone { max-width: 100%; white-space: normal; line-height: 1.25; text-align: left; }
  .tablehead { flex-wrap: wrap; gap: 8px; }
  .bankbar, .bankbar > * { min-width: 0; max-width: 100%; }
  .bankbar { flex-wrap: wrap; width: 100%; }
  .bankq, .bankq input { width: 100%; }
  .filters { gap: 6px; }
  .filters .pill-sel, .filters .pill-date { flex: 1 1 calc(50% - 3px); min-width: 0; }
  .filters .pill-sel select, .filters .pill-date input { min-width: 0; width: 100%; max-width: none; }
  .fields { grid-template-columns: minmax(0, 1fr) !important; }
  .fields .wide { grid-column: auto; }
  .mapbar { gap: 6px; }
  .mapbar > *, .mapcoord, .mapcoord input { min-width: 0; max-width: 100%; }
  .mapcoord { flex: 1 1 100%; display: flex; gap: 6px; }
  .mapcoord input { flex: 1; }
  .mapdt { flex: 1 1 calc(50% - 3px); }
  .seg { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); width: 100%; }
  .seg .pill-btn { padding: 0 4px; }
  .grid2 { gap: 10px; }
  .card h2 { font-size: 15px; }
  td.alias { max-width: 200px; }
  .chat { max-width: 100%; }
  .supsearch { flex-basis: 100%; }
  /* плашки итогов на других вкладках — по две в ряд, компактно */
  .tiles, .expkpis, .wbsum, #fuelSum { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 6px; margin-bottom: 10px; }
  .tile, .expkpis > div { padding: 7px 10px; border-radius: 12px; min-width: 0; }
  .tile .v, .expkpis .v { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .tile .k, .tile .n, .expkpis .k, .expkpis .n { font-size: 11px; line-height: 1.25; }
  section > .hint { font-size: 12.5px; margin: 0 0 8px; }
  #fuelSum > div, #bankSum > div, #wbSum > div, #supCardKpis > div { padding: 7px 10px; }
  #fuelSum .v, #bankSum .v, #wbSum .v, #supCardKpis .v { font-size: 15px; margin: 1px 0; }
  .expkpis > div > * { margin-top: 0; margin-bottom: 0; }
  /* карта: слои Leaflet не перекрывают нижнее меню и шторки */
  .mapwrap { isolation: isolate; }
  .mhead { z-index: 1000; } .mfab { z-index: 1040; } .mnav { z-index: 1050; } .msheet-bg { z-index: 1100; } .msheet { z-index: 1110; }
  .mapwrap #map { height: 55vh; }
}
