:root {
  --bg-deep: #062a33;
  --bg-mid: #0a4a55;
  --accent: #2ec4b6;
  --text: #f2fbfa;
  --muted: #a8d5d0;
  --card: #0d3a44;
  --waste: #ffb000;
  --clean: #3ce06a;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100%;
}

body {
  font-family: "IBM Plex Sans Thai", "Sora", sans-serif;
  color: var(--text);
  background: var(--bg-deep);
  overflow-x: hidden;
}

.topbar {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 2;
  padding: 1rem 1.25rem;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.auth-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.auth-card {
  width: min(100%, 26rem);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  text-align: center;
}

.auth-title {
  font-size: clamp(1.8rem, 6vw, 2.4rem);
  font-weight: 700;
  line-height: 1.2;
}

.auth-lead {
  margin-bottom: 0.5rem;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  text-align: left;
  margin-top: 0.5rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.92rem;
  color: var(--muted);
}

.field input {
  border: 1px solid rgba(168, 213, 208, 0.28);
  background: rgba(4, 30, 38, 0.55);
  color: var(--text);
  border-radius: 0.55rem;
  padding: 0.75rem 0.85rem;
  font: inherit;
  outline: none;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(46, 196, 182, 0.18);
}

.field-password {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.field-password input {
  flex: 1;
  min-width: 0;
}

.btn-show-pass {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  padding: 0;
  position: relative;
}

.btn-show-pass .icon-eye {
  display: block;
  opacity: 0.9;
}

.btn-show-pass .icon-eye-off {
  display: none;
}

.btn-show-pass.is-visible .icon-eye-open {
  display: none;
}

.btn-show-pass.is-visible .icon-eye-off {
  display: block;
}

.ssid-pick {
  margin-top: 0.35rem;
  border: 1px solid rgba(168, 213, 208, 0.28);
  background: rgba(4, 30, 38, 0.55);
  color: var(--text);
  border-radius: 0.55rem;
  padding: 0.65rem 0.85rem;
  font: inherit;
  width: 100%;
}

.btn-scan-wifi {
  flex-shrink: 0;
  padding: 0.75rem 0.9rem;
  white-space: nowrap;
}

.btn-primary,
.btn-ghost {
  font: inherit;
  cursor: pointer;
  border-radius: 0.55rem;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.btn-primary {
  border: none;
  background: var(--accent);
  color: #043039;
  font-weight: 700;
  padding: 0.8rem 1rem;
  margin-top: 0.25rem;
}

.btn-primary:disabled {
  opacity: 0.65;
  cursor: wait;
}

.btn-ghost {
  border: 1px solid rgba(168, 213, 208, 0.35);
  background: transparent;
  color: var(--text);
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
}

.btn-primary:hover,
.btn-ghost:hover {
  transform: translateY(-1px);
}

.auth-error {
  color: #ffb4a8;
  font-size: 0.9rem;
  min-height: 1.2em;
}

.auth-ok {
  color: #8fd4a8;
  font-size: 0.9rem;
  min-height: 1.2em;
}

.atmosphere {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 90% 60% at 50% -10%, rgba(46, 196, 182, 0.35), transparent 55%),
    radial-gradient(ellipse 70% 50% at 80% 80%, rgba(14, 116, 144, 0.45), transparent 50%),
    linear-gradient(165deg, #041e26 0%, #0a4a55 45%, #063540 100%);
  animation: drift 14s ease-in-out infinite alternate;
}

.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      -12deg,
      transparent 0,
      transparent 18px,
      rgba(255, 255, 255, 0.015) 18px,
      rgba(255, 255, 255, 0.015) 19px
    );
  opacity: 0.7;
}

.hero {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 2rem;
  gap: 0.85rem;
}

.eyebrow {
  font-family: Sora, sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 0;
  animation: rise 0.9s ease forwards 0.15s;
}

h1 {
  font-size: clamp(2.4rem, 8vw, 4.5rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  text-shadow: 0 8px 40px rgba(0, 0, 0, 0.35);
  opacity: 0;
  animation: rise 0.9s ease forwards 0.35s;
}

.subtitle {
  max-width: 28rem;
  font-size: clamp(1rem, 2.5vw, 1.15rem);
  color: var(--muted);
  font-weight: 400;
  opacity: 0;
  animation: rise 0.9s ease forwards 0.55s;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes drift {
  from {
    filter: hue-rotate(0deg);
    transform: scale(1);
  }
  to {
    filter: hue-rotate(8deg);
    transform: scale(1.03);
  }
}

@media (prefers-reduced-motion: reduce) {
  .atmosphere,
  .eyebrow,
  h1,
  .subtitle {
    animation: none;
    opacity: 1;
  }
}

.topbar-spread {
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
}

.nav-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.95rem;
}

.nav-link:hover {
  text-decoration: underline;
}

.nav-brand {
  font-family: Sora, sans-serif;
  font-weight: 700;
  color: var(--accent);
  font-size: 0.95rem;
}

.nav-menu {
  position: relative;
}

.nav-menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 0.4rem);
  min-width: 12.5rem;
  display: flex;
  flex-direction: column;
  background: rgba(6, 42, 51, 0.96);
  border: 1px solid rgba(168, 213, 208, 0.28);
  border-radius: 0.55rem;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  z-index: 5;
}

