:root {
  color-scheme: dark;
  --canvas: #06070b;
  --canvas-2: #0b0d14;
  --rail: #090b11;
  --surface: rgba(16, 19, 29, 0.86);
  --surface-solid: #11151f;
  --surface-2: #171c29;
  --surface-3: #202737;
  --line: rgba(143, 157, 184, 0.16);
  --line-strong: rgba(174, 190, 220, 0.28);
  --ink: #f7f9fc;
  --muted: #a1adbf;
  --subtle: #697589;
  --cyan: #55d6ff;
  --blue: #4d7cff;
  --violet: #8d6dff;
  --green: #49e6a1;
  --yellow: #ffd166;
  --red: #ff5c77;
  --orange: #ff9f43;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.46);
  --radius: 8px;
  --radius-lg: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  height: 100vh;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(85, 214, 255, 0.1), transparent 26%),
    radial-gradient(circle at 88% 12%, rgba(141, 109, 255, 0.18), transparent 28%),
    radial-gradient(circle at 70% 80%, rgba(73, 230, 161, 0.1), transparent 30%),
    var(--canvas);
  color: var(--ink);
  font: 13px/1.45 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.9), transparent 86%);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.035), transparent 12%, transparent 88%, rgba(255, 255, 255, 0.035));
}

.app-shell::before,
.app-shell::after {
  content: "";
  position: fixed;
  pointer-events: none;
  z-index: -1;
}

.app-shell::before {
  width: 42vw;
  height: 42vw;
  right: 4vw;
  top: -20vw;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(85, 214, 255, 0.24), transparent 58%);
  filter: blur(18px);
  animation: aurora-drift 12s ease-in-out infinite alternate;
}

.app-shell::after {
  left: 324px;
  right: 18px;
  top: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(85, 214, 255, 0.9), rgba(141, 109, 255, 0.7), transparent);
  animation: beam-slide 4.8s ease-in-out infinite;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0 14px;
  background: linear-gradient(135deg, var(--blue), var(--violet));
  color: #fff;
  cursor: pointer;
  font-weight: 750;
  transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease, box-shadow 0.14s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 26px rgba(77, 124, 255, 0.22);
}

button:active {
  transform: translateY(0);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 11px;
  background: rgba(5, 7, 12, 0.82);
  color: var(--ink);
  outline: none;
}

input::placeholder,
textarea::placeholder {
  color: var(--subtle);
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(85, 214, 255, 0.72);
  box-shadow: 0 0 0 3px rgba(85, 214, 255, 0.14);
}

select {
  color-scheme: dark;
}

textarea {
  min-height: 112px;
  resize: vertical;
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
}

label span,
.section-title,
.eyebrow {
  color: var(--subtle);
  font-size: 10.5px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.app-shell {
  position: relative;
  z-index: 1;
  height: 100vh;
  display: grid;
  grid-template-columns: 324px minmax(0, 1fr);
}

.brand-mark {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  min-height: 52px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255, 159, 67, 0.36);
  border-radius: 15px;
  background:
    linear-gradient(135deg, rgba(255, 159, 67, 0.2), rgba(255, 159, 67, 0.04)),
    rgba(255, 255, 255, 0.04);
  box-shadow: 0 14px 32px rgba(255, 159, 67, 0.14);
}

.brand-mark img {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  display: block;
}

.sidebar {
  min-width: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding: 18px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(12, 15, 23, 0.88), rgba(8, 10, 16, 0.8));
  backdrop-filter: blur(24px);
}

.brand {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-copy {
  min-width: 0;
  flex: 1 1 auto;
}

.brand h1,
.hero-console h2 {
  margin: 0;
}

.brand h1 {
  overflow: hidden;
  color: var(--ink);
  font-size: 24px;
  line-height: 1.05;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.brand p {
  margin: 0;
}

.setup-mini-button {
  min-height: 34px;
  padding: 0 11px;
}

#mqttState {
  margin-top: 7px;
  color: var(--muted);
}

.panel,
.hero-console,
.fleet-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(20, 24, 36, 0.86), rgba(12, 15, 23, 0.78));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  animation: panel-rise 0.55s ease both;
}

