:root{
  --bg: #0a0c0f;
  --surface: #14171c;
  --surface-2: #1b1f26;
  --border: #262b33;
  --text: #e4e7eb;
  --muted: #6b7280;
  --bad: #e25c5c;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*{ box-sizing: border-box; }
html,body{ height:100%; }
body{
  margin:0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  padding: 28px 20px;
}

.page-header{
  max-width: 1100px;
  margin: 0 auto 20px;
  display:flex;
  align-items:baseline;
  gap: 10px;
}
.page-header h1{
  font-size: 17px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}
.page-header span{
  font-size: 13px;
  color: var(--muted);
}

.grid{
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}
@media (max-width: 620px){
  .grid{ grid-template-columns: 1fr; }
}

.unit-panel{
  --accent: #4fd1c5;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color 0.3s ease;
}
.unit-panel[data-mode="HEAT"]{ --accent: #f0954b; }
.unit-panel[data-mode="DRY"]{ --accent: #c9a646; }
.unit-panel[data-mode="FAN_ONLY"]{ --accent: #8b95a6; }
.unit-panel[data-mode="AUTO"]{ --accent: #9d7cd8; }

.hidden{ display: none !important; }

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom: 18px;
}
.topbar-right{
  display:flex;
  align-items:center;
  gap: 12px;
}
.unit-name{
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.status{
  display:flex;
  align-items:center;
  gap:6px;
  font-size: 12px;
  color: var(--muted);
}
.dot{
  width:7px; height:7px; border-radius:50%;
  background: var(--bad);
}
.dot.online{
  background: var(--accent);
  animation: pulse 2.4s infinite;
}
@keyframes pulse{
  0%{ box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 50%, transparent); }
  70%{ box-shadow: 0 0 0 6px transparent; }
  100%{ box-shadow: 0 0 0 0 transparent; }
}

.dial-wrap{
  position: relative;
  width: 180px;
  height: 180px;
  margin: 0 auto 18px;
}
.dial-wrap svg{ width:100%; height:100%; transform: rotate(-90deg); }
.dial-track{ fill:none; stroke: var(--surface-2); stroke-width: 9; }
.dial-fill{
  fill:none;
  stroke: var(--accent);
  stroke-width: 9;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s ease, stroke 0.4s ease;
}
.dial-center{
  position:absolute; inset:0;
  display:flex; flex-direction:column;
  align-items:center; justify-content:center;
  gap: 2px;
}
.indoor-temp{ font-size: 38px; font-weight: 600; letter-spacing: -0.02em; }
.indoor-label{ font-size: 10px; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; }
.target-row{
  display:flex; align-items:center; gap: 6px;
  font-size: 12px; color: var(--muted);
  margin-top: 6px;
}
.target-row .target-val{ color: var(--text); font-weight: 600; }

.stepper{
  display:flex; align-items:center; justify-content:center;
  gap: 14px; margin-bottom: 16px;
}
.stepper button{
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 17px;
  font-family: var(--font);
  cursor: pointer;
}
.stepper button:active{ transform: scale(0.95); }
.stepper .target{ font-size: 18px; font-weight: 600; min-width: 56px; text-align:center; }

.row{ display:flex; gap: 7px; margin-bottom: 9px; flex-wrap: wrap; }
.pill{
  flex:1;
  min-width: 50px;
  padding: 8px 0;
  text-align:center;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  user-select: none;
}
.pill.active{
  border-color: var(--accent);
  color: var(--bg);
  background: var(--accent);
  font-weight: 600;
}

.toggles{ display:flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.toggle{
  flex: 1 1 calc(50% - 4px);
  min-width: 110px;
  display:flex; align-items:center; justify-content:space-between;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 12px;
  color: var(--muted);
}
.switch{
  position: relative;
  width: 34px; height: 18px;
  border-radius: 999px;
  background: var(--border);
  cursor: pointer;
  flex-shrink: 0;
}
.switch::after{
  content:"";
  position:absolute; top:2px; left:2px;
  width:14px; height:14px;
  border-radius:50%;
  background: var(--muted);
  transition: all 0.2s ease;
}
.switch.on{ background: color-mix(in srgb, var(--accent) 35%, var(--surface-2)); }
.switch.on::after{ left: 18px; background: var(--accent); }

.power-switch{ width: 44px; height: 23px; }
.power-switch::after{ width: 17px; height: 17px; }
.power-switch.on::after{ left: 23px; }

.footer{
  margin-top: 12px;
  font-size: 10px;
  color: var(--muted);
  text-align: center;
}
.error{
  margin-top: 10px;
  font-size: 11px;
  color: var(--bad);
  text-align: center;
  display:none;
}
.empty-state{
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* --- device pairing overlay --- */
.enroll-overlay{
  position: fixed;
  inset: 0;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}
.enroll-card{
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  text-align: center;
}
.enroll-card h2{
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.enroll-intro, .enroll-hint{
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  margin: 0 0 18px;
}
.enroll-hint{ margin: 16px 0 0; }
.enroll-input{
  width: 100%;
  padding: 11px 12px;
  margin-bottom: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
}
.enroll-input:focus{ outline: none; border-color: #4fd1c5; }
.enroll-btn{
  width: 100%;
  padding: 11px 0;
  border-radius: 10px;
  border: 1px solid #4fd1c5;
  background: #4fd1c5;
  color: var(--bg);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.enroll-btn:disabled{ opacity: 0.5; cursor: default; }
.enroll-code{
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
  margin: 8px 0 6px;
  color: #4fd1c5;
}
.enroll-countdown{
  font-size: 12px;
  color: var(--muted);
}
.enroll-error{
  margin-top: 14px;
  font-size: 12px;
  color: var(--bad);
}
