:root {
  color-scheme: dark;
  --page: #04090d;
  --surface: #08141d;
  --surface-2: #0d202a;
  --surface-3: #142b35;
  --line: #294653;
  --line-strong: #47626d;
  --ink: #f4f8fa;
  --muted: #96adb8;
  --cyan: #42c8f5;
  --cyan-soft: #123b4a;
  --magenta: #df2b8c;
  --magenta-soft: #40122e;
  --green: #55d493;
  --yellow: #f2c14e;
  --red: #ff6f79;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--page); }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}
button, input { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }

.app-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: grid;
  grid-template-columns: 170px auto 1fr auto;
  align-items: center;
  min-height: 68px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(5, 16, 23, .96);
  backdrop-filter: blur(12px);
}
.brand-logo { width: 150px; height: auto; }
.product-name {
  padding-left: 18px;
  border-left: 1px solid var(--line-strong);
  color: var(--magenta);
  font-size: 18px;
  font-weight: 800;
}
.header-status {
  display: flex;
  align-items: center;
  justify-self: end;
  gap: 8px;
  margin-right: 24px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}
.connection-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--yellow);
  box-shadow: 0 0 12px rgba(242, 193, 78, .55);
}
.connection-dot.online { background: var(--green); box-shadow: 0 0 12px rgba(85, 212, 147, .55); }
.connection-dot.offline { background: var(--red); box-shadow: 0 0 12px rgba(255, 111, 121, .55); }
.header-clock { color: var(--cyan); font-size: 17px; font-weight: 800; }

.app-shell { max-width: 1520px; margin: 0 auto; padding: 20px 24px 40px; }
.summary-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border: 1px solid var(--line);
  background: var(--surface);
}
.summary-strip > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: 12px 18px;
  border-right: 1px solid var(--line);
}
.summary-strip > div:last-child { border-right: 0; }
.summary-strip span { color: var(--muted); font-size: 11px; font-weight: 800; }
.summary-strip strong { color: var(--cyan); font-size: 27px; }
.summary-strip > div:last-child strong { color: var(--magenta); }

.toolbar {
  display: grid;
  grid-template-columns: minmax(210px, 1fr) auto auto auto auto;
  gap: 10px;
  align-items: end;
  padding: 16px 0;
}
.search-field { display: grid; gap: 5px; }
.search-field span { color: var(--muted); font-size: 10px; font-weight: 800; }
.search-field input,
.settings-form input[type="text"],
.settings-form input[type="password"],
.settings-form input[type="number"] {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  outline: none;
  background: #02080c;
  color: var(--ink);
  padding: 0 12px;
}
.search-field input:focus,
.settings-form input:focus { border-color: var(--cyan); box-shadow: 0 0 0 1px var(--cyan); }
.filters { display: flex; gap: 6px; }
.filter-button,
.command-button {
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
  padding: 0 13px;
  font-size: 11px;
  font-weight: 800;
}
.filter-button:hover,
.filter-button.active { border-color: var(--magenta); background: var(--magenta-soft); color: white; }
.command-button { border-color: var(--cyan); background: var(--cyan-soft); color: white; }
.command-button.add-station { border-color: var(--magenta); background: var(--magenta-soft); }
.command-button.secondary { border-color: var(--magenta); background: var(--magenta-soft); }
.command-button.loading { opacity: .6; cursor: wait; }

.content-grid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 18px; }
.fleet-area,
.activity-panel { min-width: 0; }
.activity-panel {
  border-left: 1px solid var(--line);
  padding-left: 18px;
}
.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  min-height: 56px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.section-heading h1,
.section-heading h2 { margin: 0 0 3px; font-size: 18px; }
.section-heading p { margin: 0 0 11px; color: var(--muted); font-size: 12px; }
.section-heading > div:last-child { margin-bottom: 11px; color: var(--muted); font-size: 11px; }
.section-heading.compact { align-items: center; }

