/* ==========================================================================
   РейсCRM — минималистичная светлая тема
   ========================================================================== */
:root {
  color-scheme: light;
  --bg: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #fbfbf9;
  --surface-3: #f2f1ed;
  --border: #e8e7e1;
  --border-strong: #d9d8d0;
  --text: #141413;
  --text-2: #52514e;
  --muted: #898781;
  --accent: #2a78d6;
  --accent-hover: #256abf;
  --accent-press: #1c5cab;
  --accent-soft: #eaf2fc;
  --accent-ring: rgba(42, 120, 214, .2);
  --good: #0ca30c;
  --good-text: #0b6b12;
  --good-soft: #e9f6ea;
  --warn: #fab219;
  --warn-text: #7a5200;
  --warn-soft: #fff5db;
  --bad: #d03b3b;
  --bad-text: #b02a2a;
  --bad-soft: #fcecec;
  --ref: #2a78d6;
  --ref-soft: #eaf2fc;
  --ref-text: #1c5cab;
  --grain: #eb6834;
  --grain-soft: #fdeee6;
  --grain-text: #a8431a;
  --spark: #c3c2b7;
  --grid: #efeee9;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(20, 20, 16, .04);
  --shadow: 0 1px 2px rgba(20, 20, 16, .04), 0 6px 20px rgba(20, 20, 16, .04);
  --shadow-lg: 0 18px 50px rgba(20, 20, 16, .14), 0 3px 8px rgba(20, 20, 16, .06);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --sidebar: 252px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 90px; }
body {
  margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--text);
  background: var(--bg); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.012em; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.i { display: inline-block; vertical-align: -3px; flex-shrink: 0; }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.nowrap { white-space: nowrap; }
