:root {
  color-scheme: light;
  --bg: #0b0f14;
  --surface: #151b22;
  --surface-alt: #1f2732;
  --text: #f5f7fa;
  --muted: #9bb0c4;
  --accent: #f4b860;
  --accent-strong: #ff9350;
  --danger: #ff6b6b;
  --shadow: rgba(0, 0, 0, 0.35);
  --panel-border: rgba(255, 255, 255, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  background: radial-gradient(circle at top, #1d2733 0%, #0b0f14 55%);
  color: var(--text);
  min-height: 100vh;
}

body.login-page {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 14px;
  padding: 24px;
}

.login-shell {
  width: min(420px, 100%);
}

.login-card {
  background: linear-gradient(140deg, var(--surface), var(--surface-alt));
  border-radius: 22px;
  padding: 24px;
  box-shadow: 0 24px 40px var(--shadow);
  border: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
}

.login-logo {
  width: 92px;
  height: auto;
}

.login-card h1 {
  margin: 0;
  font-size: 1.6rem;
}

.login-card .modal-status {
  text-align: center;
}

.login-card .wifi-password-form {
  width: 100%;
}

.login-card .wifi-password-actions {
  justify-content: center;
}

.app-footer {
  margin-top: 14px;
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0.03em;
}

.offline-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at top, rgba(12, 18, 26, 0.95), rgba(4, 6, 10, 0.98));
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 50;
}

.offline-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 10, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 70;
}

.modal.active {
  opacity: 1;
  pointer-events: all;
}

.modal-card {
  width: min(720px, 100%);
  max-height: 84vh;
  overflow: auto;
  background: linear-gradient(140deg, #1b2330, #111722);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.45);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.modal-header h3 {
  margin: 0;
}

.modal-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.wifi-connection-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wifi-connection-item {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(7, 10, 15, 0.6);
  padding: 12px;
}

.wifi-connection-item .btn {
  flex: 0 0 auto;
}

.wifi-connection-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.wifi-connection-meta strong,
.wifi-connection-meta span {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.wifi-connection-meta span {
  color: var(--muted);
  font-size: 0.85rem;
}

.wifi-current {
  color: #44d77b !important;
  font-weight: 600;
}

.wifi-password-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(7, 10, 15, 0.45);
}

.wifi-password-form[hidden] {
  display: none;
}

.wifi-password-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.85rem;
}

.wifi-password-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.wifi-rescan-actions {
  justify-content: center;
}

.offline-card {
  text-align: center;
  padding: 32px 36px;
  border-radius: 24px;
  background: linear-gradient(140deg, #1b2330, #111722);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.4);
}

.offline-card h2 {
  margin: 0 0 10px;
  font-size: clamp(1.6rem, 2.5vw, 2.2rem);
}

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

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 48px 20px 80px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  align-items: center;
  gap: 22px;
  margin-bottom: 32px;
  animation: fadeIn 0.6s ease-out;
}

.topbar > div:first-child {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--muted);
  font-size: 0.75rem;
}

h1 {
  font-size: clamp(2.1rem, 3vw, 3.2rem);
  margin: 10px 0 0;
}

.battery {
  display: flex;
  align-items: stretch;
  gap: 10%;
  justify-content: space-between;
  padding: 18px 18px;
  border-radius: 26px;
  background: linear-gradient(120deg, #1b2330, #131922);
  border: 1px solid var(--panel-border);
  box-shadow: 0 20px 35px var(--shadow);
  width: 100%;
  min-width: 0;
  overflow: hidden;
}

.battery-icon {
  flex: 0 0 calc(50% - 8px);
  max-width: calc(50% - 8px);
  width: 100%;
  height: auto;
  aspect-ratio: 2 / 1;
  border-radius: 8px;
  border: 2px solid var(--muted);
  position: relative;
  padding: 4px;
  display: flex;
  align-self: center;
  min-width: 0;
  overflow: visible;
}

.battery-icon::after {
  content: "";
  position: absolute;
  right: -7px;
  top: 33%;
  width: 7px;
  height: 34%;
  border-radius: 0 3px 3px 0;
  background: #c7d8ea;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12);
  z-index: 2;
}

.battery-bars {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 3px;
  width: 100%;
  align-items: stretch;
  min-height: 0;
  border-radius: 4px;
  overflow: hidden;
}

.battery-bars .bar {
  display: block;
  min-height: 0;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 1px;
  transition: background 0.3s ease;
}

.battery-bars.low-flash .bar:nth-child(1) {
  background: #ff4f4f;
  animation: batteryBlink 1s ease-in-out infinite;
}

.battery-bars.level-1 .bar:nth-child(1) {
  background: #ff4f4f;
}

.battery-bars.level-2 .bar:nth-child(-n + 2) {
  background: #ff7a39;
}

.battery-bars.level-3 .bar:nth-child(-n + 3) {
  background: #ffb347;
}

.battery-bars.level-4 .bar {
  background: #44d77b;
}

.battery-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  justify-content: center;
  align-items: flex-start;
  flex: 0 0 40%;
  max-width: 40%;
  min-width: 0;
  padding-right: 2px;
}

