:root {
  --bg: #0e141b;
  --panel: #17212b;
  --panel-2: #1f2b38;
  --panel-3: #243240;
  --line: #314253;
  --text: #e8eef5;
  --muted: #9cafc3;
  --primary: #4fa4ff;
  --success: #24c46b;
  --danger: #ff5d5d;
  --warning: #f3c34c;
  --offline: #66788a;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.28);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(79, 164, 255, 0.12), transparent 34%),
    radial-gradient(circle at bottom right, rgba(36, 196, 107, 0.1), transparent 28%),
    var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.page-shell {
  min-height: 100vh;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(100%, 420px);
  padding: 32px;
  background: rgba(23, 33, 43, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.brand-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #7dc9ff);
  box-shadow: 0 0 16px rgba(79, 164, 255, 0.6);
}

.login-title {
  margin: 18px 0 8px;
  font-size: 30px;
  line-height: 1.1;
}

.login-subtitle {
  margin: 0 0 24px;
  color: var(--muted);
  line-height: 1.6;
}

.field-group {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 8px;
}

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

.field input,
.field select {
  width: 100%;
  padding: 14px 16px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  outline: none;
}

.field input:focus,
.field select:focus {
  border-color: rgba(79, 164, 255, 0.75);
  box-shadow: 0 0 0 3px rgba(79, 164, 255, 0.14);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 14px;
  transition: transform 120ms ease, opacity 120ms ease, background 120ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  transform: none;
  filter: grayscale(0.25);
  box-shadow: none;
}

.btn-primary {
  color: white;
  background: linear-gradient(135deg, #2b8cff, #5db6ff);
}

.btn-secondary {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.btn-warning {
  color: #161616;
  background: linear-gradient(135deg, #ffcf64, #f3c34c);
}

.btn-danger {
  color: white;
  background: linear-gradient(135deg, #ff6d6d, #ff4e4e);
}

.btn-ghost {
  color: var(--muted);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  padding: 22px 18px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(10, 15, 20, 0.32);
  backdrop-filter: blur(18px);
}

.sidebar-header {
  padding: 8px 8px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 18px;
}

.sidebar-title {
  margin: 10px 0 4px;
  font-size: 22px;
}

.sidebar-subtitle {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 14px;
  border-radius: 14px;
  color: var(--muted);
  transition: background 120ms ease, color 120ms ease;
}

.nav-link.active,
.nav-link:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.main {
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.page-title {
  margin: 0;
  font-size: 28px;
}

.page-desc {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 13px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.dot.offline {
  background: var(--offline);
}

.dot.busy {
  background: var(--danger);
  box-shadow: 0 0 12px rgba(255, 93, 93, 0.55);
}

.dot.ready {
  background: var(--success);
  box-shadow: 0 0 12px rgba(36, 196, 107, 0.45);
}

.dot.warning {
  background: var(--warning);
  box-shadow: 0 0 12px rgba(243, 195, 76, 0.45);
}

.content-grid {
  display: grid;
  gap: 18px;
}

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.85fr);
  gap: 18px;
}

.card {
  padding: 20px;
  background: rgba(23, 33, 43, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-title {
  margin: 0 0 10px;
  font-size: 18px;
}

.card-subtitle {
  margin: 0 0 16px;
  color: var(--muted);
  line-height: 1.5;
}

.box-grid,
.stats-grid,
.device-grid,
.log-list,
.action-list,
.remote-grid {
  display: grid;
  gap: 14px;
}

.box-grid {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.box-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02));
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 20px;
}

.box-card h3,
.device-item h3,
.log-item h3 {
  margin: 0;
  font-size: 18px;
}

.meta-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
  color: var(--muted);
  font-size: 13px;
}

.stats-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.stat-card {
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

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

.stat-value {
  margin-top: 10px;
  font-size: 26px;
  font-weight: 700;
}

.preview-shell {
  position: relative;
  overflow: hidden;
  border-radius: 22px;
  aspect-ratio: 16 / 9;
  display: grid;
  background:
    radial-gradient(circle at top, rgba(79, 164, 255, 0.16), transparent 55%),
    linear-gradient(160deg, #111921, #06080d);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.preview-media {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0;
}

.preview-layer {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: opacity 180ms ease-out, transform 180ms ease-out;
  opacity: 0;
  transform: scale(1.01);
}

.preview-layer.active {
  opacity: 1;
  transform: scale(1);
}

.preview-empty {
  width: 100%;
  height: 100%;
}

.preview-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 16px;
  background: linear-gradient(180deg, transparent 48%, rgba(0, 0, 0, 0.42) 100%);
}

.preview-caption {
  display: grid;
  gap: 6px;
}

.preview-caption strong {
  font-size: 14px;
}

.preview-caption span {
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.pill {
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  font-size: 12px;
}

.info-list,
.action-list {
  padding-left: 18px;
  margin: 0;
}

.info-list li,
.action-list li {
  margin-bottom: 10px;
  color: var(--muted);
  line-height: 1.6;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 6px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.segmented-btn {
  min-height: 40px;
  padding: 0 16px;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
}

.segmented-btn.active {
  color: var(--text);
  background: rgba(79, 164, 255, 0.16);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.check-row input {
  width: 16px;
  height: 16px;
}

.helper-text {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

.device-item,
.log-item {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.log-item {
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
}

.log-item:hover {
  border-color: rgba(79, 164, 255, 0.22);
  background: rgba(255, 255, 255, 0.055);
}

.log-item.active {
  border-color: rgba(79, 164, 255, 0.42);
  background: rgba(79, 164, 255, 0.09);
  transform: translateY(-1px);
}

.log-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 8px;
}

.mini-panel {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.mini-panel strong {
  font-size: 13px;
}

.mini-panel span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.detail-stack {
  display: grid;
  gap: 12px;
}

.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.alert-box {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
}

.alert-box strong {
  font-size: 13px;
}

.alert-box span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.alert-box.success {
  border-color: rgba(36, 196, 107, 0.3);
  background: rgba(36, 196, 107, 0.08);
}

.alert-box.warning {
  border-color: rgba(243, 195, 76, 0.3);
  background: rgba(243, 195, 76, 0.08);
}

.alert-box.danger {
  border-color: rgba(255, 93, 93, 0.3);
  background: rgba(255, 93, 93, 0.08);
}

.timeline {
  display: grid;
  gap: 14px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.timeline-marker {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  margin-top: 6px;
  background: rgba(255, 255, 255, 0.18);
  border: 2px solid rgba(255, 255, 255, 0.08);
}

.timeline-item.success .timeline-marker {
  background: rgba(36, 196, 107, 0.85);
}

.timeline-item.failed .timeline-marker {
  background: rgba(255, 93, 93, 0.85);
}

.timeline-item.running .timeline-marker {
  background: rgba(243, 195, 76, 0.9);
}

.timeline-item.current .timeline-content {
  border-color: rgba(79, 164, 255, 0.35);
  background: rgba(79, 164, 255, 0.08);
  box-shadow: 0 0 0 1px rgba(79, 164, 255, 0.12) inset;
}

.timeline-item.current .timeline-marker {
  background: rgba(79, 164, 255, 0.95);
}

.timeline-content {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.timeline-line {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.timeline-evidence {
  display: grid;
  gap: 4px;
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
}

.timeline-evidence strong {
  font-size: 13px;
}

.timeline-evidence span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.key-value {
  display: grid;
  gap: 10px;
}

.key-value-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 10px;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
}

.key-value-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.key-value-row span {
  color: var(--muted);
}

.key-value-row strong {
  text-align: right;
}

.remote-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) 320px;
  gap: 18px;
}

.remote-panel {
  padding: 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.remote-grid {
  grid-template-columns: repeat(3, 1fr);
}

.remote-btn {
  min-height: 54px;
  border-radius: 16px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.remote-btn.primary {
  background: rgba(79, 164, 255, 0.18);
}

.remote-btn.warn {
  background: rgba(243, 195, 76, 0.2);
}

.remote-btn.danger {
  background: rgba(255, 93, 93, 0.18);
}

.learn-remote-shell {
  display: grid;
  gap: 14px;
  padding: 16px;
  border-radius: 22px;
  background:
    radial-gradient(circle at 50% 18%, rgba(79, 164, 255, 0.18), transparent 30%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.025));
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.learn-remote-stage {
  display: grid;
  place-items: center;
  gap: 6px;
  min-height: 108px;
  padding: 18px;
  text-align: center;
  border-radius: 18px;
  background: rgba(6, 10, 16, 0.5);
  border: 1px solid rgba(79, 164, 255, 0.18);
}

.learn-remote-stage span,
.learn-remote-stage small {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.learn-remote-stage strong {
  font-size: clamp(24px, 4.6vw, 42px);
  letter-spacing: 0.04em;
}

.learn-remote {
  display: grid;
  grid-template-columns: 84px minmax(180px, 1fr) 84px;
  grid-template-areas:
    ". power ."
    "left dpad right"
    "bottom bottom bottom";
  gap: 14px;
  align-items: center;
}

.learn-key-power {
  grid-area: power;
  justify-self: end;
  width: 78px;
  min-height: 78px;
  border-radius: 999px;
}

.learn-remote-side {
  display: grid;
  gap: 10px;
}

.learn-remote-side.left {
  grid-area: left;
}

.learn-remote-side.right {
  grid-area: right;
}

.learn-remote-dpad {
  grid-area: dpad;
  display: grid;
  grid-template-columns: repeat(3, minmax(66px, 1fr));
  grid-template-areas:
    ". up ."
    "left ok right"
    ". down .";
  gap: 10px;
  align-items: center;
}

.learn-key-up {
  grid-area: up;
}

.learn-key-left {
  grid-area: left;
}

.learn-key-ok {
  grid-area: ok;
}

.learn-key-right {
  grid-area: right;
}

.learn-key-down {
  grid-area: down;
}

.learn-remote-bottom {
  grid-area: bottom;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.learn-remote-btn {
  display: grid;
  place-items: center;
  gap: 4px;
  min-height: 64px;
  padding: 10px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.075);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
}

.learn-remote-btn span {
  font-weight: 700;
}

.learn-remote-btn small {
  color: var(--muted);
  font-size: 11px;
}

.learn-remote-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(79, 164, 255, 0.3);
}

.learn-remote-btn.active {
  background: rgba(79, 164, 255, 0.24);
  border-color: rgba(79, 164, 255, 0.78);
  box-shadow: 0 0 0 3px rgba(79, 164, 255, 0.12), 0 0 24px rgba(79, 164, 255, 0.22);
}

.learn-remote-btn.learned {
  background: rgba(36, 196, 107, 0.12);
  border-color: rgba(36, 196, 107, 0.34);
}

.learn-remote-btn.learned.active,
.learn-remote-btn.active:disabled {
  opacity: 1;
  background: rgba(79, 164, 255, 0.24);
  border-color: rgba(79, 164, 255, 0.78);
  box-shadow: 0 0 0 3px rgba(79, 164, 255, 0.12), 0 0 24px rgba(79, 164, 255, 0.22);
}

.learn-remote-btn.danger {
  color: #ffe6e6;
  background: rgba(255, 93, 93, 0.16);
  border-color: rgba(255, 93, 93, 0.28);
}

.learn-remote-btn:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.note {
  margin-top: 12px;
  color: var(--muted);
  line-height: 1.6;
  font-size: 13px;
}

.state-explainer {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
}

.state-explainer strong {
  font-size: 13px;
}

.state-explainer span {
  color: var(--muted);
  line-height: 1.6;
  font-size: 13px;
}

.state-explainer.active {
  border-color: rgba(243, 195, 76, 0.35);
  background: rgba(243, 195, 76, 0.08);
}

.state-explainer.muted {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
}

.badge.success {
  color: #dff7ea;
  background: rgba(36, 196, 107, 0.2);
}

.badge.warning {
  color: #fff2cf;
  background: rgba(243, 195, 76, 0.2);
}

.badge.danger {
  color: #ffe1e1;
  background: rgba(255, 93, 93, 0.2);
}

.badge.muted {
  color: #d4dee7;
  background: rgba(255, 255, 255, 0.08);
}

.empty-state {
  padding: 28px;
  border-radius: 18px;
  border: 1px dashed rgba(255, 255, 255, 0.12);
  text-align: center;
  color: var(--muted);
  line-height: 1.7;
}

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .two-col,
  .remote-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .main {
    padding: 16px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .login-card {
    padding: 24px;
  }

  .page-title {
    font-size: 24px;
  }

  .learn-remote {
    grid-template-columns: 1fr;
    grid-template-areas:
      "power"
      "dpad"
      "left"
      "right"
      "bottom";
  }

  .learn-key-power {
    justify-self: end;
  }

  .learn-remote-bottom {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