.tnum { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.link { color: var(--accent); font-weight: 500; }
.link:hover { color: var(--accent-press); text-decoration: underline; text-underline-offset: 3px; }
::selection { background: var(--accent-soft); }

/* ---------- layout ---------- */
.app { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar); z-index: 50; display: flex; flex-direction: column;
  padding: 18px 14px 14px; background: var(--surface); border-right: 1px solid var(--border);
}
.main { margin-left: var(--sidebar); min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 14px; min-height: 72px;
  padding: 14px 36px; background: rgba(246, 246, 243, .86); backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px); border-bottom: 1px solid transparent; transition: border-color .2s;
}
.topbar.scrolled { border-bottom-color: var(--border); }
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 { font-size: 22px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-title .sub { color: var(--muted); font-size: 13px; margin-top: 1px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.content { width: 100%; max-width: 1380px; padding: 6px 36px 56px; }
.topbar .menu-btn { display: none; }

/* ---------- brand & nav ---------- */
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 8px 20px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(145deg, #3a8ae6, #1f63b8); box-shadow: 0 6px 16px rgba(42, 120, 214, .3);
}
.brand-text b { display: block; font-size: 16px; letter-spacing: -.02em; }
.brand-text small { display: block; max-width: 168px; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav { flex: 1; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-label { padding: 18px 12px 6px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.nav-item {
  display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 12px; border-radius: 10px;
  color: var(--text-2); font-weight: 500; transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-press); }
.nav-item .count {
  margin-left: auto; min-width: 22px; height: 20px; padding: 0 7px; border-radius: 10px; display: grid; place-items: center;
  font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--text-2);
}
.nav-item .count.warn { background: var(--warn-soft); color: var(--warn-text); }
.nav-item.active .count { background: #fff; }
.sidebar-foot { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.user-card { display: flex; align-items: center; gap: 10px; padding: 4px; }
.user-card .who { flex: 1; min-width: 0; }
.user-card .who b { display: block; font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card .who small { color: var(--muted); font-size: 12px; }
.sidebar-backdrop { display: none; }

/* ---------- avatar ---------- */
.avatar {
  --c: var(--accent); width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center; flex-shrink: 0;
  background: var(--c); color: #fff; font-size: 12.5px; font-weight: 600; letter-spacing: .02em;
}
.avatar.sm { width: 26px; height: 26px; font-size: 10.5px; }
.avatar.lg { width: 44px; height: 44px; font-size: 15px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px;
  border: 1px solid transparent; border-radius: var(--radius-sm); font-size: 14px; font-weight: 550; line-height: 1;
  cursor: pointer; white-space: nowrap; user-select: none; transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .btn-icon:focus-visible, .seg a:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(31, 99, 184, .3), inset 0 1px 0 rgba(255, 255, 255, .12); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-success { background: #13893a; color: #fff; box-shadow: 0 1px 2px rgba(19, 137, 58, .3); }
.btn-success:hover { background: #0f7a33; }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { background: var(--surface-2); border-color: #c9c8bf; }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-danger-ghost { background: transparent; color: var(--bad-text); }
.btn-danger-ghost:hover { background: var(--bad-soft); }
.btn[disabled], .btn.disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 9px; gap: 6px; }
.btn-lg { height: 46px; padding: 0 20px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-icon {
  width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 10px; border: 0; background: transparent;
  color: var(--text-2); cursor: pointer; position: relative; transition: background .15s, color .15s;
}
.btn-icon:hover { background: var(--surface-3); color: var(--text); }
.btn-icon.sm { width: 30px; height: 30px; border-radius: 8px; }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 500; font-size: 13px; cursor: pointer; }
.link-btn:hover { color: var(--accent-press); }
.btn .spinner, .spinner {
  width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- cards & grids ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.card-head h2, .card-head h3 { font-size: 15.5px; flex: 1; min-width: 0; display: flex; align-items: center; gap: 9px; }
.card-head h2 .i, .card-head h3 .i { color: var(--muted); }
.card-head .hint { color: var(--muted); font-size: 13px; font-weight: 400; }
.card-sub { color: var(--muted); font-size: 13px; margin-top: -10px; margin-bottom: 16px; }
.stack { display: flex; flex-direction: column; gap: 20px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-12 { grid-template-columns: repeat(12, minmax(0, 1fr)); }
.span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; } .span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; } .span-12 { grid-column: span 12; }
.mt-0 { margin-top: 0; } .mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-20 { margin-top: 20px; } .mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; } .mb-20 { margin-bottom: 20px; }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--surface-3); color: var(--text-2);
}
.badge .i { width: 13px; height: 13px; vertical-align: 0; }
.badge-draft { background: var(--warn-soft); color: var(--warn-text); }
.badge-added { background: var(--good-soft); color: var(--good-text); }
.badge-ref { background: var(--ref-soft); color: var(--ref-text); }
.badge-grain { background: var(--grain-soft); color: var(--grain-text); }
.badge-outline { background: transparent; border: 1px solid var(--border-strong); color: var(--text-2); }
.badge-lg { height: 28px; padding: 0 11px; font-size: 13px; }

/* ---------- alerts / flash ---------- */
.flashes { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.alert {
  display: flex; align-items: flex-start; gap: 12px; padding: 13px 14px 13px 16px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-sm); font-size: 14px;
}
.alert > .i { margin-top: 1px; }
.alert .alert-body { flex: 1; min-width: 0; }
.alert .alert-close { margin: -6px -6px -6px 0; }
.alert-success { border-color: #cfe8d1; background: #f4fbf4; } .alert-success > .i { color: var(--good-text); }
.alert-error { border-color: #f1cfcf; background: #fdf6f6; } .alert-error > .i { color: var(--bad); }
.alert-warning { border-color: #f2e0b0; background: #fffaf0; } .alert-warning > .i { color: #b67a00; }
.alert-info { border-color: #d5e4f6; background: #f6f9fe; } .alert-info > .i { color: var(--accent); }

/* ---------- filters & segmented ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-3); border-radius: 11px; }
.seg a, .seg button, .seg label {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 13px; border-radius: 8px; border: 0;
  background: transparent; color: var(--text-2); font-size: 13px; font-weight: 550; cursor: pointer; white-space: nowrap;
}
.seg a:hover, .seg label:hover { color: var(--text); }
.seg a.on, .seg button.on, .seg label.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(20, 20, 16, .08), 0 0 0 1px rgba(20, 20, 16, .03); }
.seg .n { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.select, .input-sm {
  height: 38px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface);
  font-size: 13.5px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.select { padding-right: 32px; appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23898781' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; }
.select:focus, .input-sm:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.search { position: relative; flex: 1; min-width: 200px; max-width: 360px; }
.search .i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { width: 100%; padding-left: 38px; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; position: relative; }
.field > label, .field .label { font-size: 13px; font-weight: 550; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.req { width: 5px; height: 5px; border-radius: 50%; background: #d4a01e; display: inline-block; flex-shrink: 0; }
.field-hint { font-size: 12px; color: var(--muted); }
.field-error { font-size: 12.5px; color: var(--bad-text); font-weight: 500; }
.input, .field input[type=text], .field input[type=number], .field input[type=date], .field input[type=time],
.field input[type=password], .field input[type=tel], .field select, .field textarea {
  width: 100%; height: 44px; padding: 0 13px; border: 1px solid var(--border-strong); border-radius: 11px;
  background: var(--surface); font-size: 15px; outline: none; transition: border-color .15s, box-shadow .15s, background .3s;
}
.field textarea { height: auto; min-height: 90px; padding: 11px 13px; resize: vertical; line-height: 1.45; }
.field select { appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23898781' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
.field input::placeholder, .field textarea::placeholder { color: #b3b1aa; }
.field input:hover, .field select:hover, .field textarea:hover { border-color: #c6c5bc; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.field.has-error input, .field.has-error select { border-color: var(--bad); background: #fffafa; }
.field.is-missing input, .field.is-missing select { border-color: #e2b23c; background: #fffcf3; }
.field.is-dirty > label::after { content: "изменено"; margin-left: auto; font-size: 11px; font-weight: 600; color: var(--accent); }
.field.flash input, .field.flash select { animation: flash-field 2.4s ease; }
@keyframes flash-field { 0%, 35% { background: #fff4c7; border-color: #e7bd3d; } 100% { background: var(--surface); } }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .suffix { position: absolute; right: 13px; color: var(--muted); font-size: 14px; pointer-events: none; }
.input-wrap.has-suffix input { padding-right: 44px; }
.input-wrap .inline-btn { position: absolute; right: 5px; }
.remote-note {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 7px 10px; border-radius: 9px; font-size: 12.5px;
  background: var(--accent-soft); color: var(--accent-press);
}
.remote-note b { font-weight: 600; }
.form-grid { display: grid; gap: 16px 18px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-grid .wide { grid-column: 1 / -1; }
.form-grid .span-2 { grid-column: span 2; }

/* trailer choice */
.choice { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.choice-item { position: relative; }
.choice-item input { position: absolute; opacity: 0; pointer-events: none; }
.choice-item label {
  display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 14px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); transition: border-color .15s, background .15s, box-shadow .15s;
}
.choice-item label:hover { border-color: #c6c5bc; }
.choice-item .ico { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); }
.choice-item b { display: block; font-size: 14px; font-weight: 600; }
.choice-item small { display: block; font-size: 12px; color: var(--muted); line-height: 1.2; }
.choice-item input:checked + label { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); background: #fbfdff; }
.choice-item.ref input:checked + label .ico { background: var(--ref-soft); color: var(--ref-text); }
.choice-item.grain input:checked + label .ico { background: var(--grain-soft); color: var(--grain-text); }
.choice-item input:focus-visible + label { box-shadow: 0 0 0 3px var(--accent-ring); }

/* ---------- trip form ---------- */
.form-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.form-main { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.section-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 18px; }
.section-num {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0;
  background: var(--surface-3); color: var(--text-2); font-size: 13px; font-weight: 650;
}
.section-num.done { background: var(--good-soft); color: var(--good-text); }
.section-head h2 { font-size: 16px; }
.section-head p { color: var(--muted); font-size: 13px; margin-top: 1px; }
.form-side { position: sticky; top: 88px; display: flex; flex-direction: column; gap: 16px; }
.side-card { padding: 20px; }
.side-top { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.progress-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; font-size: 13px; color: var(--text-2); }
.progress-head b { font-size: 14px; color: var(--text); }
.progress { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.progress-bar { height: 100%; border-radius: 3px; background: var(--accent); transition: width .35s ease, background .3s; }
.progress-bar.complete { background: var(--good); }
.checklist { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.checklist li a { display: flex; align-items: center; gap: 9px; padding: 5px 6px; border-radius: 7px; font-size: 13px; color: var(--text-2); }
.checklist li a:hover { background: var(--surface-3); color: var(--text); }
.checklist .dot { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid #cfcdc4; flex-shrink: 0; }
.checklist li.done { display: none; }
.checklist-done { display: flex; align-items: center; gap: 8px; margin-top: 14px; padding: 10px 12px; border-radius: 10px; background: var(--good-soft); color: var(--good-text); font-size: 13px; font-weight: 550; }
.side-total { margin: 18px 0; padding: 16px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.side-total .label { font-size: 12.5px; color: var(--muted); }
.side-total .value { font-size: 28px; font-weight: 650; letter-spacing: -.02em; margin-top: 2px; line-height: 1.15; }
.side-total .formula { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.side-actions { display: flex; flex-direction: column; gap: 9px; }
.side-hint { font-size: 12px; color: var(--muted); text-align: center; line-height: 1.4; }
.side-meta { font-size: 12.5px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.presence { display: flex; flex-direction: column; gap: 8px; }
.presence-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 11px; background: var(--good-soft); font-size: 13px; }
.presence-item b { font-weight: 600; }
.presence-item small { display: block; color: var(--good-text); font-size: 12px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 0 rgba(12, 163, 12, .5); animation: pulse 1.8s infinite; flex-shrink: 0; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(12, 163, 12, .45); } 70% { box-shadow: 0 0 0 7px rgba(12, 163, 12, 0); } 100% { box-shadow: 0 0 0 0 rgba(12, 163, 12, 0); } }
.live-banner { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-press); font-size: 14px; border: 1px solid #d5e4f6; }
.live-banner.good { background: var(--good-soft); color: var(--good-text); border-color: #cfe8d1; }
.live-banner .spacer { flex: 1; }
.total-inline { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; padding: 14px 16px; border-radius: 12px; background: var(--surface-2); border: 1px dashed var(--border-strong); }
.total-inline .value { font-size: 22px; font-weight: 650; letter-spacing: -.01em; }
.total-inline .formula { color: var(--muted); font-size: 13px; }
.km-meta { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; min-height: 18px; }
.km-meta.ok { color: var(--good-text); }
.mobile-bar { display: none; }

/* map */
.map { height: 300px; border-radius: 12px; overflow: hidden; background: #eef0ec; border: 1px solid var(--border); position: relative; z-index: 0; }
.map.tall { height: calc(100vh - 230px); min-height: 460px; }
.leaflet-tile-pane { filter: saturate(.72) brightness(1.32) contrast(.9); }
/* фон под цвет снимка — субпиксельные зазоры между фрагментами при дробном масштабе не видны */
.map, .map.leaflet-container { background: #48512f; }
/* в Leaflet 1.9 стыки фрагментов смешиваются как plus-lighter — с осветляющим фильтром это светлые линии */
.leaflet-container img.leaflet-tile { mix-blend-mode: normal; }
.city-label { pointer-events: none; }
.city-label span { display: block; transform: translate(-4px, -50%); white-space: nowrap; font-size: 12px; font-weight: 600;
  color: #fff; letter-spacing: .01em; text-shadow: 0 0 3px rgba(0, 0, 0, .75), 0 1px 2px rgba(0, 0, 0, .6); }
.city-label.tier-1 span { font-size: 13px; }
.city-label.shift span { transform: translate(10px, -50%); }
.city-label.shift span::before { visibility: hidden; }
.city-label.tier-3 span { font-size: 11px; font-weight: 550; }
.city-label span::before { content: ""; display: inline-block; width: 5px; height: 5px; margin-right: 4px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .45); vertical-align: 1px; }
.map-empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 20px; color: var(--muted); font-size: 13px; z-index: 500; background: rgba(246, 246, 243, .8); }
.pin { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 12px; font-weight: 700; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .25); }
.pin-a { background: var(--accent); }
.pin-b { background: #141413; }
.pin-dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .3); }
.leaflet-container { font-family: var(--font); }
.leaflet-control-attribution { display: none !important; }
.leaflet-popup-content-wrapper { border-radius: 12px; box-shadow: var(--shadow-lg); }
.leaflet-popup-content { margin: 12px 14px; font-size: 13px; line-height: 1.45; }
.popup-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; }

/* docs */
.doc-slots { display: flex; flex-direction: column; gap: 10px; }
.doc-slot { border: 1px solid var(--border); border-radius: 13px; padding: 12px 14px; background: var(--surface); transition: border-color .2s, background .2s; }
.doc-slot.is-missing { border-color: #e2b23c; background: #fffcf3; }
.doc-slot.has-files { background: var(--surface-2); }
.doc-slot-head { display: flex; align-items: center; gap: 11px; }
.doc-step { width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; font-size: 12px; font-weight: 650; background: var(--surface-3); color: var(--text-2); flex-shrink: 0; }
.doc-slot.has-files .doc-step { background: var(--good-soft); color: var(--good-text); }
.doc-slot-title { flex: 1; min-width: 0; font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 7px; }
.doc-slot-title .muted { font-weight: 400; font-size: 12.5px; }
.file-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.file-list:not(:empty) { margin-top: 10px; }
.file-chip { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); font-size: 13px; min-width: 0; }
.file-chip .ext { min-width: 38px; height: 22px; padding: 0 5px; border-radius: 5px; display: grid; place-items: center; font-size: 10px; font-weight: 700; letter-spacing: .02em; background: var(--surface-3); color: var(--text-2); }
.file-chip .ext.pdf { background: #fdecec; color: #b42f2f; }
.file-chip .ext.doc, .file-chip .ext.docx { background: #e8f0fc; color: #1c5cab; }
.file-chip .ext.jpg, .file-chip .ext.jpeg, .file-chip .ext.png, .file-chip .ext.heic { background: #eaf6ef; color: #17734a; }
.file-chip .name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.file-chip .name:hover { color: var(--accent); }
.file-chip .meta { color: var(--muted); font-size: 12px; white-space: nowrap; }
.file-chip .lock { color: #b3b1aa; }
.dropzone {
  margin-top: 10px; display: flex; align-items: center; gap: 12px; padding: 11px 14px; border: 1.5px dashed var(--border-strong);
  border-radius: 11px; color: var(--text-2); cursor: pointer; transition: border-color .15s, background .15s; position: relative;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: #f7fbff; color: var(--accent-press); }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.dropzone .dz-title { font-weight: 550; font-size: 13.5px; }
.dropzone .dz-hint { font-size: 12px; color: var(--muted); }
.dropzone .dz-files { font-size: 12.5px; color: var(--accent-press); font-weight: 550; }
.dropzone.has-files { border-style: solid; border-color: var(--accent); background: #f7fbff; }
.locked-note { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); margin-top: 12px; }
.doc-actions { display: flex; align-items: center; gap: 4px; }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: 1.35fr repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi { padding: 18px 20px; display: flex; flex-direction: column; gap: 4px; }
.kpi .label { font-size: 13px; color: var(--text-2); font-weight: 500; display: flex; align-items: center; gap: 7px; }
.kpi .label .i { color: var(--muted); }
.kpi .value { font-size: 26px; font-weight: 650; letter-spacing: -.02em; line-height: 1.2; margin-top: 2px; }
.kpi .value small { font-size: 15px; font-weight: 550; color: var(--text-2); letter-spacing: 0; }
.kpi .sub { font-size: 12.5px; color: var(--muted); }
.kpi.hero { grid-row: span 2; justify-content: space-between; }
.kpi.hero .value { font-size: 48px; letter-spacing: -.035em; line-height: 1.05; margin-top: 8px; }
.spark-wrap { position: relative; margin-top: 14px; height: 84px; }
.spark { display: block; }
.spark-dot { position: absolute; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px #fff; }
.spark-axis { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); margin-top: 6px; }
.delta { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 0 4px; font-size: 12.5px; font-weight: 550; color: var(--text-2); }
.delta .i { width: 14px; height: 14px; vertical-align: 0; }
.delta.good { color: var(--good-text); }
.delta.bad { color: var(--bad-text); }
.delta .vs { color: var(--muted); font-weight: 400; white-space: nowrap; }

/* ---------- charts ---------- */
.chart-box { position: relative; height: 290px; }
.legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 13px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.key { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.key.line { width: 14px; height: 3px; border-radius: 2px; }
details.table-view { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 12px; }
details.table-view summary { cursor: pointer; font-size: 13px; color: var(--text-2); font-weight: 500; display: inline-flex; align-items: center; gap: 6px; list-style: none; }
details.table-view summary::-webkit-details-marker { display: none; }
details.table-view[open] summary { margin-bottom: 10px; }
.bars { display: flex; flex-direction: column; gap: 13px; }
.bar-row .bar-top { display: flex; align-items: baseline; gap: 10px; font-size: 13.5px; margin-bottom: 6px; }
.bar-row .bar-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.bar-row .bar-value { font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bar-row .bar-extra { color: var(--muted); font-size: 12.5px; white-space: nowrap; min-width: 42px; text-align: right; font-variant-numeric: tabular-nums; }
.bar-track { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; background: var(--accent); min-width: 3px; }
.bar-row a.bar-name:hover { color: var(--accent); }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.compare-item { padding: 16px; border-radius: 13px; border: 1px solid var(--border); background: var(--surface-2); }
.compare-item .top { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.compare-item .big { font-size: 22px; font-weight: 650; letter-spacing: -.02em; }
.compare-item dl { margin: 10px 0 0; display: grid; grid-template-columns: 1fr auto; gap: 5px 10px; font-size: 13px; }
.compare-item dt { color: var(--muted); }
.compare-item dd { margin: 0; text-align: right; font-weight: 550; font-variant-numeric: tabular-nums; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 12px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface-2); }
.table td { padding: 13px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover { background: #fafaf7; }
.table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table .strong { font-weight: 600; }
.table.compact td, .table.compact th { padding: 9px 12px; }
.table td.clip { max-width: 220px; }
.table td.clip > div, .table td.clip > .cell-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.table-trips .table th, .table-trips .table td { padding-left: 10px; padding-right: 10px; }
.table-trips .table td.clip { max-width: 190px; }
.trip-num { font-weight: 650; white-space: nowrap; }
.route { font-weight: 550; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.route .i { color: var(--muted); width: 14px; height: 14px; }
.cell-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; white-space: nowrap; }
.doc-dots { display: inline-flex; gap: 4px; }
.doc-dots span { width: 18px; height: 18px; border-radius: 5px; display: grid; place-items: center; font-size: 9.5px; font-weight: 700; background: var(--surface-3); color: #b3b1aa; }
.doc-dots span.on { background: var(--good-soft); color: var(--good-text); }
.mini-progress { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2); white-space: nowrap; }
.mini-progress .progress { width: 64px; height: 5px; }
.trip-cards { display: none; }

/* ---------- lists ---------- */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); min-width: 0; }
.list-item:last-child { border-bottom: 0; padding-bottom: 0; }
.list-item:first-child { padding-top: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
a.list-item:hover .title { color: var(--accent); }
.empty { text-align: center; padding: 34px 20px; color: var(--muted); font-size: 14px; }
.empty .i { margin: 0 auto 10px; color: #c3c2b7; display: block; }
.empty b { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }

/* ---------- trip detail ---------- */
.detail-head { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.detail-head .route-title { font-size: 26px; font-weight: 650; letter-spacing: -.02em; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.detail-head .route-title .i { color: var(--muted); }
.detail-head .meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; color: var(--muted); font-size: 13px; }
.detail-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.metric-strip { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); margin-bottom: 20px; padding: 0; }
.metric { padding: 16px 18px; border-right: 1px solid var(--border); min-width: 0; }
.metric:last-child { border-right: 0; }
.metric .label { font-size: 12.5px; color: var(--muted); }
.metric .value { font-size: 20px; font-weight: 650; letter-spacing: -.015em; margin-top: 3px; white-space: nowrap; }
.metric .sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
.metric.hero .value { font-size: 24px; color: var(--accent-press); }
.points { display: flex; flex-direction: column; margin-top: 18px; }
.point { display: grid; grid-template-columns: 28px 1fr; gap: 12px; position: relative; padding-bottom: 18px; }
.point:last-child { padding-bottom: 0; }
.point::before { content: ""; position: absolute; left: 13px; top: 30px; bottom: 2px; width: 2px; background: var(--border); }
.point:last-child::before { display: none; }
.point .pin { width: 28px; height: 28px; }
.point .p-title { font-weight: 600; font-size: 15px; }
.point .p-meta { color: var(--text-2); font-size: 13px; margin-top: 2px; }
.point .p-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.dl { display: grid; grid-template-columns: minmax(120px, auto) 1fr; gap: 11px 16px; margin: 0; font-size: 14px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; font-weight: 550; min-width: 0; overflow-wrap: anywhere; }
.verdict { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 12px; font-size: 14px; font-weight: 550; margin-bottom: 14px; }
.verdict.good { background: var(--good-soft); color: var(--good-text); }
.verdict.warn { background: var(--warn-soft); color: var(--warn-text); }
.verdict.info { background: var(--surface-3); color: var(--text-2); }
.assess-row { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: baseline; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.assess-row:last-child { border-bottom: 0; }
.assess-row .avg { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.assess-row .v { font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.draft-callout { display: flex; align-items: center; gap: 16px; padding: 16px 18px; margin-bottom: 20px; border-radius: 14px; background: var(--warn-soft); border: 1px solid #f2e0b0; }
.draft-callout .grow { flex: 1; min-width: 0; }
.draft-callout b { display: block; font-size: 14.5px; color: var(--warn-text); }
.draft-callout span { font-size: 13px; color: #8b6a1f; }

/* expenses */
.expense-list .list-item .amount { font-weight: 650; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cat-chip { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; background: var(--surface-3); color: var(--text-2); font-size: 12px; font-weight: 550; white-space: nowrap; }
.expense-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 16px; border-radius: 13px; background: var(--surface-2); border: 1px solid var(--border); margin-top: 16px; }
.expense-form .wide { grid-column: 1 / -1; }
.expense-form .actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; }
.totals-line { display: flex; align-items: baseline; justify-content: space-between; padding-top: 12px; margin-top: 4px; border-top: 1px solid var(--border); font-size: 14px; }
.totals-line b { font-size: 16px; }

/* activity */
.timeline { display: flex; flex-direction: column; gap: 16px; margin-top: 18px; }
.event { display: flex; gap: 12px; }
.event .body { flex: 1; min-width: 0; }
.event .who { font-size: 13px; color: var(--text-2); }
.event .who b { color: var(--text); font-weight: 600; }
.event .who .t { color: var(--muted); }
.event .text { font-size: 13.5px; margin-top: 2px; color: var(--text-2); overflow-wrap: anywhere; }
.event.comment .text { display: inline-block; margin-top: 5px; padding: 9px 13px; border-radius: 4px 14px 14px 14px; background: var(--surface-3); color: var(--text); white-space: pre-wrap; }
.event .sys-ico { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); flex-shrink: 0; }
.event .sys-ico.added { background: var(--good-soft); color: var(--good-text); }
.comment-form { display: flex; gap: 10px; align-items: flex-end; }
.comment-form textarea { flex: 1; min-height: 44px; height: 44px; max-height: 160px; padding: 11px 13px; border-radius: 12px; border: 1px solid var(--border-strong); resize: vertical; outline: none; font-size: 14px; line-height: 1.45; }
.comment-form textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }

/* ---------- notifications ---------- */
.notif { position: relative; }
.notif-badge {
  position: absolute; top: 3px; right: 3px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--bad);
  color: #fff; font-size: 10.5px; font-weight: 700; display: grid; place-items: center; box-shadow: 0 0 0 2px var(--bg);
}
.notif-badge.bump { animation: bump .5s ease; }
@keyframes bump { 30% { transform: scale(1.35); } 100% { transform: scale(1); } }
.notif-panel {
  position: absolute; right: 0; top: calc(100% + 8px); width: 390px; max-width: calc(100vw - 24px); background: var(--surface);
  border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); overflow: hidden; z-index: 60;
  animation: pop .14s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.notif-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.notif-head b { font-size: 15px; }
.notif-list { max-height: 420px; overflow-y: auto; }
.notif-item { display: flex; gap: 11px; padding: 12px 16px; border-bottom: 1px solid var(--border); transition: background .12s; }
.notif-item:last-child { border-bottom: 0; }
.notif-item:hover { background: var(--surface-2); }
.notif-item.unread { background: #f7fbff; }
.notif-item.unread:hover { background: #f0f6fe; }
.notif-item .grow { flex: 1; min-width: 0; }
.notif-item .n-title { font-size: 13.5px; font-weight: 600; display: flex; gap: 8px; align-items: center; }
.notif-item .n-title .udot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.notif-item .n-body { font-size: 12.5px; color: var(--text-2); margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.notif-item .n-time { font-size: 12px; color: var(--muted); margin-top: 3px; }
.notif-empty { padding: 30px 16px; text-align: center; color: var(--muted); font-size: 13px; }
.notif-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 16px; border-top: 1px solid var(--border); background: var(--surface-2); font-size: 13px; }
.notif-foot a { color: var(--text-2); font-weight: 500; }
.notif-foot a:hover { color: var(--text); }
.notif-page .notif-item { border-radius: 0; }

/* ---------- push banner ---------- */
.push-banner { display: flex; align-items: center; gap: 12px; padding: 12px 14px 12px 16px; margin-bottom: 18px; border-radius: 14px;
  background: linear-gradient(120deg, #f2f7ff, #ffffff); border: 1px solid #d5e4f6; box-shadow: var(--shadow-sm); }
.push-banner .pb-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; background: var(--accent); color: #fff; }
.push-banner .grow { flex: 1; min-width: 0; font-size: 13.5px; color: var(--text-2); line-height: 1.4; }
.push-banner .grow b { display: block; color: var(--text); font-size: 14px; }

/* ---------- toasts ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 1000; display: flex; flex-direction: column; gap: 10px; width: 370px; max-width: calc(100vw - 32px); }
.toast {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px 14px 14px 16px; border-radius: 14px; background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow-lg); animation: toast-in .25s ease; cursor: default;
}
.toast.out { animation: toast-out .2s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }
.toast .t-ico { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; background: var(--accent-soft); color: var(--accent); }
.toast.success .t-ico { background: var(--good-soft); color: var(--good-text); }
.toast.warn .t-ico { background: var(--warn-soft); color: #b67a00; }
.toast.error .t-ico { background: var(--bad-soft); color: var(--bad); }
.toast .grow { flex: 1; min-width: 0; }
.toast .t-title { font-weight: 600; font-size: 14px; }
.toast .t-body { font-size: 13px; color: var(--text-2); margin-top: 2px; overflow-wrap: anywhere; }
.toast a.t-link { display: inline-block; margin-top: 6px; color: var(--accent); font-size: 13px; font-weight: 550; }
.toast .t-close { margin: -6px -6px 0 0; }

/* ---------- AI ---------- */
.insights { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.insight { display: flex; gap: 13px; padding: 16px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); }
.insight .ins-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; background: var(--surface-3); color: var(--text-2); }
.insight.good .ins-ico { background: var(--good-soft); color: var(--good-text); }
.insight.warn .ins-ico { background: var(--warn-soft); color: #b67a00; }
.insight.bad .ins-ico { background: var(--bad-soft); color: var(--bad); }
.insight.info .ins-ico { background: var(--accent-soft); color: var(--accent); }
.insight .ins-title { font-weight: 600; font-size: 14.5px; line-height: 1.35; }
.insight .ins-text { font-size: 13.5px; color: var(--text-2); margin-top: 4px; line-height: 1.5; }
.insight .ins-tag { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 3px; color: var(--muted); }
.ai-hero { display: flex; gap: 18px; align-items: center; padding: 22px; border-radius: var(--radius); margin-bottom: 20px;
  background: linear-gradient(120deg, #f5f9ff 0%, #ffffff 55%, #fbf8f2 100%); border: 1px solid #dfe8f5; }
.ai-hero .ai-mark { width: 52px; height: 52px; border-radius: 15px; display: grid; place-items: center; color: #fff; flex-shrink: 0;
  background: linear-gradient(145deg, #3a8ae6, #6250d6); box-shadow: 0 8px 22px rgba(70, 90, 210, .28); }
.ai-hero h2 { font-size: 18px; }
.ai-hero p { color: var(--text-2); font-size: 14px; margin-top: 3px; }
.ai-hero .grow { flex: 1; min-width: 0; }
.ai-summary { padding: 16px 18px; border-radius: 13px; background: var(--accent-soft); color: #173f73; font-size: 14.5px; line-height: 1.55; margin-bottom: 16px; }
.reco { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; counter-reset: reco; }
.reco li { display: flex; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); font-size: 14px; }
.reco li::before { counter-increment: reco; content: counter(reco); width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; flex-shrink: 0; background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); font-size: 13px; color: var(--text-2); cursor: pointer; transition: border-color .15s, color .15s, background .15s; }
.chip:hover { border-color: var(--accent); color: var(--accent-press); background: #f7fbff; }
.answer { margin-top: 14px; padding: 16px 18px; border-radius: 13px; border: 1px solid var(--border); background: var(--surface-2); font-size: 14px; line-height: 1.6; white-space: pre-wrap; }
.skeleton { height: 14px; border-radius: 7px; background: linear-gradient(90deg, var(--surface-3), #f8f8f5, var(--surface-3)); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.ai-off { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 12px; background: var(--surface-2); border: 1px dashed var(--border-strong); font-size: 13.5px; color: var(--text-2); }
.ai-off code { background: var(--surface-3); padding: 1px 6px; border-radius: 5px; font-size: 12.5px; }

/* ---------- settings ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 22px; }
.tabs a { padding: 10px 14px; font-weight: 550; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); }
.tabs a.on { color: var(--accent-press); border-bottom-color: var(--accent); }
.settings-card { max-width: 860px; }

/* ---------- login ---------- */
.login-page { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; background: var(--surface); }
.login-art { position: relative; overflow: hidden; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; color: #fff;
  background: radial-gradient(1200px 600px at 10% 0%, #3b8ce8 0%, #1f5fb4 45%, #173e7a 100%); }
.login-art::after { content: ""; position: absolute; inset: 0; background-image: radial-gradient(rgba(255, 255, 255, .12) 1px, transparent 1px); background-size: 22px 22px; mask-image: linear-gradient(180deg, rgba(0, 0, 0, .5), transparent 70%); }
.login-art > * { position: relative; z-index: 1; }
.login-art .brand-text b { font-size: 20px; }
.login-art .brand-text small { color: rgba(255, 255, 255, .7); }
.login-art .brand-mark { background: rgba(255, 255, 255, .16); box-shadow: none; border: 1px solid rgba(255, 255, 255, .25); }
.login-art h2 { font-size: 34px; line-height: 1.15; letter-spacing: -.03em; max-width: 460px; }
.login-art p { color: rgba(255, 255, 255, .78); font-size: 16px; margin-top: 14px; max-width: 440px; line-height: 1.55; }
.login-feats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-width: 520px; }
.login-feat { padding: 14px; border-radius: 14px; background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .16); font-size: 13.5px; display: flex; gap: 10px; align-items: flex-start; }
.login-feat .i { opacity: .85; margin-top: 1px; }
.login-form-wrap { display: grid; place-items: center; padding: 40px 24px; }
.login-box { width: 100%; max-width: 380px; }
.login-box h1 { font-size: 26px; letter-spacing: -.02em; }
.login-box .lead { color: var(--muted); margin-top: 6px; margin-bottom: 26px; }
.demo-users { display: flex; flex-direction: column; gap: 8px; }
.demo-user { display: flex; align-items: center; gap: 12px; padding: 11px 13px; border-radius: 13px; border: 1px solid var(--border); background: var(--surface); transition: border-color .15s, box-shadow .15s, transform .1s; }
.demo-user:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.demo-user .grow { flex: 1; }
.demo-user b { display: block; font-size: 14px; }
.demo-user small { color: var(--muted); font-size: 12.5px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12.5px; margin: 22px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ---------- error page ---------- */
.error-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; text-align: center; }
.error-page .code { font-size: 64px; font-weight: 700; letter-spacing: -.04em; color: #d9d8d0; }
.error-page h1 { font-size: 22px; margin-top: 4px; }
.error-page p { color: var(--muted); margin: 8px 0 22px; }

.fab { display: none; }

/* ==========================================================================
   Адаптив
   ========================================================================== */
@media (max-width: 1280px) {
  .metric-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .metric:nth-child(3) { border-right: 0; }
  .metric:nth-child(-n+3) { border-bottom: 1px solid var(--border); }
}
@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi.hero { grid-column: 1 / -1; grid-row: auto; }
  .span-4, .span-5, .span-6, .span-7, .span-8 { grid-column: span 12; }
  .form-layout { grid-template-columns: minmax(0, 1fr) 300px; }
  .form-grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  .sidebar { transform: translateX(-102%); transition: transform .25s ease; box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 45; background: rgba(20, 20, 16, .35); }
  .main { margin-left: 0; }
  .topbar .menu-btn { display: inline-grid; margin-left: -8px; }
  .topbar { padding: 10px 16px; min-height: 60px; gap: 8px; }
  .topbar-title h1 { font-size: 18px; }
  .topbar-title .sub { display: none; }
  .content { padding: 4px 16px 96px; }
  .hide-sm { display: none !important; }
  .fab { display: grid; place-items: center; position: fixed; right: 18px; bottom: 18px; z-index: 35; width: 56px; height: 56px; border-radius: 18px; background: var(--accent); color: #fff; box-shadow: 0 10px 24px rgba(42, 120, 214, .4); }
  .form-layout { grid-template-columns: 1fr; }
  .form-side { position: static; }
  .form-side .side-actions { display: none; }
  .mobile-bar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 36; gap: 8px; align-items: center;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: rgba(255, 255, 255, .94); backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--border);
  }
  .mobile-bar .mb-progress { font-size: 12px; color: var(--text-2); line-height: 1.2; min-width: 58px; }
  .mobile-bar .mb-progress b { display: block; font-size: 15px; color: var(--text); }
  .mobile-bar .btn { flex: 1; height: 46px; padding: 0 10px; }
  .page-trip-form .fab { display: none; }
  .table-trips { display: none; }
  .trip-cards { display: flex; flex-direction: column; gap: 10px; }
  .trip-card { display: block; padding: 14px 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
  .trip-card .tc-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
  .trip-card .tc-route { font-weight: 650; font-size: 15px; }
  .trip-card .tc-meta { font-size: 13px; color: var(--muted); margin-top: 3px; }
  .trip-card .tc-bottom { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; gap: 10px; }
  .trip-card .tc-sum { font-weight: 650; font-size: 15px; }
  .login-page { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .detail-head .route-title { font-size: 21px; }
  .metric-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric { border-right: 0 !important; border-bottom: 1px solid var(--border); }
  .metric:nth-child(odd) { border-right: 1px solid var(--border) !important; }
  .metric:nth-last-child(-n+2) { border-bottom: 0; }
}
@media (max-width: 680px) {
  .grid-2, .grid-3, .grid-4, .insights, .compare { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 12px; }
  .kpi { padding: 14px 16px; }
  .kpi .value { font-size: 21px; }
  .kpi.hero .value { font-size: 40px; }
  .form-grid, .form-grid.cols-3, .form-grid.cols-4 { grid-template-columns: 1fr 1fr; gap: 14px 12px; }
  .form-grid .m-wide { grid-column: 1 / -1; }
  .card { padding: 18px 16px; border-radius: 14px; }
  .card.flush { padding: 0; }
  .toolbar { gap: 8px; }
  .toolbar .seg { overflow-x: auto; max-width: 100%; }
  .search { max-width: none; min-width: 100%; order: -1; }
  .expense-form { grid-template-columns: 1fr 1fr; }
  .expense-form .m-wide { grid-column: 1 / -1; }
  .notif-panel { position: fixed; left: 12px; right: 12px; top: 64px; width: auto; }
  .toasts { left: 16px; right: 16px; bottom: 84px; width: auto; }
  .detail-actions { margin-left: 0; width: 100%; }
  .detail-actions .btn { flex: 1; }
  .ai-hero { flex-direction: column; align-items: flex-start; }
  .chart-box { height: 240px; }
  .dl { grid-template-columns: 1fr; gap: 2px; }
  .dl dd { margin-bottom: 10px; }
  .map.tall { height: calc(100vh - 260px); min-height: 380px; }
}
/* ---------- телефон и планшет: удобство пальцем ---------- */
.show-sm, .expense-cards, .login-brand-mobile { display: none; }
@media (max-width: 960px), (pointer: coarse) {
  /* iPhone увеличивает страницу при фокусе на поле с шрифтом мельче 16px */
  input, select, textarea, .input-sm, .select, .input, .field input[type=text], .field input[type=number],
  .field input[type=date], .field input[type=time], .field input[type=password], .field input[type=tel],
  .field select, .field textarea, .comment-form textarea { font-size: 16px; }
}
@media (max-width: 960px) {
  .btn-icon.sm { width: 38px; height: 38px; }
  .checklist li a { padding: 9px 8px; }
  .btn-sm { height: 38px; }
  #push-banner-close { width: 40px; height: 40px; }
  .fab { bottom: calc(18px + env(safe-area-inset-bottom)); right: calc(18px + env(safe-area-inset-right)); }
  .topbar { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .content { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .login-brand-mobile { display: flex; padding: 0 0 26px; }
}
@media (max-width: 680px) {
  .card-head { flex-wrap: wrap; row-gap: 4px; }
  .card-head h2, .card-head h3 { min-width: min(100%, 210px); }
  .push-banner { padding: 10px 10px 10px 12px; gap: 10px; }
  .push-banner .pb-ico { width: 30px; height: 30px; }
  .push-banner #push-banner-text { display: none; }
  .push-banner.ios { flex-wrap: wrap; }
  .push-banner.ios #push-banner-text { display: block; margin-top: 2px; }
  .list-item .title { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .table-expenses { display: none; }
  .map { height: 240px; }
  .expense-cards { display: flex; flex-direction: column; }
  .expense-card { display: flex; align-items: flex-start; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--border); }
  .expense-card:last-child { border-bottom: 0; }
  .expense-card .grow { flex: 1; min-width: 0; }
  .expense-card .ec-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
  .expense-card .ec-amount { font-weight: 650; font-size: 15px; white-space: nowrap; }
  .expense-card .cell-sub { white-space: normal; }
  .expense-card .ec-actions { display: flex; gap: 2px; margin: -4px -6px 0 0; }
  .users-table th.hide-col, .users-table td.hide-col { display: none; }
  .users-table .cell-sub { white-space: normal; }
  .users-table td { padding-left: 10px; padding-right: 10px; }
  .show-sm { display: block; }
  .toasts { bottom: calc(84px + env(safe-area-inset-bottom)); }
}
@media (max-width: 420px) {
  .choice-item small { display: none; }
  .choice-item label { height: 52px; padding: 0 12px; gap: 10px; }
}
@media print {
  .sidebar, .topbar, .fab, .toasts, .mobile-bar { display: none !important; }
  .main { margin: 0; }
  body { background: #fff; }
  .card { box-shadow: none; }
}
