:root {
  color-scheme: dark;
  --bg: #07101d;
  --bg-deep: #040912;
  --surface: rgba(18, 32, 50, .72);
  --surface-strong: rgba(23, 40, 61, .9);
  --surface-soft: rgba(255, 255, 255, .055);
  --line: rgba(255, 255, 255, .11);
  --line-strong: rgba(255, 255, 255, .18);
  --text: #f7faff;
  --muted: #9baabd;
  --subtle: #6d7d91;
  --green: #63e6ad;
  --green-deep: #123d32;
  --blue: #74a8ff;
  --cyan: #67d9e8;
  --orange: #ffb36b;
  --red: #ff858e;
  --purple: #c39aff;
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 17px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Display",
    "SF Pro Text", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg-deep); }

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 12% -8%, rgba(62, 123, 255, .2), transparent 34rem),
    radial-gradient(circle at 92% 12%, rgba(92, 230, 179, .11), transparent 32rem),
    linear-gradient(155deg, #091426 0%, #07101c 48%, #050b14 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: linear-gradient(to bottom, #000, transparent 78%);
}

body::after {
  content: "";
  position: fixed;
  z-index: -1;
  width: 42vw;
  height: 42vw;
  min-width: 360px;
  min-height: 360px;
  right: -13vw;
  bottom: -20vw;
  border-radius: 45% 55% 61% 39% / 52% 38% 62% 48%;
  background: linear-gradient(145deg, rgba(67, 122, 255, .13), rgba(85, 230, 177, .1));
  filter: blur(42px);
  animation: ambient 18s ease-in-out infinite alternate;
  pointer-events: none;
}

main {
  position: relative;
  z-index: 1;
  width: min(1160px, calc(100% - 48px));
  margin: 0 auto;
  padding: 42px 0 64px;
}

.hero {
  position: relative;
  max-width: none;
  margin: 0;
  padding: 8px 2px 30px;
  border-bottom: 1px solid var(--line);
}

.hero.compact { margin-bottom: 0; }

.eyebrow {
  margin: 0 0 11px;
  color: rgba(126, 230, 191, .88);
  font: 750 11px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .18em;
  text-transform: uppercase;
}

.title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px 20px;
}

.status-row {
  display: flex;
  align-items: stretch;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 17px;
}

h1 {
  margin: 0;
  font-size: clamp(44px, 6vw, 72px);
  line-height: .94;
  letter-spacing: -.065em;
  font-weight: 780;
}

.hero.compact h1 { font-size: clamp(44px, 6vw, 72px); }

h1 span {
  color: rgba(225, 238, 255, .2);
  -webkit-text-stroke: 1px rgba(203, 224, 250, .55);
}

.charge-state,
.plug-summary,
.card,
.remaining-panel,
.soc-panel,
.focus-metric,
.cost-panel,
.admin-link,
.back-link,
input,
button {
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  backdrop-filter: blur(24px) saturate(150%);
}

.charge-state {
  width: fit-content;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 10px 14px;
  border: 1px solid rgba(148, 163, 184, .34);
  border-radius: 15px;
  color: #cbd5e1;
  background: rgba(148, 163, 184, .1);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.13);
  font-size: clamp(16px, 1.5vw, 18px);
  font-weight: 760;
  line-height: 1;
  letter-spacing: -.025em;
  white-space: nowrap;
}

.charge-state[data-state="0"] { color: #cbd5e1; }
.charge-state[data-state="1"] { color: var(--green); border-color: rgba(99,230,173,.38); background: rgba(38,160,112,.14); }
.charge-state[data-state="2"] { color: #9bc2ff; border-color: rgba(116,168,255,.42); background: rgba(67,116,226,.18); }
.charge-state[data-state="3"] { color: var(--orange); border-color: rgba(255,179,107,.4); background: rgba(209,116,37,.14); }
.charge-state[data-state="4"] { color: var(--purple); border-color: rgba(195,154,255,.4); background: rgba(144,88,218,.15); }
.charge-state[data-state="5"],
.charge-state[data-state="7"] { color: var(--red); border-color: rgba(255,133,142,.42); background: rgba(210,63,75,.14); }
.charge-state[data-state="6"] { color: var(--cyan); border-color: rgba(103,217,232,.4); background: rgba(41,157,174,.14); }
.charge-state[data-state="99"] { color: #a8a29e; background: rgba(87,83,78,.18); }

.plug-summary {
  width: fit-content;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 0;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255,255,255,.045);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.09);
  font-size: clamp(16px, 1.5vw, 18px);
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.plug-summary::before {
  content: "";
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #718094;
}

.plug-summary.plugged { color: var(--green); border-color: rgba(99,230,173,.26); background: rgba(48,186,132,.09); }
.plug-summary.plugged::before { background: var(--green); box-shadow: 0 0 12px rgba(99,230,173,.8); }

.dashboard { margin-top: 28px; }

.dashboard-header,
.card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dashboard-header {
  min-height: 48px;
  margin-bottom: 14px;
}

.dashboard-header::after {
  content: "每秒自动更新";
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255,255,255,.035);
  font-size: 12px;
}

h2 {
  margin: 0;
  font-size: clamp(21px, 2.5vw, 28px);
  line-height: 1.15;
  letter-spacing: -.035em;
}

.device-grid,
.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}

