/* Переменные — в assets/css/tokens.css, он подключается раньше. */
* { margin: 0; }
body { display: flex; min-height: 100vh; background: var(--bg);
  font-family: Inter, system-ui, sans-serif; color: var(--text); font-size: 14px; }

/* сайдбар */
.sidebar { width: 242px; flex: 0 0 242px; background: var(--side); display: flex;
  flex-direction: column; padding: 22px 14px; position: sticky; top: 0; height: 100vh;
  overflow-y: auto; }
.logo { display: flex; align-items: center; gap: 9px; padding: 0 10px 26px; font-size: 17px;
  font-weight: 600; color: #fff; letter-spacing: -.01em; }
.logo:hover { color: #fff; }
.logo span { color: #A5A0F0; }
.brand-mark { display: inline-flex; align-items: center; justify-content: center; width: 28px;
  height: 28px; border-radius: 8px; background: var(--accent); color: #fff; font-size: 15px;
  flex: 0 0 auto; }
.side-group { font-size: 10px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--sidemuted); padding: 22px 12px 8px; }
.side-group:first-of-type { padding-top: 0; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
  padding: 10px 12px; background: none; border: 0; border-radius: 10px; color: var(--sidetext);
  font: inherit; font-size: 13.5px; cursor: pointer; }
.nav-item .ic { font-size: 17px; }
.nav-item:hover { background: var(--side2); color: #fff; }
.nav-item.active { background: var(--accent); color: #fff; font-weight: 500; }
.nav-badge { margin-left: auto; font-size: 11px; color: var(--sidemuted); }
.nav-item.active .nav-badge { color: rgba(255, 255, 255, .7); }

.sidebar-footer { margin-top: auto; padding-top: 18px; }
.user-card { display: flex; align-items: center; gap: 10px; background: var(--side2);
  border-radius: 12px; padding: 10px 12px; }
.user-ava { display: inline-flex; align-items: center; justify-content: center; width: 30px;
  height: 30px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 12px;
  font-weight: 600; flex: 0 0 auto; }
.user-meta { min-width: 0; }
.user-name { font-size: 12.5px; color: #fff; font-weight: 500; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.user-sub { font-size: 11px; color: var(--sidemuted); }
.logout-btn { margin-left: auto; color: var(--sidemuted); font-size: 16px; display: inline-flex;
  background: none; padding: 0; }
.logout-btn:hover { color: #fff; }
.back-link { display: flex; align-items: center; gap: 8px; color: var(--sidetext);
  font-size: 13px; padding: 10px 12px; }
.back-link .ic { transform: rotate(180deg); }
.back-link:hover { color: #fff; }

/* main */
.main { flex: 1; padding: 26px 30px 40px; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 18px; margin-bottom: 22px; }
.topbar-title { flex: 1; min-width: 0; }
.topbar h1 { font-size: 23px; font-weight: 500; letter-spacing: -.02em; margin: 0; }
.topbar-date { font-size: 12.5px; color: var(--text2); margin-top: 3px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.burger { display: none; background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--text); }
.lang-switch { display: flex; border: 1px solid var(--border); border-radius: 8px;
  overflow: hidden; background: var(--surface); }
.lang-switch button { border: 0; background: transparent; color: var(--text2); padding: 6px 11px;
  cursor: pointer; font: inherit; font-size: 12px; }
.lang-switch button.active { background: var(--accent); color: #fff; font-weight: 500; }

/* карточки */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 18px; box-shadow: var(--shadow); }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.card h2 { font-size: 14px; font-weight: 500; margin: 0; }
.card-title { display: flex; align-items: center; gap: 9px; margin-bottom: 14px; }
.card-title .ic { font-size: 17px; }
.ic.ink { color: var(--ink); }

/* сетка расчёта */
.calc-grid { display: grid; grid-template-columns: 352px 1fr; gap: 18px; align-items: start;
  margin-bottom: 20px; }
.form-col { display: flex; flex-direction: column; gap: 14px; }

/* поля */
.field { display: flex; align-items: center; gap: 9px; border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; background: var(--surface2); }
.field:focus-within { border-color: var(--accent); }
.field input { border: 0; background: none; outline: none; font-size: 15px; color: var(--text);
  width: 100%; padding: 0; }
.field-clear { flex: 0 0 auto; border: 0; background: none; color: var(--text2); cursor: pointer;
  font-size: 20px; line-height: 1; padding: 0 2px; }
.field-clear:hover { color: var(--text); }
.dot { width: 8px; height: 8px; flex: 0 0 auto; }
.dot-from { border-radius: 50%; background: var(--accent); }
.dot-to { border-radius: 2px; background: var(--text2); }
.dot-via { border-radius: 50%; background: var(--text2); }
.results-col { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
/* альтернативные маршруты */
.variants-head { font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text2); margin-bottom: 8px; }
.variants-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.variant-card { text-align: left; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 14px 16px; font: inherit; color: inherit; cursor: pointer;
  box-shadow: var(--shadow); }
.variant-card:hover { border-color: var(--accent2); }
.variant-card.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(79, 70, 229, .18); }
.variant-head { font-size: 12px; color: var(--text2); display: flex; gap: 6px;
  align-items: baseline; flex-wrap: wrap; }
.variant-badges { color: var(--ink); font-size: 11px; }
.variant-freight { font-size: 19px; font-weight: 600; letter-spacing: -.02em; margin: 4px 0 2px; }
.variant-meta { font-size: 11px; color: var(--text2); }

.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 18px; box-shadow: var(--shadow); }
.stat-ic { display: inline-flex; align-items: center; justify-content: center; width: 30px;
  height: 30px; border-radius: 9px; background: var(--soft); color: var(--ink); font-size: 15px; }
.stat-accent { background: linear-gradient(150deg, var(--accent) 0%, var(--accent2) 100%);
  color: #fff; border-color: transparent; box-shadow: 0 14px 30px rgba(79, 70, 229, .24); }
.stat-accent .stat-ic { background: rgba(255, 255, 255, .18); color: #fff; }
.stat-accent .stat-label { color: #E0E0FA; }
.stat-label { font-size: 12px; color: var(--text2); margin: 18px 0 4px; }
.stat-value { font-size: 27px; font-weight: 600; letter-spacing: -.02em; }
.map-card { padding: 8px; flex: 1; }
#map { height: 460px; min-height: 300px; border-radius: 10px; }

/* форма */
.form-col label { display: block; font-size: 11.5px; color: var(--text2); margin: 12px 0 6px; }
.form-col .card > label:first-of-type { margin-top: 0; }
.form-col input, .form-col select { width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 10px; font: inherit; font-size: 15px; background: var(--surface2);
  color: var(--text); }
.form-col .field input { padding: 0; border: 0; background: none; }
.form-col input:focus, .form-col select:focus { outline: 2px solid var(--accent2);
  border-color: transparent; }
/* Поля внутри .field уже подсвечиваются рамкой обёртки (.field:focus-within),
   свой outline рисовал бы вторую рамку внутри первой. */
.form-col .field input:focus { outline: none; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.row { display: flex; gap: 8px; align-items: end; }
.row select { flex: 1; }
.presets { margin-top: 10px; }
.chip { border: 1px solid var(--border); background: var(--surface2); color: var(--text);
  border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 12px; cursor: pointer; }
.chip:hover { border-color: var(--accent2); color: var(--ink); }
.primary-btn { width: 100%; padding: 13px; border: 0; border-radius: 11px;
  background: var(--accent); color: #fff; font: inherit; font-size: 14.5px; font-weight: 500;
  cursor: pointer; box-shadow: 0 8px 20px rgba(79, 70, 229, .24); }
.primary-btn:hover { background: var(--accent2); }
.primary-btn:disabled { opacity: .6; cursor: default; }
.card-head .primary-btn { width: auto; margin: 0; padding: 9px 16px; font-size: 13px; }
.ghost-btn { border: 1px solid var(--border); background: none; border-radius: 10px;
  padding: 10px 12px; font: inherit; font-size: 12px; cursor: pointer; color: var(--accent); white-space: nowrap; }
.link-btn { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0;
  color: var(--ink); font: inherit; font-size: 12.5px;
  cursor: pointer; padding: 4px 0; }

/* автодополнение */
.suggest-wrap { position: relative; }
.suggest-list { position: absolute; z-index: 1100; left: 0; right: 0; top: 100%;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(30,27,57,.12); max-height: 220px; overflow-y: auto; display: none; }
.suggest-list div { padding: 9px 12px; cursor: pointer; font-size: 13px; }
.suggest-list div:hover { background: var(--surface2); }

/* разбивка */
table.breakdown { width: 100%; border-collapse: collapse; }
table.breakdown th { text-align: left; font-size: 11px; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text2); font-weight: 500;
  padding: 8px 10px; border-bottom: 1px solid var(--border); }
table.breakdown td { padding: 11px 10px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
table.breakdown tr.total-row td { font-weight: 600; border-bottom: 0; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 500; }
.badge.distance { background: var(--soft); color: var(--ink); }
.badge.vignette, .badge.eurovignette { background: #FEF3C7; color: #92400E; }
.badge.distance_weight { background: var(--possoft); color: var(--pos); }
.badge.free { background: var(--surface2); color: var(--text2); }
.badge.toll_points { background: #FEF3C7; color: #92400E; }
.badge.unknown { background: #FEF2F2; color: #B91C1C; }
.note { background: var(--soft); color: var(--ink); border-radius: 10px; padding: 10px 14px;
  font-size: 13px; margin-bottom: 12px; }
.disclaimer { color: var(--muted); font-size: 12px; margin-top: 14px; }
.intro { color: var(--muted); margin-bottom: 14px; }
.muted { color: var(--muted); font-size: 12px; }

/* тарифы */
.tariff-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.tariff-grid .card h3 { font-size: 15px; margin-bottom: 6px; }
.tariff-grid .card table { width: 100%; font-size: 12px; margin-top: 8px; }
.tariff-grid .card a { color: var(--accent); font-size: 12px; }

/* тосты */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--side); color: #fff; padding: 12px 20px; border-radius: 10px;
  font-size: 14px; z-index: 2000; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.toast.error { background: #B91C1C; }

/* кнопки-иконки истории */
.row-actions { display: flex; gap: 6px; }
/* Цвет задаём явно: font: inherit тянет шрифт, но не цвет, а у кнопки он свой
   (buttontext, тёмный) — на тёмной теме надпись сливалась с фоном. */
.row-actions button { border: 1px solid var(--border); background: none; border-radius: 8px;
  padding: 5px 10px; font: inherit; font-size: 12px; cursor: pointer; color: var(--text); }
.row-actions button:hover { border-color: var(--accent-2); color: var(--accent); }
.row-actions button.danger:hover { border-color: #B91C1C; color: #B91C1C; }

@media (max-width: 1100px) {
  .calc-grid { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(3, 1fr); }
}

/* мобильная адаптация */
@media (max-width: 900px) {
  body { flex-direction: column; }
  .sidebar { position: fixed; z-index: 1500; left: -252px; width: 242px; transition: left .2s;
    height: 100vh; }
  .sidebar.open { left: 0; box-shadow: 4px 0 24px rgba(0,0,0,.3); }
  .burger { display: block; }
  .main { padding: 16px; }
  .calc-grid { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .stat-value { font-size: 18px; }
  #map { height: 320px; }
  table.breakdown { display: block; overflow-x: auto; }
  .card-head { flex-wrap: wrap; gap: 8px; }
}

/* остаток дневного лимита */
.quota-note { margin-top: 10px; font-size: 12px; color: var(--muted); text-align: center; }
.quota-note.exhausted { color: #B91C1C; }

/* форма отзыва */
.feedback-card { margin-top: 16px; scroll-margin-top: 20px; }
.feedback-card.highlight { box-shadow: 0 0 0 2px var(--accent); transition: box-shadow .3s; }
.feedback-card textarea { width: 100%; margin: 10px 0; padding: 11px 12px; font: inherit;
  font-size: 13.5px; background: var(--surface2); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; resize: vertical; }
.stars { display: flex; gap: 4px; margin: 10px 0 4px; }
.star { background: none; border: 0; padding: 0 2px; font-size: 30px; line-height: 1;
  cursor: pointer; color: var(--border); }
.star:hover, .star.on { color: #F59E0B; }
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.fb-done { margin-top: 10px; font-weight: 500; color: var(--pos); }

/* подписи номеров дорог вдоль маршрута */
.road-label { background: var(--accent); color: #fff; border-radius: 6px; padding: 1px 6px;
  font-size: 11px; font-weight: 600; line-height: 1.5; white-space: nowrap;
  width: auto !important; height: auto !important; text-align: center;
  box-shadow: 0 2px 6px rgba(24, 22, 51, .3); }

/* города, через которые идёт маршрут: светлая плашка, чтобы не путать
   с синими номерами дорог */
.city-label { background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 1px 6px; font-size: 11px; font-weight: 600; line-height: 1.5;
  white-space: nowrap; width: auto !important; height: auto !important; text-align: center;
  box-shadow: 0 2px 6px rgba(24, 22, 51, .25); }
.route-via { margin-top: 8px; padding: 9px 6px 2px; border-top: 1px solid var(--border);
  font-size: 13px; line-height: 1.6; color: var(--text); }
.route-via-label { color: var(--muted); }
