/* BYD Monitor — tema escuro premium (estilo app de carro elétrico) */

:root {
  color-scheme: dark;
  --bg: #070b14;
  --line: rgba(148, 163, 184, .14);
  --line-strong: rgba(148, 163, 184, .26);
  --ink: #eef2f8;
  --muted: #8fa0b8;
  --accent: #2dd4bf;
  --accent-2: #38bdf8;
  --radius: 18px;
  --shadow: 0 12px 32px rgba(2, 6, 23, .5);
}

* { box-sizing: border-box; }

[x-cloak] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(640px 320px at 12% -6%, rgba(45, 212, 191, .13), transparent 70%),
    radial-gradient(720px 360px at 92% -4%, rgba(56, 189, 248, .10), transparent 70%);
}

::selection { background: rgba(45, 212, 191, .35); }

main { max-width: 1060px; margin: 0 auto; padding: 14px 14px 40px; }

:focus-visible { outline: 2px solid rgba(45, 212, 191, .65); outline-offset: 2px; }

/* --- topo ---------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(7, 11, 20, .78);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 650; letter-spacing: .2px; }
.brand svg { color: var(--accent); filter: drop-shadow(0 0 9px rgba(45, 212, 191, .55)); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .7px;
  padding: 5px 11px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}
.badge-mock { background: rgba(251, 191, 36, .13); color: #fcd34d; border: 1px solid rgba(251, 191, 36, .25); }
.badge-real { background: rgba(52, 211, 153, .12); color: #6ee7b7; border: 1px solid rgba(52, 211, 153, .25); }

/* --- chave de acesso ------------------------------------------------ */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(4, 7, 14, .66);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.keycard {
  width: 100%;
  max-width: 390px;
  background: linear-gradient(180deg, #101a2f, #0c1322);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 24px 60px rgba(2, 6, 23, .7);
}
.keycard h2 { margin: 0 0 8px; font-size: 18px; }
.keycard p { margin: 0 0 14px; color: var(--muted); font-size: 13.5px; }
.keycard code { background: rgba(148, 163, 184, .12); padding: 2px 6px; border-radius: 6px; font-size: 12.5px; color: #cbd5e1; }
.keycard input {
  width: 100%;
  padding: 12px 13px;
  margin-bottom: 12px;
  background: rgba(7, 11, 20, .7);
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  color: var(--ink);
  font: inherit;
}
.keycard input::placeholder { color: #5b6b85; }
.keycard input:focus {
  outline: none;
  border-color: rgba(45, 212, 191, .55);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, .15);
}

/* --- erros e botões ------------------------------------------------- */

.error {
  margin: 12px 0;
  padding: 11px 15px;
  border-radius: 12px;
  background: rgba(248, 113, 113, .1);
  border: 1px solid rgba(248, 113, 113, .25);
  color: #fca5a5;
  font-size: 13.5px;
}

.btn {
  font: inherit;
  font-weight: 600;
  padding: 9px 14px;
  border-radius: 11px;
  border: 1px solid var(--line-strong);
  background: rgba(148, 163, 184, .08);
  color: var(--ink);
  cursor: pointer;
  min-height: 42px;
  transition: border-color .15s ease, color .15s ease, background .15s ease,
              box-shadow .15s ease, filter .15s ease, transform .08s ease;
}
.btn:hover:not(:disabled) { border-color: rgba(45, 212, 191, .55); color: #5eead4; background: rgba(45, 212, 191, .08); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, #14b8a6, #0ea5e9);
  border: none;
  color: #fff;
  width: 100%;
  box-shadow: 0 8px 22px rgba(20, 184, 166, .35);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #14b8a6, #0ea5e9);
  color: #fff;
  filter: brightness(1.08);
}
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover:not(:disabled) { color: #5eead4; background: rgba(45, 212, 191, .08); }
.btn-seg { padding: 6px 13px; min-height: 34px; font-size: 13px; border-radius: 999px; background: rgba(148, 163, 184, .08); }
.btn-seg.active {
  background: linear-gradient(135deg, #14b8a6, #0ea5e9);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 14px rgba(20, 184, 166, .35);
}
.btn-seg.active:hover:not(:disabled) {
  background: linear-gradient(135deg, #14b8a6, #0ea5e9);
  color: #fff;
}

/* --- cards dos veículos --------------------------------------------- */

.grid { display: grid; gap: 14px; grid-template-columns: 1fr; margin-top: 16px; }

.card {
  background: linear-gradient(180deg, #0e1627, #0b1220);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
@media (hover: hover) {
  .card { transition: transform .18s ease, border-color .18s ease; }
  .card:hover { transform: translateY(-2px); border-color: var(--line-strong); }
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.card-head h2 { margin: 0; font-size: 19px; letter-spacing: .2px; }
.plate { color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: 1.2px; font-variant-numeric: tabular-nums; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 650;
  padding: 5px 11px;
  border-radius: 999px;
  white-space: nowrap;
}
.chip::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}
.chip-charge { background: rgba(56, 189, 248, .13); color: #7dd3fc; border: 1px solid rgba(56, 189, 248, .22); }
.chip-drive { background: rgba(251, 191, 36, .13); color: #fcd34d; border: 1px solid rgba(251, 191, 36, .22); }
.chip-idle { background: rgba(148, 163, 184, .1); color: #b6c2d6; border: 1px solid rgba(148, 163, 184, .18); }

.metric { margin-bottom: 14px; }
.metric-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 7px; }
.metric-head span { color: var(--muted); font-size: 13px; }
.metric-head strong {
  font-size: 26px;
  font-weight: 750;
  letter-spacing: -.5px;
  font-variant-numeric: tabular-nums;
}
.soc-ok { color: #34d399; }
.soc-mid { color: #fbbf24; }
.soc-low { color: #f87171; }

.bar { height: 11px; border-radius: 999px; background: rgba(148, 163, 184, .12); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; transition: width .6s cubic-bezier(.22, .61, .36, 1); }
.bar-ok { background: linear-gradient(90deg, #10b981, #34d399); box-shadow: 0 0 12px rgba(52, 211, 153, .5); }
.bar-mid { background: linear-gradient(90deg, #f59e0b, #fbbf24); box-shadow: 0 0 12px rgba(251, 191, 36, .45); }
.bar-low { background: linear-gradient(90deg, #dc2626, #f87171); box-shadow: 0 0 12px rgba(248, 113, 113, .5); }
.bar-fuel { background: linear-gradient(90deg, #f59e0b, #fbbf24); box-shadow: 0 0 12px rgba(251, 191, 36, .4); }

.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin-top: 14px; font-size: 13.5px; }
.facts .k {
  display: block;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: .9px;
  text-transform: uppercase;
  margin-bottom: 2px;
}
.facts span:not(.k) { font-variant-numeric: tabular-nums; }
.facts-details { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }
.warn { color: #fbbf24; font-weight: 650; }

.muted { color: var(--muted); font-size: 13px; }

/* --- painéis (mapa, gráficos, comandos) ------------------------------ */

.panel {
  background: linear-gradient(180deg, #0e1627, #0b1220);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-top: 14px;
  box-shadow: var(--shadow);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.panel-head h3 { display: flex; align-items: center; gap: 9px; margin: 0; font-size: 16px; letter-spacing: .2px; }
.panel-head h3::before {
  content: "";
  width: 4px;
  height: 15px;
  border-radius: 999px;
  background: linear-gradient(180deg, #2dd4bf, #0ea5e9);
  box-shadow: 0 0 10px rgba(45, 212, 191, .5);
}
.segments { display: flex; gap: 6px; }

#map { height: 340px; border-radius: 13px; z-index: 1; border: 1px solid var(--line); }

/* Leaflet no escuro */
.leaflet-container { background: #0a101d; }
.leaflet-tile { filter: brightness(.78) saturate(.85); }
.leaflet-bar { border: 1px solid var(--line-strong) !important; box-shadow: 0 8px 20px rgba(2, 6, 23, .5) !important; }
.leaflet-bar a { background: #101a2f !important; color: #cbd5e1 !important; border-bottom: 1px solid var(--line) !important; }
.leaflet-bar a:hover { background: #16223b !important; color: #5eead4 !important; }
.leaflet-control-attribution { background: rgba(7, 11, 20, .75) !important; color: #64748b !important; }
.leaflet-control-attribution a { color: #94a3b8 !important; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: #101a2f;
  color: var(--ink);
  box-shadow: 0 12px 30px rgba(2, 6, 23, .6);
}
.leaflet-popup-content { margin: 12px 14px; font: inherit; }
.leaflet-container a.leaflet-popup-close-button { color: #94a3b8; }

.car-pin-wrap { background: none; border: none; }
.car-pin {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  border: 2px solid rgba(255, 255, 255, .9);
  box-shadow: 0 2px 10px rgba(2, 6, 23, .6);
}

.chart-wrap { margin-bottom: 10px; }
.chart-title { display: flex; align-items: center; gap: 7px; font-weight: 600; font-size: 14px; margin: 10px 0 6px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.chart-wrap canvas { width: 100% !important; height: 220px !important; }

.cmds { display: grid; gap: 14px; grid-template-columns: 1fr; }
.cmd-block {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: rgba(148, 163, 184, .04);
}
.cmd-title { font-weight: 650; margin-bottom: 10px; }
.cmd-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.cmd-result { margin: 10px 0 0; min-height: 18px; font-size: 13px; }

.foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 20px; color: var(--muted); font-size: 13px; flex-wrap: wrap; }

/* --- telas maiores --------------------------------------------------- */

@media (min-width: 720px) {
  main { padding: 22px 20px 50px; }
  .grid.cols-2, .cmds.cols-2 { grid-template-columns: 1fr 1fr; }
  .grid.cols-1 { grid-template-columns: 1fr; }
  #map { height: 400px; }
}