.panel:nth-of-type(2) {
  animation-delay: 0.04s;
}

.panel:nth-of-type(3) {
  animation-delay: 0.08s;
}

.panel:nth-of-type(4) {
  animation-delay: 0.12s;
}

.section-head {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.section-head strong {
  display: block;
  margin-top: 2px;
  font-size: 15px;
  line-height: 1.2;
}

.game-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(5, 7, 12, 0.72);
}

.game-options [data-game] {
  min-width: 0;
  min-height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.game-options [data-game]:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
}

.game-options [data-game].active {
  color: #041018;
  background: linear-gradient(135deg, var(--cyan), var(--green));
  box-shadow: 0 10px 28px rgba(85, 214, 255, 0.16);
  animation: active-tab-glow 2.8s ease-in-out infinite;
}

.selected-device {
  color: var(--muted);
  font-size: 12px;
}

.selected-device strong {
  color: var(--cyan);
}

.setup-modal {
  position: fixed;
  inset: 0;
  z-index: 38;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 20%, rgba(85, 214, 255, 0.16), transparent 34%),
    rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(14px);
}

.setup-modal[hidden] {
  display: none;
}

.setup-dialog {
  width: min(480px, calc(100vw - 40px));
  display: grid;
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(24, 29, 43, 0.98), rgba(10, 13, 20, 0.98)),
    var(--surface-solid);
  box-shadow: var(--shadow);
  animation: modal-in 0.24s ease both;
}

.setup-head {
  display: grid;
  gap: 5px;
}

.setup-head h3 {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
}

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

.setup-section {
  display: grid;
  gap: 8px;
}

.setup-section > span {
  color: var(--subtle);
  font-size: 10.5px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

body.setup-open .app-shell {
  filter: saturate(0.7) brightness(0.72);
}

.primary-command {
  min-height: 44px;
  background:
    linear-gradient(135deg, rgba(85, 214, 255, 0.95), rgba(77, 124, 255, 0.95) 48%, rgba(141, 109, 255, 0.95)),
    var(--blue);
  color: #fff;
  position: relative;
  overflow: hidden;
}

.primary-command::after {
  content: "";
  position: absolute;
  inset: -40% auto -40% -35%;
  width: 34%;
  transform: rotate(18deg);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.46), transparent);
  animation: command-shine 3.6s ease-in-out infinite;
}

.button-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.command-quick-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.ghost-button,
.toolbar-actions button,
.log-button,
.log-close,
.icon-button {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.055);
  color: var(--ink);
  box-shadow: none;
}

.ghost-button:hover,
.toolbar-actions button:hover,
.log-button:hover,
.log-close:hover,
.icon-button:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.09);
  box-shadow: none;
}

.warn-button {
  border-color: rgba(255, 92, 119, 0.38);
  background: rgba(255, 92, 119, 0.14);
  color: #ffb4c0;
}

.warn-button:hover {
  border-color: rgba(255, 92, 119, 0.66);
  background: rgba(255, 92, 119, 0.22);
}

.command-title {
  cursor: pointer;
  user-select: none;
}

.command-title.unlocked {
  color: var(--yellow);
}

.segment-list {
  max-height: 118px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
  gap: 6px;
  overflow: auto;
}

.segment-button {
  min-width: 0;
  min-height: 31px;
  display: grid;
  align-content: center;
  justify-content: center;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  box-shadow: none;
  text-align: center;
}

.segment-button:hover,
.segment-button.active {
  border-color: rgba(85, 214, 255, 0.66);
  background: rgba(85, 214, 255, 0.14);
}