.card {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(145deg, rgba(255,255,255,.09), rgba(255,255,255,.025) 45%, rgba(83,141,225,.02)),
    var(--surface);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.15),
    0 24px 70px rgba(0, 4, 12, .3);
}

.card::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  background: radial-gradient(360px circle at var(--mx, 20%) var(--my, 0), rgba(255,255,255,.1), transparent 52%);
  pointer-events: none;
}

.device { width: 100%; min-width: 0; padding: 24px; }

.device-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
}

.device h3 {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: #eaf1fb;
  font-size: 17px;
  font-weight: 690;
  letter-spacing: -.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.device p { margin: 0; color: var(--muted); }

.badge {
  flex: 0 0 auto;
  padding: 6px 10px;
  border: 1px solid rgba(99,230,173,.19);
  border-radius: 999px;
  color: var(--green);
  background: rgba(39,163,114,.11);
  font-size: 11px;
  font-weight: 700;
}

.progress-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.session-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.remaining-panel,
.soc-panel,
.focus-metric {
  min-width: 0;
  min-height: 154px;
  padding: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-soft);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.07);
}

.session-metrics .focus-metric { min-height: 108px; }

.remaining-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-color: rgba(99,230,173,.27);
  background:
    linear-gradient(138deg, rgba(79,221,163,.17), rgba(68,133,231,.075) 68%, rgba(255,255,255,.025));
}

.remaining-panel small,
.focus-metric small,
.technical-metrics small,
.cost-panel span { color: var(--muted); }

.remaining-panel strong {
  margin: 8px 0 7px;
  color: var(--green);
  font-size: clamp(38px, 4.4vw, 58px);
  font-weight: 780;
  line-height: .96;
  letter-spacing: -.055em;
  white-space: nowrap;
}

.remaining-panel span { color: var(--subtle); font-size: 11px; }

.soc-panel { display: grid; place-items: center; }

.soc-ring {
  --soc: 0deg;
  position: relative;
  width: 104px;
  max-width: 100%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--green) var(--soc), rgba(99,230,173,.12) 0);
  box-shadow: 0 0 32px rgba(99,230,173,.09);
}

.soc-ring::before {
  content: "";
  position: absolute;
  inset: 9px;
  border-radius: inherit;
  background: radial-gradient(circle at 32% 24%, #26394c, #101b28 70%);
  box-shadow: inset 0 1px 2px rgba(255,255,255,.12);
}

.soc-ring div { position: relative; z-index: 1; text-align: center; }
.soc-ring strong { display: block; font-size: clamp(22px, 2.8vw, 31px); font-weight: 760; line-height: 1; letter-spacing: -.04em; white-space: nowrap; }
.soc-ring small { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }

.focus-metric {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.focus-metric strong {
  width: 100%;
  margin: auto 0;
  overflow: hidden;
  font-size: clamp(26px, 3vw, 40px);
  font-variant-numeric: tabular-nums;
  font-weight: 750;
  line-height: 1;
  letter-spacing: -.045em;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cost-panel {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 20px;
  margin-top: 12px;
  padding: 17px 20px;
  overflow: hidden;
  border: 1px solid rgba(99,230,173,.25);
  border-radius: var(--radius-md);
  background: linear-gradient(100deg, rgba(67,190,139,.12), rgba(68,128,218,.055), rgba(255,255,255,.025));
}

.cost-panel div { min-width: 0; display: grid; gap: 4px; }
.cost-panel small { color: var(--text); font-size: 13px; font-weight: 730; }
.cost-panel span { overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }

.cost-panel strong {
  min-width: 0;
  color: var(--green);
  font-size: clamp(30px, 4vw, 44px);
  font-variant-numeric: tabular-nums;
  font-weight: 790;
  line-height: 1;
  letter-spacing: -.045em;
  text-shadow: 0 0 24px rgba(99,230,173,.12);
  white-space: nowrap;
}

.technical-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255,255,255,.027);
}

.technical-metrics div {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-right: 1px solid var(--line);
}

.technical-metrics div:last-child { border-right: 0; }
.technical-metrics strong { overflow: hidden; font-size: 15px; font-variant-numeric: tabular-nums; font-weight: 690; text-overflow: ellipsis; white-space: nowrap; }

.live-note {
  margin-top: 12px !important;
  color: var(--subtle) !important;
  font-size: 11px;
  text-align: right;
}

.message { min-height: 1.2em; margin: 0; color: #ff9ea6; font-size: 13px; }
.hidden { display: none !important; }

/* Admin */
.admin-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); }
.admin-card, .login-card { padding: 26px; }
.login-card { width: min(480px, 100%); margin-left: auto; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 16px var(--green); }
form { display: grid; gap: 16px; margin-top: 26px; }
label { display: grid; gap: 8px; color: var(--muted); font-size: 13px; }
input { width: 100%; padding: 14px 15px; outline: none; border: 1px solid var(--line); border-radius: 13px; color: var(--text); background: rgba(255,255,255,.045); font: inherit; }
input:focus { border-color: rgba(99,230,173,.48); box-shadow: 0 0 0 4px rgba(99,230,173,.07); }
button { display: flex; justify-content: space-between; padding: 14px 17px; border: 0; border-radius: 13px; color: #062117; background: linear-gradient(145deg, #8df1c3, #59dca3); box-shadow: inset 0 1px 0 rgba(255,255,255,.5); font: 750 14px/1 inherit; cursor: pointer; }
button:disabled { opacity: .5; cursor: wait; }
.text-button { display: block; width: auto; padding: 0; color: var(--muted); background: transparent; box-shadow: none; }
.admin-link, .back-link { display: inline-block; padding: 8px 13px; border: 1px solid var(--line); border-radius: 999px; color: var(--green); background: rgba(255,255,255,.035); text-decoration: none; }
.back-link { margin-top: 22px; }
.status-list { display: grid; gap: 2px; margin: 24px 0; }
.status-list div { display: flex; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); color: var(--muted); }
.status-list strong { color: var(--text); }
.admin-actions { display: flex; gap: 10px; }
.admin-actions button { flex: 1; }
.secondary-button { color: var(--green); border: 1px solid rgba(99,230,173,.35); background: transparent; }

