/* Same palette as the Android app (Ui.kt / PhoneClimateView). Calm: no animations. */
:root {
  --bg: #071725;
  --card: #213241;
  --card-2: #2e4559;
  --on: #0059a7;
  --on-edge: #7cc4ff;
  --text: #ffffff;
  --muted: #9fb4cc;
  --cold: #4a8dff;
  --hot: #ff6b5e;
  --green: #3ddc84;
  --amber: #f2c46b;
  --orange: #ff9f43;
  --red: #ff5a4a;
  --radius: 12px;
  --gutter: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
button:active { opacity: .6; }
[hidden] { display: none !important; }
.sprite { position: absolute; }
svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--on-edge); outline-offset: 2px; }

/* ---------------------------------------------------------------- header */
.top {
  display: flex; align-items: center; gap: 8px;
  max-width: 980px; margin: 0 auto; padding: 8px var(--gutter);
}
.link { width: 48px; height: 48px; display: grid; place-items: center; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: var(--red); flex: none; }
.dot.green { background: var(--green); }
.dot.amber { background: var(--amber); }
.dot.orange { background: var(--orange); }
.brand { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 700; font-size: 16px; }
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand img { flex: none; }
.actions { display: flex; }
.icon { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%; }
.icon.sm svg { width: 18px; height: 18px; }

main { max-width: 980px; margin: 0 auto; padding: 0 var(--gutter) 32px; }
.body.off { opacity: .45; }

/* ---------------------------------------------------------------- climate */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 6px; }
.tile {
  height: 76px; border-radius: var(--radius); background: var(--card-2);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  font-weight: 700; font-size: 12.5px; border: 1.5px solid transparent;
}
.tile svg { opacity: .82; }
.tile.on { background: var(--on); border-color: var(--on-edge); }
.tile.on svg { opacity: 1; }
.tile.wide { grid-column: 1 / -1; height: 56px; flex-direction: row; gap: 10px; font-size: 14px; }

.seats { display: grid; gap: 12px; margin-top: 14px; }
.seat { background: var(--card); border-radius: 14px; padding: 12px 14px 14px; }
.seat-head { display: flex; align-items: center; gap: 8px; }
.seat-head > div { flex: 1; }
.seat h2 { margin: 0; font-size: 17px; }
.sub { margin: 0; color: var(--muted); font-size: 12px; }
.sub:empty { display: none; }
.lbl { color: var(--muted); font-size: 12px; }
.pill { width: 48px; height: 40px; border-radius: var(--radius); background: var(--bg); font-weight: 700; font-size: 17px; border: 1.5px solid transparent; }
.pill.on { background: var(--on); border-color: var(--on-edge); }

.temp { display: flex; align-items: center; margin-top: 10px; }
.round { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; border: 2px solid currentColor; flex: none; user-select: none; -webkit-user-select: none; }
.round.down { color: var(--cold); }
.round.up { color: var(--hot); }
.round svg { width: 24px; height: 24px; stroke-width: 2.2; }
.temp-val { flex: 1; text-align: center; font-size: 40px; font-weight: 700; font-variant-numeric: tabular-nums; }

.fan-lbl { margin: 12px 0 4px; font-size: 13px; }
.fan { display: flex; align-items: center; gap: 6px; }
.fan .icon { width: 44px; height: 44px; }
.bars { flex: 1; height: 40px; display: flex; align-items: flex-end; gap: 4px; cursor: pointer; touch-action: manipulation; }
.bars i { flex: 1; border-radius: 3px; background: var(--card-2); border: 1px solid transparent; }
.bars i.on { background: var(--on); border-color: var(--on-edge); }