.battery-label {
  margin: 0;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.battery-state {
  margin: 0;
  font-size: 0.85rem;
  color: var(--danger);
  min-height: 1.1rem;
}

.battery-state:empty {
  display: none;
}

.battery-voltage {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.15;
  color: var(--muted);
  min-height: 0;
}

.battery-status {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  font-size: 1rem;
  font-weight: 600;
  flex: 0 0 auto;
  max-width: none;
  margin-top: 0;
  line-height: 1;
}

.battery-status .charge {
  font-size: 1.4rem;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.battery-status .charge.blink-slow {
  animation: chargeBlink 1.6s ease-in-out infinite;
}

.battery-status .charge.blink-fast {
  animation: chargeBlink 0.6s ease-in-out infinite;
}

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

.column {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.reboot-footer {
  width: 100%;
  display: flex;
  gap: 12px;
  grid-column: 1 / -1;
}

.reboot-footer .btn {
  flex: 0 0 50%;
  max-width: 50%;
}

.panel {
  background: linear-gradient(140deg, var(--surface), var(--surface-alt));
  border-radius: 22px;
  padding: 22px;
  box-shadow: 0 24px 40px var(--shadow);
  border: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: riseIn 0.5s ease-out;
}



.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-header h2 {
  margin: 0;
  font-size: 1.3rem;
}

.status {
  font-size: 0.85rem;
  color: var(--muted);
}

.mobile-total-speed {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  margin-bottom: 16px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(140deg, rgba(244, 184, 96, 0.18), rgba(7, 10, 15, 0.7));
}

.mobile-total-speed .mobile-total-label {
  color: var(--muted);
  font-size: 0.85rem;
}

.mobile-total-speed strong {
  font-size: 1rem;
}

.preview-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.preview-controls .btn {
  padding: 8px 12px;
  font-size: 0.8rem;
}

.preview-frame {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  background: #0b0f14;
  border: 1px solid rgba(255, 255, 255, 0.06);
  aspect-ratio: 16 / 9;
}

.preview-loader {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  color: var(--muted);
  background: rgba(7, 10, 15, 0.6);
  letter-spacing: 0.02em;
  transition: opacity 0.2s ease;
}

.preview-frame.is-loading .preview-loader {
  opacity: 1;
  visibility: visible;
}

.preview-frame.is-loaded .preview-loader {
  opacity: 0;
  visibility: hidden;
}

.preview-frame img,
.preview-frame video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.preview-frame.is-loading img,
.preview-frame.is-loading video {
  opacity: 0;
  visibility: hidden;
}

.net-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stream-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.net-item {
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(7, 10, 15, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.net-item.net-total {
  padding: 18px 20px;
  border-color: rgba(244, 184, 96, 0.6);
  background: linear-gradient(140deg, rgba(244, 184, 96, 0.18), rgba(7, 10, 15, 0.7));
  box-shadow: 0 18px 30px rgba(0, 0, 0, 0.25);
}

.net-item.net-total .net-title {
  font-size: 1.1rem;
  letter-spacing: 0.02em;
}

.net-item.net-total .net-meta {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.net-item.status-ok {
  border-color: rgba(68, 215, 123, 0.7);
  background: rgba(68, 215, 123, 0.08);
}

.net-item.status-warn {
  border-color: rgba(255, 179, 71, 0.7);
  background: rgba(255, 179, 71, 0.08);
}

.net-item.status-error {
  border-color: rgba(255, 79, 79, 0.7);
  background: rgba(255, 79, 79, 0.08);
}

.net-item.speed-warning {
  border-color: rgba(255, 179, 71, 0.7);
  background: rgba(255, 179, 71, 0.12);
}

.net-item.speed-low {
  border-color: rgba(255, 79, 79, 0.75);
  background: rgba(255, 79, 79, 0.14);
}

.stream-item {
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(7, 10, 15, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stream-item.status-ok {
  border-color: rgba(68, 215, 123, 0.7);
  background: rgba(68, 215, 123, 0.08);
}

.stream-item.status-warn {
  border-color: rgba(255, 179, 71, 0.7);
  background: rgba(255, 179, 71, 0.08);
}

.stream-item.status-error {
  border-color: rgba(255, 79, 79, 0.7);
  background: rgba(255, 79, 79, 0.08);
}

.stream-item h3 {
  margin: 0;
  font-size: 1rem;
}

.stream-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 0.85rem;
}

.stream-meta span {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.stream-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stream-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

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

.stream-actions .btn {
  flex: 1 1 calc(50% - 4px);
  max-width: calc(50% - 4px);
}

.net-item h3 {
  margin: 0;
  font-size: 1rem;
}

.net-title.connected {
  color: #44d77b;
}

.net-title.disconnected {
  color: #ff4f4f;
}

.net-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px 12px;
  color: var(--muted);
  font-size: 0.85rem;
}

.net-meta span {
  display: block;
}

#temp1Value,
#temp2Value,
#fanValue {
  white-space: nowrap;
}

.net-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

.net-actions .btn {
  width: 100%;
  padding: 8px 14px;
  font-size: 0.82rem;
}


.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

.field input,
.field select {
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(7, 10, 15, 0.6);
  color: var(--text);
  padding: 10px 12px;
  font-family: inherit;
}

.btn {
  border: none;
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn.primary {
  background: linear-gradient(120deg, var(--accent), var(--accent-strong));
  color: #1b1206;
}

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

.btn.danger {
  background: linear-gradient(120deg, #ff8c8c, var(--danger));
  color: #2f0707;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.25);
}

.logo {
  height: 64px;
  width: auto;
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

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

@keyframes batteryBlink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.2;
  }
}

@keyframes chargeBlink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.25;
  }
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 800px) {
  .topbar {
    display: block;
    width: 100%;
    max-width: 100%;
  }

  .topbar > div:first-child {
    width: 100%;
    justify-content: center;
    margin-bottom: 22px;
    text-align: center;
  }

  .topbar > * {
    width: 100%;
    min-width: 0;
  }

  .app-title {
    display: none;
  }

  .battery {
    width: 100%;
    inline-size: 100%;
    max-width: none;
    gap: 10%;
    padding: 14px 14px;
    justify-self: stretch;
    margin: 0;
  }

  .battery-icon {
    flex: 0 0 calc(50% - 6px);
    max-width: calc(50% - 6px);
    min-width: 0;
  }

  .battery-meta {
    flex: 0 0 40%;
    max-width: 40%;
    min-width: 0;
  }

  .battery-label {
    font-size: 0.72rem;
  }

  .battery-voltage {
    font-size: 0.82rem;
  }

  .layout {
    grid-template-columns: 1fr;
    width: 100%;
    max-width: 100%;
  }

  .preview-controls {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 800px) {
  .page {
    padding-left: 12px;
    padding-right: 12px;
  }

  .topbar {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    margin-bottom: 22px !important;
  }

  .topbar > div:first-child,
  .topbar > * {
    display: block;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0;
  }

  .topbar > #batteryCard {
    display: flex !important;
  }

  .topbar > div:first-child {
    margin-bottom: 14px;
  }

  .layout {
    width: 100% !important;
    max-width: 100% !important;
  }

  .mobile-total-speed {
    display: flex;
  }

  .net-item.net-total {
    display: none;
  }
}