.station-list { display: grid; gap: 14px; }
.station-group { border: 1px solid var(--line); background: var(--surface); }
.station-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  min-height: 49px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: #0a1b25;
}
.station-head h2 { overflow: hidden; margin: 0; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.station-meta { color: var(--muted); font-size: 11px; }
.online-badge {
  margin-left: 14px;
  border: 1px solid var(--green);
  border-radius: 3px;
  color: var(--green);
  padding: 4px 7px;
  font-size: 9px;
  font-weight: 900;
}
.online-badge.offline { border-color: var(--red); color: var(--red); }
.vacuum-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.vacuum-card {
  position: relative;
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr) auto;
  grid-template-rows: auto auto auto;
  gap: 7px 14px;
  min-height: 186px;
  padding: 16px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: inherit;
  text-align: left;
}
.vacuum-card:last-child { border-right: 0; }
.vacuum-card:hover { background: #0c202a; }
.vacuum-card:focus-visible { outline: 2px solid var(--cyan); outline-offset: -2px; }
.vacuum-card.warning { background: rgba(124, 38, 48, .12); }

.battery-shell {
  position: relative;
  grid-row: 1 / 4;
  align-self: center;
  width: 58px;
  height: 112px;
  margin: 9px 10px 0;
  border: 2px solid #d9eff8;
  border-radius: 6px;
  padding: 5px;
  box-shadow: 0 0 12px rgba(66, 200, 245, .28);
  overflow: visible;
}
.battery-shell::before {
  content: "";
  position: absolute;
  top: -9px;
  left: 17px;
  width: 20px;
  height: 6px;
  border-radius: 2px 2px 0 0;
  background: #d9eff8;
}
.battery-level {
  position: absolute;
  right: 5px;
  bottom: 5px;
  left: 5px;
  min-height: 3px;
  border-radius: 3px;
  background: linear-gradient(to top, var(--magenta) 0 17%, #10baf1 17% 100%);
  transition: height .5s ease;
  overflow: hidden;
}
.vacuum-card.charging .battery-level::after {
  content: "";
  position: absolute;
  inset: -45% 0 auto;
  height: 50%;
  background: linear-gradient(to bottom, transparent, rgba(255,255,255,.65), transparent);
  animation: charge-sweep 2.4s linear infinite;
}
.vacuum-card.charging .battery-shell { animation: charge-glow 2.2s ease-in-out infinite; }
@keyframes charge-sweep { to { transform: translateY(290%); } }
@keyframes charge-glow { 50% { box-shadow: 0 0 20px rgba(66, 200, 245, .72), 0 0 8px rgba(223, 43, 140, .55); } }
.balance-star {
  position: absolute;
  bottom: 11px;
  left: 14px;
  display: none;
  color: white;
  font-size: 12px;
  animation: star-rise 5s linear infinite;
}
.balance-star::before { content: "✦"; }
.vacuum-card.balancing .balance-star { display: block; }
.vacuum-card.balancing .balance-star:nth-child(3) { left: 31px; animation-delay: 1.3s; }
.vacuum-card.balancing .balance-star:nth-child(4) { left: 20px; animation-delay: 2.7s; }
@keyframes star-rise {
  0% { opacity: 0; transform: translateY(0) scale(.35); }
  15% { opacity: 1; transform: translateY(-9px) scale(1); }
  100% { opacity: 0; transform: translateY(-83px) scale(.65); }
}

.vacuum-title { min-width: 0; }
.vacuum-title h3 { overflow: hidden; margin: 0 0 3px; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; }
.vacuum-title small { color: var(--muted); }
.soc-block { grid-row: 1 / 3; grid-column: 3; text-align: right; }
.soc-block strong { display: block; color: white; font-size: 29px; line-height: 31px; }
.soc-block span { color: var(--cyan); font-size: 13px; font-weight: 800; }
.status-line { align-self: center; min-width: 0; }
.status-pill {
  display: inline-flex;
  max-width: 100%;
  min-height: 27px;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  color: var(--muted);
  padding: 0 8px;
  font-size: 10px;
  font-weight: 900;
}
.status-pill.charging { border-color: var(--cyan); color: var(--cyan); }
.status-pill.away { border-color: var(--magenta); color: var(--magenta); }
.status-pill.ready { border-color: var(--green); color: var(--green); }
.status-pill.warning { border-color: var(--red); color: var(--red); }
.vacuum-message { overflow: hidden; color: #bed0d8; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.vacuum-footer {
  grid-column: 2 / 4;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-self: end;
  padding-top: 9px;
  border-top: 1px solid var(--line);
}
.vacuum-footer span { color: var(--muted); font-size: 9px; font-weight: 800; }
.vacuum-footer strong { display: block; margin-top: 2px; color: var(--ink); font-size: 11px; }

.activity-list { display: grid; }
.activity-item { padding: 13px 4px; border-bottom: 1px solid var(--line); }
.activity-item time { color: var(--cyan); font-size: 10px; font-weight: 800; }
.activity-item strong { display: block; margin: 4px 0 2px; font-size: 12px; }
.activity-item p { margin: 0; color: var(--muted); font-size: 11px; line-height: 16px; }
.activity-kind { color: var(--magenta); font-size: 9px; font-weight: 900; }
.empty-state { padding: 50px 20px; border: 1px dashed var(--line-strong); color: var(--muted); text-align: center; }

.modal {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(1, 5, 8, .86);
}
.modal[hidden] { display: none; }
.modal-card {
  width: min(760px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #07141d;
  box-shadow: 0 24px 80px rgba(0,0,0,.65);
}
.modal-head {
  position: sticky;
  z-index: 2;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 74px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: #0a1b25;
}
.modal-head h2 { margin: 2px 0 0; font-size: 20px; }
.modal-eyebrow { color: var(--magenta); font-size: 10px; font-weight: 900; }
.close-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface-2);
  color: white;
  font-size: 22px;
}
.detail-summary { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--line); }
.detail-summary div { padding: 16px; border-right: 1px solid var(--line); }
.detail-summary div:last-child { border-right: 0; }
.detail-summary span { color: var(--muted); font-size: 9px; font-weight: 800; }
.detail-summary strong { display: block; margin-top: 4px; color: var(--cyan); font-size: 17px; }
.remote-actions { padding: 16px 18px; border-bottom: 1px solid var(--line); background: #06111a; }
.remote-actions-head { display: flex; align-items: start; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.remote-actions-head h3 { margin: 0; color: var(--magenta); font-size: 13px; }
.remote-actions-head p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.command-availability { flex: 0 0 auto; border: 1px solid var(--green); border-radius: 3px; color: var(--green); padding: 4px 7px; font-size: 9px; font-weight: 900; }
.command-availability.offline { border-color: var(--red); color: var(--red); }
.remote-action-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.remote-action {
  min-height: 48px;
  border: 1px solid var(--magenta);
  border-radius: 4px;
  background: var(--magenta-soft);
  color: white;
  font-size: 10px;
  font-weight: 900;
}
.remote-action.primary { border-color: var(--cyan); background: var(--cyan-soft); }
.remote-action:hover { border-color: white; }
.remote-action:disabled { border-color: var(--line-strong); background: #121c22; color: #607681; cursor: not-allowed; }
.schedule-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  align-items: end;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.schedule-form[hidden] { display: none; }
.schedule-form label { display: grid; gap: 5px; color: var(--muted); font-size: 10px; font-weight: 800; }
.schedule-form input,
.schedule-form select {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: #02080c;
  color: white;
  padding: 0 10px;
}
.schedule-form button {
  min-height: 40px;
  border: 1px solid var(--cyan);
  border-radius: 4px;
  background: var(--cyan-soft);
  color: white;
  padding: 0 12px;
  font-size: 10px;
  font-weight: 900;
}
.command-message { min-height: 18px; margin-top: 10px; color: var(--cyan); font-size: 11px; font-weight: 700; }
.command-message.error { color: var(--red); }
.history-title { display: flex; justify-content: space-between; padding: 16px 18px 8px; color: var(--magenta); font-weight: 900; }
.history-title small { color: var(--muted); font-weight: 500; }
.history-list { padding: 0 18px 18px; }
.history-row {
  display: grid;
  grid-template-columns: 92px 1fr auto;
  gap: 12px;
  align-items: center;
  min-height: 58px;
  border-bottom: 1px solid var(--line);
}
.history-row:last-child { border-bottom: 0; }
.history-type { border-left: 3px solid var(--magenta); color: var(--magenta); padding-left: 8px; font-size: 10px; font-weight: 900; }
.history-type.charge { border-color: var(--cyan); color: var(--cyan); }
.history-main strong { display: block; font-size: 12px; }
.history-main span { color: var(--muted); font-size: 11px; }
.history-energy { color: var(--cyan); font-weight: 800; }

.settings-card { width: min(560px, 100%); }
.login-card { width: min(460px, 100%); }
.settings-form { display: grid; gap: 14px; padding: 20px; }
.settings-form label { display: grid; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 800; }
.check-row { grid-template-columns: auto 1fr; align-items: center; }
.check-row input { width: 18px; height: 18px; accent-color: var(--magenta); }
.save-button {
  min-height: 44px;
  border: 1px solid var(--magenta);
  border-radius: 4px;
  background: var(--magenta-soft);
  color: white;
  font-weight: 800;
}
.settings-note { margin: 0; padding: 0 20px 20px; color: var(--muted); font-size: 11px; line-height: 16px; }

.pairing-card { width: min(560px, 100%); }
.pairing-intro { padding: 20px 20px 0; }
.pairing-intro strong { color: var(--ink); font-size: 14px; }
.pairing-intro p { margin: 7px 0 0; color: var(--muted); font-size: 12px; line-height: 18px; }
.pairing-form { display: grid; gap: 16px; padding: 20px; }
.pairing-form label { display: grid; gap: 7px; color: var(--muted); font-size: 11px; font-weight: 800; }
.pairing-form input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  outline: 0;
  background: var(--surface);
  color: var(--ink);
  padding: 0 12px;
}
.pairing-form input:focus { border-color: var(--cyan); box-shadow: 0 0 0 1px var(--cyan); }
.pairing-form .pairing-code {
  height: 58px;
  color: var(--cyan);
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 0;
  text-align: center;
}
.pairing-message { min-height: 22px; margin: 0 20px 16px; color: var(--cyan); font-size: 12px; font-weight: 800; line-height: 18px; }
.pairing-message.error { color: #ff6e8f; }

@media (max-width: 1050px) {
  .toolbar { grid-template-columns: 1fr auto auto auto; }
  .filters { grid-column: 1 / -1; grid-row: 2; }
  .content-grid { grid-template-columns: 1fr; }
  .activity-panel { border-top: 1px solid var(--line); border-left: 0; padding: 14px 0 0; }
  .activity-list { grid-template-columns: repeat(2, 1fr); gap: 0 16px; }
}

@media (max-width: 720px) {
  .app-header { grid-template-columns: 126px 1fr auto; min-height: 58px; padding: 0 14px; }
  .brand-logo { width: 116px; }
  .product-name { padding-left: 12px; font-size: 14px; }
  .header-status { display: none; }
  .header-clock { font-size: 14px; }
  .app-shell { padding: 12px 12px 28px; }
  .summary-strip { grid-template-columns: repeat(3, 1fr); }
  .summary-strip > div { min-height: 56px; padding: 9px; }
  .summary-strip > div:nth-child(3) { border-right: 0; }
  .summary-strip > div:nth-child(n+4) { border-top: 1px solid var(--line); }
  .summary-strip strong { font-size: 21px; }
  .toolbar { grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
  .filters { overflow-x: auto; padding-bottom: 3px; }
  .command-button.add-station { grid-column: 1 / -1; }
  .filter-button { flex: 0 0 auto; }
  .vacuum-grid { grid-template-columns: 1fr; }
  .vacuum-card { border-right: 0; border-bottom: 1px solid var(--line); }
  .vacuum-card:last-child { border-bottom: 0; }
  .vacuum-title h3 {
    display: -webkit-box;
    overflow: hidden;
    white-space: normal;
    line-height: 19px;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }
  .vacuum-message { white-space: normal; line-height: 17px; }
  .station-head { grid-template-columns: 1fr auto; }
  .station-meta { display: none; }
  .activity-list { grid-template-columns: 1fr; }
  .modal { padding: 0; }
  .modal-card { width: 100%; max-height: 100vh; min-height: 100vh; border: 0; border-radius: 0; }
  .detail-summary { grid-template-columns: repeat(2, 1fr); }
  .detail-summary div:nth-child(2) { border-right: 0; }
  .detail-summary div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .remote-actions-head { display: grid; }
  .remote-action-grid { grid-template-columns: repeat(2, 1fr); }
  .schedule-form { grid-template-columns: 1fr; }
  .history-row { grid-template-columns: 80px 1fr; }
  .history-energy { grid-column: 2; }
}

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