@media (hover: hover) and (pointer: fine) {
  .card { transition: transform .28s ease, border-color .28s ease, box-shadow .28s ease; }
  .card:hover { transform: translateY(-2px); border-color: rgba(255,255,255,.23); box-shadow: inset 0 1px 0 rgba(255,255,255,.17), 0 30px 84px rgba(0,4,12,.36); }
}

@media (max-width: 640px) {
  main { width: calc(100% - 24px); padding: 24px 0 36px; }
  .hero { padding: 4px 0 22px; }
  .title-row { display: grid; justify-items: start; gap: 11px; }
  .hero.compact h1 { max-width: 100%; font-size: clamp(43px, 14.5vw, 56px); }
  .status-row { width: 100%; flex-wrap: nowrap; gap: 8px; margin-top: 14px; }
  .charge-state, .plug-summary { width: fit-content; min-width: 0; min-height: 40px; flex: 0 0 auto; padding: 9px 12px; font-size: 15px; }
  .dashboard { margin-top: 22px; }
  .dashboard-header { margin-bottom: 11px; }
  .dashboard-header::after { padding: 6px 9px; font-size: 10px; }
  .device-grid, .device { width: 100%; max-width: 100%; min-width: 0; }
  .device { padding: 14px; border-radius: 22px; }
  .device h3 { font-size: 16px; }
  .badge { padding: 5px 8px; font-size: 10px; }
  .progress-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-top: 15px; }
  .progress-grid > *, .session-metrics > * { min-width: 0; }
  .remaining-panel, .soc-panel { min-height: 126px; padding: 14px; }
  .remaining-panel strong { font-size: clamp(34px, 10.5vw, 42px); }
  .remaining-panel span { max-width: 13em; }
  .soc-panel { padding: 10px; }
  .soc-ring { width: 82px; }
  .session-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-top: 9px; }
  .session-metrics .focus-metric { min-height: 96px; padding: 13px; }
  .session-metrics .focus-metric:last-child { grid-column: 1 / -1; min-height: 82px; }
  .focus-metric strong { font-size: clamp(27px, 8vw, 32px); }
  .cost-panel { gap: 12px; padding: 15px 16px; }
  .cost-panel > * { min-width: 0; }
  .cost-panel strong { font-size: clamp(29px, 9vw, 35px); }
  .technical-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .technical-metrics div { padding: 13px 15px; border-bottom: 1px solid var(--line); }
  .technical-metrics div:nth-child(2n) { border-right: 0; }
  .technical-metrics div:nth-last-child(-n + 2) { border-bottom: 0; }
  .live-note { text-align: center; }
}

@media (max-width: 360px) {
  .dashboard-header::after { content: "1 秒更新"; }
  .cost-panel { grid-template-columns: 1fr; }
  .cost-panel strong { margin-top: 5px; }
}

@keyframes ambient {
  from { transform: translate3d(0, -4%, 0) rotate(-5deg); }
  to { transform: translate3d(-12vw, 8%, 0) rotate(11deg) scale(1.1); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
  .card { transition: none; }
}
