:root {
  color-scheme: dark;
  --bg: #111318;
  --panel: #1a1f27;
  --panel-2: #222a34;
  --line: #313946;
  --text: #f3f5f7;
  --muted: #9da7b5;
  --accent: #46d0a9;
  --accent-2: #6db8ff;
  --danger: #ff6b6b;
  --warning: #ffd166;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, #161a20 0%, #101217 42%, #0c0e12 100%);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

.login-view,
.dashboard-view {
  display: grid;
  gap: 16px;
}

[hidden] {
  display: none !important;
}

.brand-row,
.topbar,
.section-heading,
.vehicle-switcher,
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-row {
  justify-content: flex-start;
  padding-top: 24px;
}

.app-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(135deg, #222934, #15191f);
  color: var(--accent);
  font-weight: 800;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.73rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.6rem, 1.1rem + 2vw, 2.2rem);
  letter-spacing: 0;
}

h2 {
  font-size: 1rem;
}

.login-panel,
.notice,
.status-panel,
.activity-panel,
.tab-panel,
.vehicle-switcher {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(26, 31, 39, 0.92);
  box-shadow: var(--shadow);
}

.login-panel {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  padding: 16px;
}

label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.token-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

input,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #10141a;
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

input:focus,
select:focus,
button:focus-visible {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(109, 184, 255, 0.18);
}

.primary-button,
.secondary-button,
.control-button,
.icon-button,
.text-button,
.tab {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
}

#demoButton {
  width: 100%;
}

.primary-button,
.secondary-button {
  min-height: 48px;
  font-weight: 800;
}

.primary-button {
  background: var(--accent);
  border-color: var(--accent);
  color: #06120f;
}

.secondary-button,
.control-button,
.icon-button,
.tab {
  background: var(--panel-2);
}

.icon-button {
  min-width: 46px;
  height: 46px;
  padding: 0 10px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.text-button {
  min-height: 38px;
  padding: 0 10px;
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

.notice {
  padding: 14px;
  color: var(--muted);
  line-height: 1.5;
}

.notice strong {
  color: var(--warning);
}

.field-hint {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.topbar {
  padding-top: 4px;
}

.vehicle-switcher {
  display: grid;
  grid-template-columns: auto 1fr auto;
  padding: 10px;
  box-shadow: none;
}

.status-panel {
  position: relative;
  display: grid;
  gap: 16px;
  overflow: hidden;
  padding: 16px;
}

.car-visual {
  position: relative;
  height: 118px;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(109, 184, 255, 0.12), transparent 58%),
    #151a21;
}

.car-body {
  position: absolute;
  left: 11%;
  right: 11%;
  bottom: 24px;
  height: 36px;
  border: 2px solid #d8e1eb;
  border-radius: 42px 42px 18px 18px;
  background: linear-gradient(180deg, #dfe7ee, #8995a2);
}

.car-glass {
  position: absolute;
  left: 29%;
  right: 29%;
  bottom: 53px;
  height: 30px;
  border: 2px solid #d8e1eb;
  border-bottom: 0;
  border-radius: 36px 36px 0 0;
  background: #263341;
}

.car-light {
  position: absolute;
  bottom: 36px;
  width: 20px;
  height: 5px;
  border-radius: 5px;
  background: var(--accent);
}

.car-light.left {
  left: 15%;
}

.car-light.right {
  right: 15%;
}

.battery-ring {
  position: absolute;
  top: 28px;
  right: 28px;
  display: flex;
  align-items: baseline;
  justify-content: center;
  width: 76px;
  height: 76px;
  border: 8px solid rgba(70, 208, 169, 0.22);
  border-top-color: var(--accent);
  border-radius: 50%;
  background: rgba(12, 15, 19, 0.78);
}

.battery-ring span {
  font-size: 1.35rem;
  font-weight: 900;
}

.battery-ring small {
  color: var(--muted);
  font-weight: 800;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.status-grid div {
  min-height: 68px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #141921;
}

.status-grid span,
.setting-row span {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.status-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 1rem;
}

.last-updated {
  color: var(--muted);
  font-size: 0.78rem;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f1319;
}

.tab {
  min-height: 42px;
  color: var(--muted);
  font-weight: 800;
}

.tab.active {
  background: var(--text);
  color: #101318;
}

.tab-panel {
  display: none;
  padding: 14px;
  box-shadow: none;
}

.tab-panel.active {
  display: grid;
  gap: 12px;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.inline-controls {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.inline-controls.compact {
  width: 132px;
}

.control-button {
  min-height: 54px;
  padding: 0 8px;
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 800;
}

.control-button.danger {
  border-color: rgba(255, 107, 107, 0.45);
  color: #ffd5d5;
}

.control-button:disabled,
.primary-button:disabled,
.secondary-button:disabled {
  cursor: wait;
  opacity: 0.58;
}

.range-field {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #141921;
}

input[type="range"] {
  min-height: 28px;
  padding: 0;
  accent-color: var(--accent);
}

.setting-row {
  min-height: 76px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #141921;
}

.activity-panel {
  display: grid;
  gap: 10px;
  padding: 14px;
  box-shadow: none;
}

.activity-log {
  display: grid;
  gap: 8px;
  max-height: 220px;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.activity-log li {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #121720;
  color: var(--muted);
  font-size: 0.8rem;
}

.activity-log strong {
  color: var(--text);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 20;
  width: min(calc(100% - 32px), 480px);
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f3f5f7;
  color: #12151b;
  padding: 12px 14px;
  font-weight: 800;
  box-shadow: var(--shadow);
}

@media (max-width: 380px) {
  .control-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .status-grid {
    grid-template-columns: 1fr;
  }

  .tab {
    font-size: 0.78rem;
  }
}