.segment-button strong,
.download-item span {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.fail-select-button {
  border-color: rgba(255, 209, 102, 0.34);
  background: rgba(255, 209, 102, 0.11);
  color: #ffe2a0;
}

.fail-select-button.has-failed {
  border-color: rgba(255, 92, 119, 0.58);
  background: rgba(255, 92, 119, 0.16);
  color: #ffb4c0;
}

.main {
  min-width: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
  overflow: hidden;
  padding: 18px;
}

.hero-console {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(190px, 0.62fr) minmax(520px, 1.38fr) minmax(230px, auto);
  gap: 14px;
  align-items: stretch;
  padding: 16px;
  background:
    linear-gradient(90deg, rgba(85, 214, 255, 0.14), transparent 34%),
    linear-gradient(180deg, rgba(20, 24, 36, 0.92), rgba(12, 15, 23, 0.82));
  animation: panel-rise 0.55s ease both;
}

.hero-copy {
  min-width: 0;
  display: grid;
  align-content: center;
}

.hero-console h2 {
  margin-top: 4px;
  font-size: 34px;
  line-height: 1;
}

.hero-console p {
  min-width: 0;
  margin: 7px 0 0;
  overflow: hidden;
  color: var(--muted);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.summary-stats {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(7, minmax(72px, 1fr));
  gap: 8px;
}

.stat-card,
.summary-stats div {
  position: relative;
  min-width: 0;
  min-height: 62px;
  display: grid;
  align-content: center;
  gap: 4px;
  overflow: hidden;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(5, 7, 12, 0.58);
}

.stat-card::after,
.summary-stats div::after {
  content: "";
  position: absolute;
  inset: auto 12px 10px 12px;
  height: 2px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--cyan), transparent);
  animation: stat-meter 3.2s ease-in-out infinite;
}