.vents { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.vents .tile { height: 64px; }

@media (min-width: 760px) {
  .seats { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 980px) {
  #climate-body { display: grid; grid-template-columns: 360px 1fr; gap: 16px; align-items: start; }
  .seats { margin-top: 6px; }
}

/* ---------------------------------------------------------------- pages */
.page-head { display: flex; align-items: center; gap: 4px; margin: 0 0 4px -12px; }
.page-head h1 { font-size: 20px; margin: 0; flex: 1; }
h3 { font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; margin: 22px 0 8px; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
code { font-size: 12.5px; background: var(--card); padding: 1px 5px; border-radius: 4px; }

.rows { display: grid; gap: 6px; }
@media (min-width: 760px) { .rows { grid-template-columns: 1fr 1fr; column-gap: 24px; } }
.row { display: flex; align-items: center; gap: 12px; min-height: 48px; }
.row > span { flex: 1; font-weight: 700; font-size: 14px; }
.row .ctl { width: 45%; max-width: 220px; display: flex; gap: 6px; }

.btn {
  min-height: 44px; padding: 0 16px; border-radius: 8px; background: var(--card);
  font-weight: 700; font-size: 14px; flex: 1; white-space: nowrap;
}
.btn.on { background: var(--on); }

.cmd { display: flex; gap: 8px; align-items: center; }
.cmd input, .fields input:not([type=checkbox]) {
  flex: 1; min-width: 0; height: 44px; padding: 0 12px; border-radius: 8px;
  background: var(--card); border: 1px solid transparent; outline: none;
}
.cmd input:focus, .fields input:focus { border-color: var(--on); }
.cmd .btn { flex: none; }

.fields { display: grid; gap: 10px; }
.fields label { display: grid; gap: 4px; color: var(--muted); font-size: 13px; }
.fields label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }
.fields input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--on); }
.qr-row { display: flex; gap: 8px; flex-wrap: wrap; }
#scan-video { width: 100%; max-width: 420px; border-radius: var(--radius); margin-top: 10px; background: #000; }
#qr-form { margin-top: 10px; }

.status-card { display: flex; align-items: center; gap: 10px; background: var(--card); border-radius: var(--radius); padding: 14px; margin-top: 8px; }

