:root {
  color-scheme: dark;
  --bg: #2b3038;
  --card: #3a414b;
  --card-soft: #444c58;
  --line: rgba(190, 198, 214, 0.2);
  --line-soft: rgba(190, 198, 214, 0.1);
  --text: #f3f7ff;
  --muted: #c0cadb;
  --cyan: #19c9ef;
  --cyan-soft: rgba(25, 201, 239, 0.12);
  --emerald-soft: rgba(16, 185, 129, 0.2);
  --amber-soft: rgba(234, 179, 8, 0.2);
  --rose-soft: rgba(244, 114, 182, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.page {
  min-height: 100vh;
  padding: 22px 26px;
}

.shell {
  width: 100%;
  margin: 0;
  display: grid;
  gap: 24px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.hero {
  padding: 26px 24px;
  display: flex;
  gap: 28px;
  justify-content: space-between;
  align-items: center;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: rgba(103, 232, 249, 0.8);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 37px;
  font-weight: 600;
  letter-spacing: -0.03em;
}

h2 {
  font-size: 18px;
  font-weight: 500;
}

h3 {
  font-size: 20px;
  font-weight: 600;
}

.hero-copy,
.muted,
.field-label,
.metric-card span,
.device-card small,
.video-path,
.video-meta,
.activity-item,
.stack-title,
.form-stack label span {
  color: var(--muted);
}

.hero-copy {
  margin-top: 10px;
  max-width: 760px;
  font-size: 15px;
  line-height: 1.45;
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
}

.metric-card,
.device-card,
.inner-card,
.mini-card,
.activity-item,
.empty-state {
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
}

.metric-card {
  padding: 14px 16px;
  min-width: 122px;
  background: #4a5360;
}

.metric-card span {
  display: block;
  font-size: 12px;
}

.metric-card strong {
  display: block;
  margin-top: 6px;
  font-size: 19px;
  font-weight: 600;
}

.layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 340px;
  gap: 24px;
}

.sidebar-panel,
.main-column,
.right-column {
  display: grid;
  gap: 24px;
}

.sidebar-panel,
.main-column > .card,
.right-column > .card {
  padding: 20px;
}

.sidebar-panel {
  align-content: start;
}

.section-head,
.device-header,
.action-row,
.hotspot-top,
.video-head,
.video-row {
  display: flex;
  align-items: center;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #4a5360;
  color: var(--text);
  cursor: pointer;
}

.icon-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.section-head,
.device-header,
.hotspot-top {
  justify-content: space-between;
  gap: 16px;
}

.device-header {
  margin-bottom: 18px;
}

.device-heading {
  display: grid;
  gap: 8px;
}

.title-row,
.status-tags {
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.limit-control {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.limit-input {
  width: 96px;
  padding: 8px 10px;
}

.limit-edit-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.input {
  width: 100%;
  border: 1px solid var(--line);
  background: #0b1120;
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text);
  font-size: 14px;
}

.btn {
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.btn-primary {
  border: none;
  background: var(--cyan);
  color: #020617;
}

.btn-ghost {
  border: 1px solid var(--line);
  background: #4a5360;
  color: var(--text);
}

.btn.is-active {
  border-color: transparent;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.btn.is-active.connect-active {
  background: rgba(16, 185, 129, 0.92);
  color: #04130d;
}

.btn.is-active.disconnect-active {
  background: rgba(244, 63, 94, 0.92);
  color: #1a070d;
}

.btn.is-active.hotspot-active {
  background: rgba(234, 179, 8, 0.92);
  color: #1a1302;
}

.btn:disabled,
.input:disabled {
  opacity: 0.5;
  cursor: default;
}

.device-list,
.activity-list {
  display: grid;
  gap: 12px;
}

.device-list {
  margin-top: 16px;
  gap: 14px;
}

.device-card {
  padding: 18px 16px 14px;
  cursor: pointer;
  background: #434b57;
  min-height: 144px;
}

.device-card.active {
  border-color: rgba(25, 201, 239, 0.95);
  background: linear-gradient(180deg, rgba(58, 92, 113, 0.96), rgba(66, 102, 124, 0.92));
  box-shadow: inset 0 0 0 1px rgba(25, 201, 239, 0.18);
}

.device-top-row,
.device-stats {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.device-top-row {
  align-items: flex-start;
}

.device-actions {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 132px;
  justify-content: flex-end;
}

.device-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
}

.device-host {
  margin-top: 6px;
  display: block;
  font-size: 14px;
  color: #d1d9e8;
}

.device-stats {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.device-delete-btn {
  width: 28px;
  height: 28px;
  border: 1px solid rgba(244, 114, 182, 0.28);
  border-radius: 999px;
  background: rgba(244, 114, 182, 0.14);
  color: #ffb1c2;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.device-delete-btn:hover {
  background: rgba(244, 114, 182, 0.22);
}

.mini-info {
  min-width: 0;
  border-radius: 6px;
  background: #4c5562;
  padding: 7px 9px 6px;
  min-height: 30px;
}

.device-stats .field-label {
  font-size: 10px;
}

.device-stats .mini-info div:last-child {
  font-size: 12px;
  line-height: 1.2;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 96px;
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 999px;
  line-height: 1;
  text-align: center;
}

.badge.online {
  background: var(--emerald-soft);
  color: #6ef2b7;
}

.badge.hotspot {
  background: var(--amber-soft);
  color: #ffd84d;
}

.badge.offline {
  background: var(--rose-soft);
  color: #ff9fb3;
}

.badge.connected {
  background: rgba(249, 115, 22, 0.2);
  color: #fdba74;
}

.badge.agent {
  background: rgba(34, 211, 238, 0.16);
  color: #67e8f9;
}

.top-grid {
  display: grid;
  grid-template-columns: 0.95fr 1.9fr;
  gap: 16px;
}

.inner-card {
  padding: 16px;
  background: var(--card-soft);
}

.inner-title {
  margin-bottom: 14px;
  font-size: 14px;
  color: var(--muted);
}

.field-list,
.form-stack {
  display: grid;
  gap: 12px;
}

.btn-ready {
  border: none;
  background: var(--cyan);
  color: #020617;
  box-shadow: 0 0 0 1px rgba(25, 201, 239, 0.18), 0 0 24px rgba(25, 201, 239, 0.18);
}

.drawer-shell {
  position: fixed;
  inset: 0;
  z-index: 50;
}

.modal-shell {
  position: fixed;
  inset: 0;
  z-index: 60;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(3, 8, 20, 0.6);
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(3, 8, 20, 0.7);
}

.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(420px, 100vw);
  height: 100%;
  padding: 28px 24px;
  border-left: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(20, 27, 49, 0.99), rgba(9, 15, 30, 0.99));
  box-shadow: -18px 0 48px rgba(0, 0, 0, 0.28);
  overflow-y: auto;
  animation: slideLeft 0.24s ease;
}

.modal-panel {
  position: relative;
  width: min(760px, calc(100vw - 32px));
  max-height: min(720px, calc(100vh - 32px));
  margin: 16px auto;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(20, 27, 49, 0.99), rgba(9, 15, 30, 0.99));
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 18px;
  animation: modalRise 0.18s ease;
}

.drawer-panel .section-head {
  margin-bottom: 18px;
}

.field-box {
  border-radius: 6px;
  background: #4a5360;
  border: 1px solid var(--line);
  padding: 10px 12px;
}

.hotspot-name {
  font-size: 20px;
  font-weight: 500;
}

.hotspot-right {
  text-align: right;
}

.hotspot-time {
  color: #fcd34d;
  font-size: 22px;
  font-weight: 600;
}

.progress-track {
  height: 13px;
  border-radius: 6px;
  overflow: hidden;
  background: #323844;
  margin: 16px 0;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 6px;
  background: #fcd34d;
  transition: width 0.2s ease;
}

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

.mini-card {
  padding: 12px;
}

.table-card {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #414855;
}

.video-status-card {
  margin-top: 16px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #454d59;
  display: grid;
  gap: 14px;
}

.video-status-main {
  display: grid;
  gap: 6px;
}

.current-video-name {
  font-size: 20px;
  font-weight: 600;
  color: #f8fafc;
}

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

.upload-progress-panel {
  display: grid;
  gap: 8px;
}

.upload-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
}

.upload-stage {
  display: grid;
  gap: 6px;
}

.upload-stage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
}

.upload-progress-track {
  margin: 0;
  background: #323844;
}

.upload-progress-fill {
  background: var(--cyan);
}

.upload-progress-fill.is-syncing {
  width: 100% !important;
  background: linear-gradient(90deg, rgba(25, 201, 239, 0.3) 0%, rgba(25, 201, 239, 1) 50%, rgba(25, 201, 239, 0.3) 100%);
  background-size: 220px 100%;
  animation: upload-sync-flow 1.2s linear infinite;
}

.upload-progress-fill.is-pending {
  background: linear-gradient(90deg, rgba(25, 201, 239, 0.2) 0%, rgba(25, 201, 239, 0.9) 50%, rgba(25, 201, 239, 0.2) 100%);
  background-size: 180px 100%;
  animation: upload-sync-flow 1.4s linear infinite;
}

@keyframes upload-sync-flow {
  from {
    background-position: 220px 0;
  }
  to {
    background-position: 0 0;
  }
}

.video-head,
.video-row {
  display: grid;
  grid-template-columns: 1.7fr 1fr 120px 220px;
  gap: 12px;
}

.video-head {
  padding: 14px 16px;
  background: #4a5360;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #d8e1f0;
}

.video-row {
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  background: #414855;
}

.video-row.current {
  background: linear-gradient(180deg, rgba(25, 201, 239, 0.12), rgba(25, 201, 239, 0.04));
}

.video-actions {
  display: flex;
  gap: 8px;
}

.toast {
  margin-top: 16px;
  border-radius: 8px;
  border: 1px solid rgba(34, 211, 238, 0.3);
  background: var(--cyan-soft);
  color: #cffafe;
  padding: 14px 16px;
}

.console-shell {
  min-height: 300px;
  max-height: 420px;
  margin-top: 16px;
  padding: 18px 18px 16px;
  border-radius: 10px;
  border: 1px solid rgba(85, 103, 145, 0.35);
  background: #010409;
  color: #d1fae5;
  font-family: Consolas, "Courier New", monospace;
  font-size: 15px;
  overflow: hidden;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
  cursor: text;
}

.console-output {
  display: block;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  user-select: text;
  order: 1;
  line-height: 1;
}

.console-block {
  display: block;
  margin: 0;
  padding: 0;
}

.console-line,
.console-entry {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0;
  line-height: 1;
  margin: 0;
  padding: 0;
}

.console-entry {
  order: 2;
  user-select: text;
}

.console-prompt,
.console-prompt-text {
  display: inline-block;
  color: #7dd3fc;
  white-space: nowrap;
  flex: 0 0 auto;
  margin-right: 8px;
  line-height: 1;
}

.console-prompt::before,
.console-prompt-text::before {
  content: "";
  display: inline-block;
  width: 0;
}

.console-command {
  display: inline-block;
  color: #f8fafc;
  word-break: break-word;
  user-select: text;
  flex: 1 1 auto;
  min-width: 0;
  line-height: 1;
}

.console-stream {
  display: block;
  color: #86efac;
  white-space: pre-wrap;
  word-break: break-word;
  user-select: text;
  margin-left: 0;
  margin-top: 0;
  margin-bottom: 0;
  padding: 0;
  line-height: 1;
}

.console-stream.error {
  color: #fda4af;
}

.console-block + .console-block {
  margin-top: 0;
}

.console-input {
  display: inline-block;
  min-width: 0;
  flex: 1;
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  outline: none;
  color: #f8fafc;
  font: inherit;
  line-height: 1;
  user-select: text;
  width: 100%;
}

.console-input::placeholder {
  color: #4b5b7b;
}

.console-input:read-only {
  opacity: 0.55;
}

.stack-title {
  margin-bottom: 14px;
}

.activity-item {
  padding: 12px 14px;
  background: #454d59;
}

.empty-state {
  padding: 16px;
}

.file-upload {
  position: relative;
  overflow: hidden;
}

.file-upload input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.video-log-content {
  min-height: 240px;
  max-height: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0b1120;
  padding: 16px;
  color: #dbeafe;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.hidden {
  display: none;
}

@keyframes slideLeft {
  from {
    opacity: 0;
    transform: translateX(22px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes modalRise {
  from {
    opacity: 0;
    transform: translateY(18px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@media (max-width: 900px) {
  .hero {
    flex-direction: column;
    align-items: stretch;
  }

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

  .top-grid {
    grid-template-columns: 1fr;
  }

  .mini-grid {
    grid-template-columns: 1fr;
  }

  .video-head,
  .video-row {
    grid-template-columns: 1fr;
  }
}