.nav-menu-list[hidden] {
  display: none;
}

.nav-menu-list a,
.nav-menu-list button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: var(--text);
  font: inherit;
  padding: 0.7rem 0.9rem;
  text-decoration: none;
  cursor: pointer;
}

.nav-menu-list a:hover,
.nav-menu-list button:hover {
  background: rgba(46, 196, 182, 0.16);
}

.field select {
  border: 1px solid rgba(168, 213, 208, 0.28);
  background: rgba(4, 30, 38, 0.55);
  color: var(--text);
  border-radius: 0.55rem;
  padding: 0.75rem 0.85rem;
  font: inherit;
  outline: none;
}

.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(46, 196, 182, 0.18);
}

.hero-actions {
  margin-top: 1rem;
  opacity: 0;
  animation: rise 0.9s ease forwards 0.7s;
}

.btn-link {
  display: inline-block;
  text-decoration: none;
  margin-top: 0;
}

.page-app .atmosphere {
  opacity: 0.85;
}

.app-panel {
  position: relative;
  z-index: 1;
  max-width: 52rem;
  margin: 0 auto;
  padding: 4.5rem 1.25rem 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.panel-title {
  font-size: clamp(1.6rem, 4vw, 2rem);
}

.panel-lead {
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.panel-card {
  background: rgba(4, 30, 38, 0.55);
  border: 1px solid rgba(168, 213, 208, 0.2);
  border-radius: 0.75rem;
  padding: 1rem 1.1rem 1.15rem;
}

.panel-card h2 {
  font-size: 1.05rem;
  margin-bottom: 0.65rem;
}

.mono {
  font-family: Sora, monospace;
  word-break: break-all;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.85rem;
}

.break {
  word-break: break-all;
}

.list-block {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0;
  border-top: 1px solid rgba(168, 213, 208, 0.12);
}

.list-row:first-child {
  border-top: none;
  padding-top: 0;
}

.badge {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.1rem 0.4rem;
  border-radius: 0.3rem;
  font-size: 0.7rem;
  background: rgba(46, 196, 182, 0.2);
  color: var(--accent);
}

.badge.on {
  background: rgba(46, 196, 182, 0.25);
}

.badge.off {
  background: rgba(255, 180, 168, 0.18);
  color: #ffb4a8;
}

.btn-sm {
  padding: 0.45rem 0.7rem;
  font-size: 0.85rem;
  margin-top: 0;
  white-space: nowrap;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: flex-end;
}

.btn-danger {
  border-color: rgba(255, 180, 168, 0.45);
  color: #ffb4a8;
}

.ok-msg {
  color: #9df0c8;
}

.monitor {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 5rem 1.25rem 2rem;
}

.device-picker {
  width: min(100%, 28rem);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.device-picker select {
  width: 100%;
  border: 1px solid rgba(168, 213, 208, 0.28);
  background: rgba(4, 30, 38, 0.72);
  color: var(--text);
  border-radius: 0.55rem;
  padding: 0.7rem 0.8rem;
  font: inherit;
  outline: none;
}

.device-picker select:focus {
  border-color: var(--accent);
}

#mixView {
  width: min(100%, 28rem);
}

.mix-panel {
  width: 100%;
  background: rgba(6, 42, 51, 0.88);
  border: 1px solid rgba(168, 213, 208, 0.18);
  border-radius: 1rem;
  padding: 1.1rem 1.15rem 1.2rem;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
  box-sizing: border-box;
}

.mix-head {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.mix-ver {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted);
  font-family: Sora, sans-serif;
  font-size: 0.9rem;
  padding-top: 0.15rem;
}

.mix-sys-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin: 0 0 1rem;
  padding: 0.65rem 0.75rem;
  border-radius: 0.65rem;
  background: rgba(4, 30, 38, 0.45);
  border: 1px solid rgba(168, 213, 208, 0.16);
}

.mix-sys-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.mix-sys-label {
  font-family: Sora, sans-serif;
  font-size: 0.85rem;
  color: var(--muted);
}

.btn-sys-toggle {
  padding: 0.45rem 0.85rem;
  font-size: 0.9rem;
}

.btn-sys-toggle:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.online-dot {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  background: #f80000;
  box-shadow: 0 0 8px rgba(248, 0, 0, 0.55);
}

.online-dot.on {
  background: #00e000;
  box-shadow: 0 0 8px rgba(0, 224, 0, 0.55);
}

.mix-title {
  text-align: center;
}

.mix-title .eyebrow {
  opacity: 1;
  animation: none;
  letter-spacing: 0.12em;
}

.mix-title h1 {
  font-size: 1.7rem;
  opacity: 1;
  animation: none;
  text-shadow: none;
  margin-top: 0.15rem;
}

.mix-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
}