.summary-stats span {
  color: var(--subtle);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.summary-stats strong {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 20px;
  line-height: 1.05;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.status-online strong {
  color: var(--green);
}

.status-alert strong {
  color: var(--red);
}

.status-offline strong {
  color: #a7b2c3;
}

.status-selected strong {
  color: var(--cyan);
}

.toolbar-actions {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(160px, 240px) 72px 72px;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.toolbar-actions select {
  min-width: 0;
  width: 100%;
}

.workbench {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
}

.fleet-panel {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  animation: panel-rise 0.62s ease both;
}

.fleet-head {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--line);
}

.fleet-head strong {
  display: block;
  margin-top: 2px;
  font-size: 16px;
}

.fleet-tools {
  min-width: 0;
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(220px, 340px);
  align-items: center;
  justify-content: end;
  gap: 8px;
}

.quick-key-list {
  min-width: 0;
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  overflow: hidden;
}

.quick-key-list:empty {
  display: none;
}

.quick-key-button {
  min-width: 0;
  max-width: 112px;
  min-height: 34px;
  padding: 0 10px;
  overflow: hidden;
  border-color: rgba(85, 214, 255, 0.24);
  background: rgba(85, 214, 255, 0.09);
  color: var(--ink);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.quick-key-button.active {
  border-color: rgba(73, 230, 161, 0.5);
  background: rgba(73, 230, 161, 0.16);
  color: var(--green);
}

.multi-key-button {
  min-height: 34px;
  padding: 0 12px;
}

.device-search-floating {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(5, 7, 12, 0.72);
}

.device-search-floating input,
.device-search-floating button {
  min-height: 34px;
}

.grid {
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr;
  align-content: start;
  gap: 6px;
  overflow-y: auto;
  padding: 10px;
}

.grid.tile-view {
  grid-template-columns: repeat(auto-fill, minmax(178px, 1fr));
  gap: 10px;
}

.device-card {
  position: relative;
  min-width: 0;
  height: 66px;
  display: grid;
  grid-template-columns: 178px minmax(0, 1fr);
  gap: 11px;
  align-items: center;
  overflow: hidden;
  padding: 9px 13px 9px 15px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(13, 16, 25, 0.88);
  cursor: pointer;
  transition: border-color 0.14s ease, background 0.14s ease, box-shadow 0.14s ease, transform 0.14s ease;
}

.device-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--subtle);
}

.device-card:hover {
  border-color: var(--line-strong);
  background: rgba(24, 30, 44, 0.92);
  transform: translateY(-1px);
}

.device-card.online::before {
  background: var(--green);
  box-shadow: 0 0 20px rgba(73, 230, 161, 0.6);
  animation: status-flow 2.2s ease-in-out infinite;
}

.device-card.offline {
  opacity: 0.74;
}

.device-card.offline::before {
  background: #556173;
}

.device-card.selected {
  border-color: rgba(85, 214, 255, 0.82);
  box-shadow: 0 0 0 3px rgba(85, 214, 255, 0.16);
}

.device-card.abnormal {
  border-color: rgba(255, 92, 119, 0.78);
  background: linear-gradient(90deg, rgba(255, 92, 119, 0.18), rgba(13, 16, 25, 0.9) 42%);
}

.device-card.abnormal::before {
  background: var(--red);
  box-shadow: 0 0 22px rgba(255, 92, 119, 0.64);
  animation: alert-pulse 1.2s ease-in-out infinite;
}

.device-card.verification {
  border-color: rgba(255, 209, 102, 0.72);
  background: linear-gradient(90deg, rgba(255, 209, 102, 0.16), rgba(13, 16, 25, 0.9) 42%);
}

.device-card.verification::before,
.device-card.version-warning:not(.abnormal)::before {
  background: var(--yellow);
}

.device-card.drag-hit,
.device-card.search-hit {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(85, 214, 255, 0.2), var(--shadow);
}

.device-top,
.device-actions {
  min-width: 0;
  display: flex;
  align-items: center;
}

.device-top {
  justify-content: space-between;
  gap: 8px;
  overflow: hidden;
}

.device-top h3 {
  margin: 0;
  overflow: hidden;
  font-size: 17px;
  line-height: 20px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.device-top p {
  margin: 1px 0 0;
  overflow: hidden;
  color: var(--subtle);
  font-size: 12px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.device-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 5px;
}

.device-metrics {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(66px, 0.7fr) minmax(94px, 1fr) minmax(54px, 0.58fr) minmax(62px, 0.66fr) minmax(62px, 0.66fr) minmax(62px, 0.66fr) minmax(72px, 0.76fr) minmax(90px, 0.94fr);
  align-items: center;
  gap: 8px;
}

.device-metrics > div {
  min-width: 0;
  display: grid;
  grid-template-rows: 13px 18px;
  gap: 1px;
  padding-left: 8px;
  border-left: 1px solid var(--line);
  overflow: hidden;
}

.device-metrics > div[data-metric="state"],
.device-metrics > div[data-metric="action"] {
  display: none;
}

.device-metrics span {
  color: var(--subtle);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.device-metrics strong {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 700;
  line-height: 18px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.device-metrics > div.metric-bad strong,
.bad {
  color: #ff93a4 !important;
}

.device-metrics > div.metric-warn strong {
  color: #ffe2a0;
}

.good {
  color: var(--green) !important;
}

.status,
.pill {
  min-height: 22px;
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 850;
  white-space: nowrap;
}

.online .status,
.pill.success {
  border-color: rgba(73, 230, 161, 0.32);
  background: rgba(73, 230, 161, 0.12);
  color: #9af5cb;
}

.offline .status,
.pill.failed {
  border-color: rgba(105, 117, 137, 0.28);
  color: #a7b2c3;
}

.pill.running,
.pill.received,
.pill.pending,
.version-label,
.verification-label,
.buy-potion-failed-label {
  border-color: rgba(255, 209, 102, 0.34) !important;
  background: rgba(255, 209, 102, 0.12) !important;
  color: #ffe2a0 !important;
}

.abnormal-label {
  border-color: rgba(255, 92, 119, 0.38) !important;
  background: rgba(255, 92, 119, 0.14) !important;
  color: #ffb4c0 !important;
}

.log-button {
  min-height: 24px;
  padding: 0 8px;
  font-size: 10.5px;
}

.tile-view .device-card {
  height: 164px;
  grid-template-columns: 1fr;
  grid-template-rows: auto minmax(0, 1fr);
  align-items: stretch;
  padding: 12px;
}

.tile-view .device-metrics {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.tile-view .device-metrics > div {
  min-height: 48px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(5, 7, 12, 0.5);
}

.tile-view .device-metrics > div:not([data-metric="daily"]):not([data-metric="level"]):not([data-metric="exp"]):not([data-metric="diamond"]):not([data-metric="gold"]):not([data-metric="version"]) {
  display: none;
}

.download-panel {
  display: grid;
  gap: 10px;
}

.export-panel {
  gap: 8px;
}

.export-button {
  border-color: rgba(73, 230, 161, 0.38);
  background:
    linear-gradient(135deg, rgba(73, 230, 161, 0.86), rgba(85, 214, 255, 0.82));
  color: #041018;
}

.export-hint {
  margin: 0;
  color: var(--subtle);
  font-size: 12px;
  line-height: 1.45;
}

.download-list {
  max-height: 126px;
  display: grid;
  gap: 8px;
  overflow: auto;
}

.download-item {
  min-width: 0;
  min-height: 38px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  text-decoration: none;
}

.download-item:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.08);
}

.download-item small {
  color: var(--subtle);
  white-space: nowrap;
}

.empty,
.empty-cell {
  padding: 16px;
  color: var(--subtle);
  font-size: 12px;
}

.grid > .empty {
  min-height: 240px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(85, 214, 255, 0.08), transparent 34%),
    rgba(255, 255, 255, 0.025);
}

.mono {
  overflow-wrap: anywhere;
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: rgba(17, 21, 31, 0.98);
  color: var(--ink);
  box-shadow: var(--shadow);
  animation: toast-in 0.24s ease both;
}

.bad-toast {
  border-color: rgba(255, 92, 119, 0.55);
  background: rgba(72, 22, 34, 0.98);
}

.scroll-top-button {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 30;
  min-height: 38px;
  padding: 0 12px;
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.08);
}

.drag-select-box {
  position: fixed;
  z-index: 20;
  pointer-events: none;
  border: 1px solid rgba(85, 214, 255, 0.9);
  background: rgba(85, 214, 255, 0.16);
}

.is-drag-selecting {
  user-select: none;
  cursor: crosshair;
}

.log-modal,
.version-modal,
.multi-key-modal {
  position: fixed;
  inset: 0;
  z-index: 35;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.66);
  backdrop-filter: blur(12px);
}