.log { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.log li { background: var(--card); border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.log li b { display: block; color: var(--muted); font-weight: 600; font-size: 12px; }
.log:empty::after { content: "Chưa có lệnh nào."; color: var(--muted); font-size: 13px; }

/* ---------------------------------------------------------------- message bar (like BottomAlert) */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(18px + env(safe-area-inset-bottom));
  max-width: calc(100% - 32px); padding: 10px 22px; border-radius: 22px;
  background: rgba(10, 26, 51, .95); border: 1.5px solid #2f7dff; text-align: center; z-index: 10;
}

/* ---------------------------------------------------------------- Android (head unit) controls, like HeadUnitActivity */
#view-android { padding-bottom: 84px; }
.hu { display: grid; gap: 12px; align-content: start; }
/* wide screens: two balanced columns (cards keep their own height, no holes between rows) */
@media (min-width: 760px) {
  .hu { display: block; column-count: 2; column-gap: 12px; }
  .hu > * { break-inside: avoid; margin: 0 0 12px; }
  .hu > .hu-hint.pad, .hu > :only-child { column-span: all; }
}
.hu-card { background: #12233a; border-radius: 20px; padding: 16px 18px 18px; display: grid; gap: 10px; }
.hu-card-head { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.hu-card-head > span:first-child { flex: 1; color: #8aa3c0; font-size: 15px; }
.hu-row { display: flex; align-items: center; gap: 12px; }
.hu-row.start > div { min-width: 0; }
.hu-row.center { justify-content: center; }
.hu-row.media { gap: 28px; margin-top: 10px; }
.hu-big { flex: 1; text-align: center; font-size: 64px; font-weight: 300; line-height: 1.1; font-variant-numeric: tabular-nums; }
.hu-big.left { text-align: left; }
.hu-title { font-size: 20px; overflow-wrap: anywhere; }
.hu-title.good { color: #6fe0a8; }
.hu-sub { color: #8aa3c0; font-size: 13px; }
.hu-sub.center { text-align: center; margin: 0; }
.hu-hint { color: #6f8db3; font-size: 13px; margin: 2px 0 0; }
.hu-hint.pad { padding: 0 6px; }
.hu-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 46px; font-size: 16px; }

.hu-pill {
  min-height: 52px; border-radius: 999px; background: #182c48; border: 1.5px solid #2a4a7c;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 16px; font-size: 16px;
}
.hu-pill svg { width: 22px; height: 22px; }
.hu-pill.small { min-height: 40px; font-size: 13.5px; padding: 0 12px; }
.hu-pill.small svg { width: 18px; height: 18px; }
.hu-pill.wide { width: 100%; }
.hu-pill.on { background: #0f4c8f; border-color: #3b9bff; }
.hu-chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.hu-chips .hu-pill { min-height: 44px; padding: 0 6px; }

.hu-round { width: 56px; height: 56px; flex: none; border-radius: 50%; background: #182c48; border: 1.5px solid #2a4a7c; display: grid; place-items: center; }
.hu-round svg { width: 24px; height: 24px; stroke-width: 2; }
.hu-round.big { width: 76px; height: 76px; }
.hu-round.big svg { width: 30px; height: 30px; }
.hu-round.on { background: #0f4c8f; border-color: #3b9bff; }
.hu-badge { width: 56px; height: 56px; flex: none; border-radius: 50%; background: rgba(47,125,255,.16); color: #8fc3ff; display: grid; place-items: center; }
.hu-badge svg { width: 28px; height: 28px; }

.hu-switch { width: 60px; height: 34px; border-radius: 17px; background: #1a3058; position: relative; flex: none; }
.hu-switch::after { content: ""; position: absolute; top: 4px; left: 4px; width: 26px; height: 26px; border-radius: 50%; background: #9db3cf; }
.hu-switch[aria-checked="true"] { background: #2f7dff; }
.hu-switch[aria-checked="true"]::after { left: 30px; background: #fff; }

.hu-range { width: 100%; height: 44px; accent-color: #3b9bff; margin: 0; }
.hu-range.vertical { writing-mode: vertical-lr; direction: rtl; width: 44px; height: 190px; }
.hu-eq { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 6px; }
.hu-eq > div { display: grid; justify-items: center; gap: 6px; }

.hu-pad {
  position: relative; width: 240px; height: 240px; justify-self: center; border-radius: 16px;
  background: #0b1f40; border: 1.5px solid #1d3a68; touch-action: none; cursor: crosshair;
  background-image: linear-gradient(#1d3a68, #1d3a68), linear-gradient(#1d3a68, #1d3a68);
  background-size: 100% 1.5px, 1.5px 100%; background-position: center; background-repeat: no-repeat;
}
.hu-pad .car { position: absolute; left: 30%; right: 30%; top: 14%; bottom: 14%; border: 2px solid #2c4f86; border-radius: 38px; pointer-events: none; }
.hu-pad span { position: absolute; color: #5f7ea6; font-size: 11px; pointer-events: none; }
.hu-pad .f { top: 3px; left: 50%; transform: translateX(-50%); }
.hu-pad .b { bottom: 3px; left: 50%; transform: translateX(-50%); }
.hu-pad .l { left: 6px; top: 50%; transform: translateY(-120%); }
.hu-pad .r { right: 6px; top: 50%; transform: translateY(-120%); }
.hu-knob { position: absolute; width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%; background: #3b9bff; box-shadow: 0 0 0 7px rgba(47,125,255,.25); pointer-events: none; }

.hu-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hu-tile { background: #1b3350; border-radius: 14px; padding: 10px 10px 10px 14px; display: grid; gap: 2px; }

.hu-tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; justify-content: center;
  background: #04101f; padding: 6px 4px calc(10px + env(safe-area-inset-bottom));
}
.hu-tabs button { flex: 1; max-width: 140px; height: 58px; display: grid; justify-items: center; align-content: center; gap: 4px; color: #8aa3c0; font-size: 11.5px; }
.hu-tabs button svg { width: 56px; height: 30px; padding: 4px 17px; border-radius: 15px; }
.hu-tabs button.on { color: #fff; }
.hu-tabs button.on svg { background: rgba(47,125,255,.25); }