.mix-card {
  background: var(--card);
  border-radius: 0.7rem;
  padding: 0.7rem 0.8rem 0.75rem;
  min-height: 6.2rem;
}

.mix-card.waste {
  border: 1px solid var(--waste);
}

.mix-card.clean {
  border: 1px solid var(--clean);
}

.mix-label {
  font-size: 0.95rem;
  font-weight: 600;
}

.mix-card.waste .mix-label {
  color: var(--waste);
}

.mix-card.clean .mix-label {
  color: var(--clean);
}

.mix-value {
  font-family: Sora, sans-serif;
  font-size: 1.85rem;
  font-weight: 700;
  line-height: 1.2;
  margin: 0.25rem 0 0.1rem;
}

.mix-unit {
  color: var(--muted);
  font-size: 0.85rem;
}

.mix-vol {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.mix-vol.total-vol {
  margin: 0.35rem 0 0.15rem;
  color: var(--text);
}

.mix-total {
  margin-top: 0.7rem;
  background: var(--card);
  border-radius: 0.7rem;
  padding: 0.75rem 0.85rem 0.85rem;
}

.mix-total-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: baseline;
  gap: 0.5rem;
}

.mix-value.total {
  color: var(--accent);
  font-size: 1.7rem;
}

.ratio-bar {
  display: flex;
  height: 0.65rem;
  border-radius: 0.2rem;
  overflow: hidden;
  margin: 0.55rem 0 0.45rem;
  background: #2a4a52;
}

.ratio-waste {
  background: var(--waste);
}

.ratio-clean {
  background: var(--clean);
}

.ratio-legend {
  color: var(--text);
  font-size: 0.88rem;
}

.mix-meta {
  margin-top: 0.7rem;
  word-break: break-all;
}

