*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #0f1117;
  color: #e8eaf0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

#rates-bar {
  background: #1a1d28;
  border-bottom: 1px solid #2a2d3e;
  padding: 10px 20px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.rates-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.rates-label { font-size: 12px; color: #8892a4; font-weight: 600; letter-spacing: 0.05em; }
.rate-field { display: flex; align-items: center; gap: 6px; }
.rate-field label { font-size: 12px; color: #8892a4; white-space: nowrap; }
.rate-field input {
  width: 90px;
  background: #0f1117;
  border: 1px solid #2a2d3e;
  border-radius: 6px;
  color: #fff;
  padding: 4px 8px;
  font-size: 14px;
}
#btn-refresh-rates {
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
  font-size: 13px;
}
#btn-refresh-rates:hover { background: #1d4ed8; }
.rates-updated { font-size: 11px; color: #6b7280; }
.rates-stale { color: #f59e0b !important; }

main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.car-form {
  width: 300px;
  min-width: 280px;
  background: #1a1d28;
  border-right: 1px solid #2a2d3e;
  padding: 20px;
  overflow-y: auto;
}
.car-form h2 { font-size: 14px; color: #8892a4; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 16px; }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; color: #8892a4; margin-bottom: 4px; }
.form-group input, .form-group select {
  width: 100%;
  background: #0f1117;
  border: 1px solid #2a2d3e;
  border-radius: 6px;
  color: #e8eaf0;
  padding: 8px 10px;
  font-size: 14px;
}
.form-group input:focus, .form-group select:focus {
  outline: none;
  border-color: #2563eb;
}
.price-group input {
  font-size: 20px;
  font-weight: 700;
  color: #60a5fa;
  padding: 10px;
}
#model_text { margin-top: 6px; }

.customs-status {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 14px;
}
.customs-found { background: #064e3b; border: 1px solid #065f46; color: #6ee7b7; }
.customs-not-found { background: #451a03; border: 1px solid #78350f; color: #fcd34d; }
.customs-льгота { background: #1e1b4b; border: 1px solid #3730a3; color: #a5b4fc; }
.hidden { display: none !important; }
.customs-manual { background: #131620; padding: 12px; border-radius: 8px; border: 1px solid #2a2d3e; margin-bottom: 14px; }

.results {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  padding: 20px;
  align-content: start;
  overflow-y: auto;
}

.route-card {
  background: #1a1d28;
  border: 1px solid #2a2d3e;
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 0.2s;
}
.route-card.cheapest {
  border-color: #059669;
  box-shadow: 0 0 0 1px #059669;
}
.route-header {
  background: #212436;
  padding: 12px 16px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.03em;
}
.route-body { padding: 16px; }
.route-placeholder { color: #4b5563; font-size: 13px; text-align: center; padding: 20px 0; }

.line-item {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px solid #212436;
  font-size: 13px;
}
.line-item:last-of-type { border-bottom: none; }
.line-label { color: #8892a4; }
.line-value { font-weight: 500; color: #e8eaf0; }
.line-value.zero { color: #4b5563; }

.total-line {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 2px solid #374151;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.total-label { font-size: 13px; color: #8892a4; font-weight: 600; }
.total-value { font-size: 22px; font-weight: 800; color: #fff; }

.cheapest-badge {
  display: inline-block;
  background: #059669;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 6px;
}

.btn-copy {
  margin-top: 12px;
  width: 100%;
  background: #1e293b;
  border: 1px solid #374151;
  color: #94a3b8;
  border-radius: 6px;
  padding: 7px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s;
}
.btn-copy:hover { background: #334155; color: #e2e8f0; }
.btn-copy.copied { background: #064e3b; color: #6ee7b7; border-color: #065f46; }

.no-customs-warning {
  font-size: 11px;
  color: #d97706;
  margin-top: 6px;
  font-style: italic;
}
.customs-auto-note {
  font-size: 11px;
  color: #60a5fa;
  margin-top: -2px;
  margin-bottom: 4px;
  font-style: italic;
  padding-left: 2px;
}

.url-group {
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid #2a2d3e;
}
.url-group input {
  font-size: 11px;
  color: #a0a3b0;
}
.url-status {
  margin-top: 6px;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 6px;
  line-height: 1.4;
}
.url-status.hidden { display: none !important; }
.url-status.loading { color: #6b7280; }
.url-status.url-ok { background: #052e1c; color: #34d399; border: 1px solid #065f46; }
.url-status.url-error { background: #2d1010; color: #f87171; border: 1px solid #7f1d1d; }
.url-status.url-hint  { background: #1c1a08; color: #fbbf24; border: 2px solid #d97706; padding: 10px 12px; }

.price-hint { font-size: 11px; color: #6b7280; font-weight: 400; margin-left: 6px; }
.bookmarklet-link { font-size: 11px; font-weight: 400; color: #2563eb; text-decoration: none; margin-left: 8px; }
.bookmarklet-link:hover { text-decoration: underline; }

/* Переключатель режимов */
.mode-tabs {
  display: flex;
  background: #13151f;
  border-bottom: 1px solid #2a2d3e;
  padding: 0 20px;
}
.mode-tab {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: #8892a4;
  padding: 10px 22px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
}
.mode-tab:hover { color: #e8eaf0; }
.mode-tab.active { color: #60a5fa; border-bottom-color: #2563eb; }

/* EU результаты: 2 колонки */
.results-eu { grid-template-columns: 1fr; max-width: 640px; }
.route-card-wide { width: 100%; }

/* Responsive mobile */
@media (max-width: 700px) {
  main { flex-direction: column; overflow-y: auto; overflow-x: hidden; }
  .car-form { width: 100%; min-width: unset; border-right: none; border-bottom: 1px solid #2a2d3e; }
  .results { grid-template-columns: 1fr; overflow-y: unset; padding: 12px; }
  .results-eu { max-width: 100%; }
  #rates-bar .rates-inner { gap: 8px; }
}

/* Чекбокс BMW */
.checkbox-label {
  display: flex !important;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  font-size: 12px !important;
  color: #e8eaf0 !important;
  line-height: 1.4;
}
.checkbox-label input[type="checkbox"] {
  width: auto;
  min-width: 16px;
  margin-top: 2px;
  accent-color: #2563eb;
  cursor: pointer;
}

/* ── Car specs dropdown (drom.ru autocomplete) ── */
.specs-dropdown {
  position: absolute;
  z-index: 9999;
  background: #1a1d28;
  border: 1px solid #2a2d3e;
  border-radius: 8px;
  padding: 4px 0;
  min-width: 340px;
  max-height: 280px;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  margin-top: 4px;
  scrollbar-width: thin;
  scrollbar-color: #2a2d3e transparent;
}
.specs-dropdown-row {
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
  color: #c8ccd8;
  border-bottom: 1px solid #1e2133;
  line-height: 1.4;
}
.specs-dropdown-row:last-child { border-bottom: none; }
.specs-dropdown-row:hover { background: #252840; }
.specs-dropdown-row b { color: #e8eaf0; }
.specs-dropdown-row small { color: #6b7280; font-size: 12px; }
.specs-badge {
  display: inline-block;
  background: #0d4f2f;
  color: #34d399;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
  margin-left: 4px;
  font-weight: 600;
}
.specs-badge.phev { background: #1e3a5f; color: #60a5fa; }
.specs-badge.mhev { background: #2d3a1e; color: #86efac; }
.specs-badge.ev   { background: #3a1e5f; color: #c084fc; }
#specs-hint {
  font-size: 12px;
  color: #34d399;
  margin-top: 3px;
}