.log-modal[hidden],
.version-modal[hidden],
.multi-key-modal[hidden] {
  display: none;
}

.log-dialog,
.version-dialog,
.multi-key-dialog {
  width: min(820px, 100%);
  max-height: min(740px, calc(100vh - 48px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface-solid);
  box-shadow: var(--shadow);
  animation: modal-in 0.22s ease both;
}

.multi-key-dialog {
  width: min(520px, 100%);
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: 0;
}

.multi-key-head,
.multi-key-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.multi-key-actions {
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.multi-key-head span {
  color: var(--subtle);
  font-size: 10.5px;
  font-weight: 850;
  letter-spacing: 0.08em;
}

.multi-key-head h3 {
  margin: 2px 0 0;
  font-size: 18px;
}

.multi-key-rows {
  min-height: 0;
  max-height: min(420px, calc(100vh - 220px));
  display: grid;
  gap: 8px;
  overflow: auto;
  padding: 14px;
}

.multi-key-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  gap: 8px;
}

.multi-key-row input {
  min-height: 38px;
}

.multi-key-remove,
.multi-key-add {
  min-width: 38px;
  min-height: 38px;
  padding: 0;
}

@keyframes aurora-drift {
  from {
    transform: translate3d(0, 0, 0) scale(1);
    opacity: 0.7;
  }
  to {
    transform: translate3d(-10vw, 8vh, 0) scale(1.16);
    opacity: 1;
  }
}

@keyframes beam-slide {
  0%,
  100% {
    opacity: 0.25;
    transform: translateX(-10%);
  }
  50% {
    opacity: 1;
    transform: translateX(10%);
  }
}

@keyframes live-pulse {
  0%,
  100% {
    transform: scale(0.82);
    opacity: 0.7;
  }
  50% {
    transform: scale(1.18);
    opacity: 1;
  }
}

@keyframes panel-rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes active-tab-glow {
  0%,
  100% {
    box-shadow: 0 10px 28px rgba(85, 214, 255, 0.16);
  }
  50% {
    box-shadow: 0 12px 34px rgba(73, 230, 161, 0.32);
  }
}

@keyframes command-shine {
  0%,
  55% {
    transform: translateX(0) rotate(18deg);
  }
  100% {
    transform: translateX(420%) rotate(18deg);
  }
}

@keyframes stat-meter {
  0%,
  100% {
    opacity: 0.38;
    transform: scaleX(0.42);
    transform-origin: left;
  }
  50% {
    opacity: 1;
    transform: scaleX(1);
    transform-origin: left;
  }
}

@keyframes status-flow {
  0%,
  100% {
    filter: brightness(0.85);
  }
  50% {
    filter: brightness(1.35);
  }
}

@keyframes alert-pulse {
  0%,
  100% {
    opacity: 0.72;
  }
  50% {
    opacity: 1;
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

.log-head,
.version-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
}

.log-head span,
.version-head span {
  color: var(--subtle);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.log-head h3,
.version-head h3 {
  margin: 2px 0 0;
  font-size: 19px;
}

.log-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.log-failure-code {
  min-height: 32px;
  border-color: rgba(255, 92, 119, 0.42);
  background: rgba(255, 92, 119, 0.15);
  color: #ffb4c0;
}

.version-dialog {
  width: min(540px, calc(100vw - 40px));
  grid-template-rows: auto auto auto;
}

.version-body {
  display: grid;
  gap: 13px;
  padding: 16px;
}

.version-current {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.version-actions {
  display: flex;
  justify-content: flex-end;
  padding: 0 16px 16px;
}

.log-sections {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(150px, 0.85fr) minmax(220px, 1.15fr);
  gap: 10px;
  padding: 12px;
}

.log-sections.has-failure {
  grid-template-rows: minmax(120px, 0.75fr) minmax(150px, 0.85fr) minmax(220px, 1.15fr);
}

.log-section[hidden] {
  display: none;
}

.log-section {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(5, 7, 12, 0.72);
}

.log-section-title {
  padding: 9px 11px;
  border-bottom: 1px solid var(--line);
  color: var(--subtle);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.log-content {
  min-height: 0;
  margin: 0;
  overflow: auto;
  padding: 11px;
  background: rgba(4, 5, 9, 0.78);
  color: #d8dee9;
  font: 12.5px/1.55 "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

@media (max-width: 1240px) {
  .app-shell {
    grid-template-columns: 300px minmax(0, 1fr);
  }

  .hero-console {
    grid-template-columns: 1fr;
  }

  .summary-stats {
    grid-template-columns: repeat(4, minmax(86px, 1fr));
  }
}

@media (max-width: 900px) {
  body {
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }

  .app-shell {
    height: auto;
    grid-template-columns: 1fr;
  }

  .sidebar {
    height: auto;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .main {
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .toolbar-actions {
    grid-template-columns: minmax(0, 1fr) 72px 72px;
  }

  .toolbar-actions select,
  .toolbar-actions button {
    min-width: 0;
  }

  .fleet-head {
    display: grid;
  }

  .fleet-tools {
    grid-template-columns: 1fr;
    justify-content: stretch;
  }

  .quick-key-list {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .quick-key-button {
    max-width: 130px;
  }

  .device-search-floating {
    width: 100%;
    min-width: 0;
  }

  .grid {
    overflow: visible;
  }

  .device-card {
    height: auto;
    min-height: 96px;
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .device-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
