body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: #f4f5f7;
  color: #1c1e21;
  font-size: 15px;
  line-height: 1.45;
}
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }
header { background: #1f2937; color: #fff; padding: 10px 0; }
header .wrap { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
nav { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
nav a, nav button.link { color: #cbd5e1; text-decoration: none; padding: 6px 10px; border-radius: 6px; background: none; border: 0; font-size: 14px; cursor: pointer; }
nav a.active, nav a:hover, nav button.link:hover { background: #374151; color: #fff; }
main { padding: 20px 16px 48px; }
.card { background: #fff; border: 1px solid #e2e5ea; border-radius: 10px; padding: 16px 18px; margin-bottom: 16px; }
.card h2 { margin: 0 0 12px; font-size: 17px; }
table.kv { width: 100%; border-collapse: collapse; }
table.kv td { padding: 7px 4px; border-bottom: 1px solid #eef0f3; vertical-align: top; }
table.kv td:first-child { color: #6b7280; width: 45%; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px; }
.badge.ok { background: #dcfce7; color: #166534; }
.badge.warn { background: #fef9c3; color: #854d0e; }
.badge.err { background: #fee2e2; color: #991b1b; }
.badge.info { background: #e0e7ff; color: #3730a3; }
.flash { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.error { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-weight: 600; margin-bottom: 4px; }
.field small { display: block; color: #6b7280; margin-top: 3px; }
input[type="text"], input[type="password"], input[type="url"] {
  width: 100%; box-sizing: border-box; padding: 9px 11px; border: 1px solid #cbd2d9; border-radius: 8px; font-size: 15px;
}
button, .btn {
  display: inline-block; background: #2563eb; color: #fff; border: 0; border-radius: 8px;
  padding: 9px 16px; font-size: 15px; cursor: pointer; text-decoration: none;
}
button:hover, .btn:hover { background: #1d4ed8; }
button.secondary { background: #6b7280; }
button.danger { background: #dc2626; }
button.danger:hover { background: #b91c1c; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
form.inline { display: inline; }
ul.stages { list-style: none; padding: 0; margin: 8px 0; }
ul.stages li { padding: 4px 0; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 13px; word-break: break-all; }
table.log { width: 100%; border-collapse: collapse; font-size: 13px; }
table.log th, table.log td { text-align: left; padding: 6px 8px; border-bottom: 1px solid #eef0f3; vertical-align: top; }
table.log th { color: #6b7280; font-weight: 600; }
.muted { color: #6b7280; }
.hint-box { background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; }

.history-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.history-heading a { color: #1d4ed8; }
#history-range, #history-dates { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
#history-dates[hidden] { display: none; }
#history-range label { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
#history-range select, #history-range input { font: inherit; padding: 7px; border: 1px solid #cbd5e1; border-radius: 7px; background: white; color: #1e293b; }
#history-metrics { min-width: 0; margin: 14px 0 0; padding: 8px 0 0; border: 0; border-top: 1px solid #e2e8f0; }
#history-metrics legend { font-weight: 600; padding-right: 7px; }
#history-metrics label { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; margin: 3px 5px 3px 0; border-radius: 6px; border: 1px solid #e2e8f0; }
#history-metrics input { accent-color: var(--metric, #2563eb); }
[data-metric="cabin"] { --metric: #b45309; }
[data-metric="outside"] { --metric: #0369a1; }
[data-metric="battery"] { --metric: #6d28d9; }
[data-metric="coolant"], [data-metric="charge"] { --metric: #047857; }
[data-metric="voltage"] { --metric: #1d4ed8; }
.history-caption, #history-status { margin: 8px 0 0; font-size: 13px; }
.history-chart canvas { display: block; width: 100%; height: 220px; }
.history-chart canvas:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }
.history-readout { border-top: 1px solid #e2e8f0; padding-top: 8px; font-size: 13px; }
.history-readout time { color: #475569; }
.history-readout ul { display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 0; margin: 4px 0 0; list-style: none; }
.history-readout li::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin: 0 5px 2px 0; background: var(--metric); }
.yandex-device-options { border: 0; padding: 0; margin: 0 0 10px; display: flex; flex-wrap: wrap; gap: 6px 14px; }
.yandex-device-options legend { margin-bottom: 6px; }
.yandex-device-options label { display: inline-flex; align-items: center; gap: 5px; }
@media (max-width: 480px) {
  header .wrap { flex-direction: column; align-items: flex-start; }
  table.kv td:first-child { width: 50%; }
}