:root {
  color-scheme: dark;
  --bg: #0d131b;
  --panel: #17212d;
  --panel2: #1d2a39;
  --line: #2b3b4e;
  --muted: #9aabba;
  --text: #f4f7fb;
  --accent: #9bd1ff;
  --warning: #f2c879;
  --green: #73d6a2;
  --red: #f08d8d;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  min-height: 100vh;
  margin: 0;
  padding: env(safe-area-inset-top) 15px env(safe-area-inset-bottom);
  background: radial-gradient(ellipse at 50% -18%, #263d55 0, var(--bg) 57%);
  color: var(--text);
  font: 16px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.shell { max-width: 760px; margin: 0 auto; padding: 20px 0 34px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 8px 2px 20px; }
.eyebrow, .section-kicker { color: var(--accent); font-size: 10px; font-weight: 850; letter-spacing: 1.9px; }
.topbar h1 { margin: 5px 0 2px; font-size: 29px; letter-spacing: -.7px; }
.subtitle { margin: 0; color: var(--muted); font-size: 12px; }
.server-badge { display: flex; align-items: center; gap: 7px; white-space: nowrap; color: var(--muted); font-size: 11px; }
#server-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warning); box-shadow: 0 0 0 4px #f2c87918; }
#server-dot.online { background: var(--green); box-shadow: 0 0 0 4px #73d6a21a; }
#server-dot.offline { background: var(--red); box-shadow: 0 0 0 4px #f08d8d1a; }
.notice { display: flex; gap: 12px; margin-bottom: 13px; padding: 14px; border: 1px solid #6c572e; border-radius: 17px; background: #2b251a; }
.notice.notice-info { border-color: #3a5977; background: #1a2938; }
.notice.notice-info .notice-icon { background: #294762; color: #b7dcff; }
.notice.notice-info b { color: #b7dcff; }
.notice.notice-info p { color: #d4e4f2; }
.notice.notice-success { border-color: #346b51; background: #16271f; }
.notice.notice-success .notice-icon { background: #28583f; color: #a7e7c2; }
.notice.notice-success b { color: #b7f0cd; }
.notice.notice-success p { color: #d2e8db; }
.notice-icon { display: grid; flex: 0 0 26px; width: 26px; height: 26px; place-items: center; border-radius: 50%; background: #574322; color: #ffdc9b; font-weight: 900; }
.notice b { color: #ffdc9b; font-size: 13px; }
.notice p { margin: 5px 0 0; color: #e3d6bd; font-size: 12px; line-height: 1.5; }
.vehicle-card { display: flex; align-items: center; gap: 13px; padding: 14px; border: 1px solid var(--line); border-radius: 18px; background: linear-gradient(130deg, #1d2b3a, #17212d); }
.vehicle-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: -2px 0 8px; }
.vehicle-actions button { flex: 1 1 180px; }
.vehicle-mark { display: grid; width: 52px; height: 52px; place-items: center; border-radius: 15px; background: #2a4057; color: var(--accent); font-weight: 950; letter-spacing: 1px; }
.vehicle-copy { display: flex; flex-direction: column; gap: 4px; }
.vehicle-copy b { font-size: 15px; }
.vehicle-copy span { color: var(--muted); font-size: 11px; }
.pill { margin-left: auto; padding: 5px 9px; border: 1px solid; border-radius: 30px; font-size: 9px; font-weight: 900; letter-spacing: .7px; }
.pill.offline { border-color: #704747; color: #ffaaaa; }
.pill.online { border-color: #346b51; color: #9be2ba; }
.pill.paired { border-color: #7a6237; color: #f2d18f; }
.tabs { display: flex; gap: 7px; overflow-x: auto; padding: 17px 0 13px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { padding: 9px 13px; border: 1px solid var(--line); border-radius: 30px; background: #17212d; color: var(--muted); font-size: 12px; font-weight: 700; white-space: nowrap; }
.tab.active { border-color: #dcefff; background: #dcefff; color: #142638; }
.panel { display: none; }
.panel.active { display: block; }
.panel-heading { margin: 6px 2px 13px; }
.panel-heading h2 { margin: 4px 0 0; font-size: 20px; letter-spacing: -.3px; }
.tile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tile { display: flex; min-height: 124px; flex-direction: column; align-items: flex-start; gap: 8px; padding: 15px; border: 1px solid var(--line); border-radius: 17px; background: var(--panel); color: var(--text); text-align: left; }
.tile:disabled { opacity: .68; cursor: not-allowed; }
.tile-icon { font-size: 23px; line-height: 1; }
.tile b { font-size: 13px; line-height: 1.3; }
.tile small { color: var(--muted); font-size: 10px; line-height: 1.35; }
.tile.wide { min-height: 94px; grid-column: 1 / -1; }
.diagnostic-card { padding: 3px 14px; border: 1px solid var(--line); border-radius: 17px; background: var(--panel); }
.diagnostic-row { display: flex; justify-content: space-between; gap: 12px; padding: 13px 0; border-bottom: 1px solid #2a3949; font-size: 12px; }
.diagnostic-row:last-child { border-bottom: 0; }
.diagnostic-row span { color: var(--muted); }
.diagnostic-row b { font-size: 11px; text-align: right; }
.diagnostic-actions { display: flex; gap: 8px; margin-top: 12px; }
.secondary-button, .primary-button { padding: 11px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel2); color: var(--text); font-size: 12px; font-weight: 750; }
.secondary-button:disabled { opacity: .5; }
.primary-button { width: 100%; margin-top: 12px; border-color: #dcefff; background: #dcefff; color: #142638; }
.diagnostic-note { margin: 12px 3px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.protocol-inventory { margin-top: 14px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 15px; background: #111b26; }
.protocol-inventory summary { color: var(--text); font-size: 12px; font-weight: 750; cursor: pointer; }
.protocol-inventory p { color: var(--muted); font-size: 10px; line-height: 1.5; }
.protocol-inventory ul { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 12px; margin: 10px 0 0; padding-left: 17px; color: var(--muted); font: 10px ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }
.install-help { margin-top: 18px; padding: 14px; border: 1px solid var(--line); border-radius: 15px; background: #111b26; }
.install-help b { font-size: 13px; }
.install-help ol { margin: 9px 0; padding-left: 20px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.install-help small { color: var(--muted); font-size: 10px; }
.auth-panel { margin: 12px 0 18px; padding: 17px; border: 1px solid #45617c; border-radius: 18px; background: #182635; }
.auth-panel h2 { margin: 5px 0; font-size: 19px; }
.auth-panel p { color: var(--muted); font-size: 12px; line-height: 1.5; }
.auth-panel label { display: block; margin: 12px 0 6px; color: var(--muted); font-size: 11px; }
.auth-panel input { width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 11px; background: #0f1822; color: var(--text); font-size: 14px; }
.error-text { min-height: 15px; color: #ffaaaa !important; }
.hidden { display: none !important; }
.locked { opacity: .42; pointer-events: none; filter: grayscale(.4); }
footer { margin: 25px 3px 0; color: #77889a; font-size: 10px; line-height: 1.55; }
@media (min-width: 560px) { .tile-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } .tile.wide { grid-column: span 2; } }
@media (max-width: 390px) { .topbar h1 { font-size: 25px; } .server-badge { font-size: 10px; } .tab { padding: 8px 11px; } .tile { padding: 12px; } }

.pairing-card { padding: 15px; border: 1px solid var(--line); border-radius: 17px; background: var(--panel); }
.pairing-step { display: flex; gap: 11px; margin: 3px 0 16px; }
.step-number { display: grid; flex: 0 0 27px; width: 27px; height: 27px; place-items: center; border: 1px solid #45617c; border-radius: 50%; background: #203246; color: var(--accent); font-size: 12px; font-weight: 850; }
.pairing-step b { display: block; font-size: 13px; }
.pairing-step p { margin: 4px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.pairing-actions { display: grid; grid-template-columns: 1fr; gap: 9px; margin: 14px 0; }
.pairing-actions .primary-button { display: block; width: 100%; margin: 0; text-align: center; cursor: pointer; }
.pairing-actions .secondary-button { width: 100%; margin: 0; }
.file-button { display: block; text-align: center; cursor: pointer; }
.qr-reader { width: 100%; min-height: 120px; margin: 12px 0; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: #080d13; }
.qr-reader video { width: 100% !important; max-height: 360px; object-fit: cover; border-radius: 12px; }
#qr-stop-button { width: 100%; margin: 0 0 10px; }
.pairing-status { min-height: 18px; margin: 9px 0; color: var(--muted); font-size: 11px; line-height: 1.5; overflow-wrap: anywhere; }
.manual-qr { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.manual-qr summary { color: var(--muted); font-size: 12px; font-weight: 700; cursor: pointer; }
.manual-qr label { display: block; margin: 10px 0 6px; color: var(--muted); font-size: 11px; }
.manual-qr textarea { width: 100%; resize: vertical; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: #0f1822; color: var(--text); font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }
.manual-qr button { width: 100%; margin-top: 8px; }
.qr-result { margin-top: 14px; padding: 13px; border: 1px solid #356c52; border-radius: 14px; background: #14271f; }
.qr-result-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.result-check { display: grid; width: 28px; height: 28px; place-items: center; border-radius: 50%; background: #28583f; color: #a7e7c2; font-weight: 900; }
.qr-result-heading b, .qr-result-heading small { display: block; }
.qr-result-heading b { color: #b7f0cd; font-size: 13px; }
.qr-result-heading small { margin-top: 3px; color: #9ab9a7; font-size: 10px; }
.qr-result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.qr-result-grid div { min-width: 0; padding: 9px; border: 1px solid #315541; border-radius: 10px; background: #102019; }
.qr-result-grid small, .qr-result-grid b { display: block; }
.qr-result-grid small { margin-bottom: 5px; color: #9ab9a7; font-size: 9px; }
.qr-result-grid b { color: #e8fff0; font-size: 11px; overflow-wrap: anywhere; }
.qr-result #qr-clear-button { width: 100%; margin-top: 8px; border-color: #315541; background: #1d382b; }
.qr-result #qr-pair-button { width: 100%; margin-top: 12px; }
.pairing-warning { margin-top: 12px; padding: 13px 14px; border: 1px solid #6c572e; border-radius: 15px; background: #2b251a; }
.pairing-warning b { color: #ffdc9b; font-size: 12px; }
.pairing-warning p { margin: 6px 0 0; color: #e3d6bd; font-size: 10px; line-height: 1.55; }
.pairing-warning code { color: #ffdc9b; }
@media (min-width: 560px) { .pairing-actions { grid-template-columns: 1fr 1fr; } }

.qr-result-copy { min-width: 0; flex: 1; }
.qr-result-actions, .vehicle-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.vehicle-card { display: grid; gap: 12px; }
.vehicle-details { font-size: 13px; overflow-wrap: anywhere; }
.vehicle-actions { justify-content: flex-start; }
.danger-button { border-color: rgba(210, 70, 70, .45); color: #ffaaaa; }
.live-control-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.live-control-card { min-width: 0; border: 1px solid var(--border, #d9dee7); border-radius: 14px; padding: 12px; background: var(--surface, #fff); display: grid; gap: 9px; }
.live-control-title { font-weight: 650; font-size: 14px; }
.live-control-value { color: var(--muted, #667085); font-size: 13px; }
.live-control-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.live-control-actions button { min-height: 36px; }
.live-control-actions input[type="range"] { flex: 1; min-width: 90px; }
.live-control-actions input[type="number"], .live-control-actions select { min-width: 92px; max-width: 140px; min-height: 36px; border: 1px solid var(--border, #d9dee7); border-radius: 9px; padding: 6px 8px; background: var(--surface, #fff); color: inherit; }
.live-control-card button { cursor: pointer; }
.live-control-card button:disabled, .live-control-actions input:disabled, .live-control-actions select:disabled { opacity: .5; cursor: not-allowed; }
.telemetry-grid .live-control-card { background: var(--surface-muted, #f8fafc); }
@media (max-width: 520px) {
  .qr-result { align-items: stretch; flex-direction: column; }
  .qr-result-actions { width: 100%; }
  .qr-result-actions button { flex: 1; }
  .live-control-grid { grid-template-columns: 1fr; }
}
.vehicle-details { white-space: pre-line; }

/* v0.7.0: live DzB controls, enabled strictly from authenticated Welcome. */
.panel-intro { margin: 0 2px 14px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.live-control-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 270px), 1fr)); gap: 12px; }
.live-control-card {
  display: flex; flex-direction: column; min-width: 0; gap: 8px; padding: 15px;
  border: 1px solid #344558; border-radius: 17px;
  background: linear-gradient(140deg, #1c2938, #16212e);
  color: #eef6ff;
}
.live-control-card.not-available { opacity: .63; }
.live-control-card.advertised { border-color: #3a6e5c; }
.control-heading { display: flex; align-items: center; gap: 10px; }
.control-emoji { font-size: 23px; width: 32px; text-align: center; }
.live-control-title { font-size: 14px; line-height: 1.3; }
.wire-label { color: #7893a9; font: 10px ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }
.live-control-value { font-size: 12px; color: #bed4e5; }
.live-control-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 3px; }
.live-control-actions button, .live-control-actions select, .live-control-actions input {
  min-width: 0; min-height: 43px; border: 1px solid #4d6680; border-radius: 10px;
  background: #102033; color: #edf5fd; font-size: 13px;
}
.live-control-actions button { padding: 10px 12px; font-weight: 750; flex: 1; cursor: pointer; }
.live-control-actions .on-button { border-color: #538b73; }
.live-control-actions .off-button { border-color: #52718d; }
.live-control-actions .sensitive-button { border-color: #ac7852; }
.live-control-actions .selected-value { background: #2a5342; box-shadow: inset 0 0 0 1px #79caaa; }
.live-control-actions input, .live-control-actions select { flex: 1 1 120px; padding: 8px 11px; }
.live-control-actions button:disabled, .live-control-actions input:disabled, .live-control-actions select:disabled { opacity: .44; cursor: not-allowed; }
.control-note { color: #91a7bb; font-size: 11px; line-height: 1.45; }
.control-result { display: block; min-height: 14px; color: #c1e0f6; font-size: 11px; line-height: 1.45; overflow-wrap: anywhere; }
.control-result.result-ok { color: #91e2ae; }
.control-result.result-warning { color: #f5d490; }
.control-result.result-error { color: #ff9f9f; }
.command-feedback { padding: 13px 15px; margin: 4px 0 10px; border: 1px solid #426b62; border-radius: 14px; background: #1b312a; font-size: 12px; line-height: 1.5; color: #b5ebd2; overflow-wrap: anywhere; }
.command-feedback.is-error { border-color: #8b5353; background: #322125; color: #ffa8a8; }
.control-help { margin-top: 12px; padding: 13px 15px; border: 1px solid #4c5265; border-radius: 14px; background: #20232f; }
.control-help b { font-size: 13px; }
.control-help p { margin: 5px 0 0; color: #b4c3d1; font-size: 11px; line-height: 1.5; }
.telemetry-panel { margin-top: 20px; }
.telemetry-panel h3 { margin: 10px 0; font-size: 15px; }
.telemetry-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.telemetry-item { display: grid; gap: 4px; padding: 12px; border: 1px solid #344558; border-radius: 12px; background: #172433; }
.telemetry-item span { font-size: 11px; color: #a4b9ce; }
.telemetry-item b { font-size: 14px; }
@media (max-width: 520px) { .live-control-grid { grid-template-columns: 1fr; } }
.live-control-actions input[type="number"], .live-control-actions select { background: #102033; color: #edf5fd; border-color: #4d6680; }
