:root {
  --bg: #0f1420;
  --card: #182031;
  --card-line: #26314a;
  --text: #e8edf7;
  --muted: #8d9ab5;
  --accent: #4c8dff;
  --on: #2ea86a;
  --off: #d64c4c;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px 32px;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.view { display: flex; flex-direction: column; gap: 16px; flex: 1; }
/* display у .view перебивает штатное hidden -> прячем явно. */
.view[hidden] { display: none; }
#login-view { justify-content: center; }

h1 { font-size: 1.35rem; margin: 0; letter-spacing: -0.01em; }
.subtitle { margin: 4px 0 0; color: var(--muted); font-size: 0.85rem; }

.card {
  background: var(--card);
  border: 1px solid var(--card-line);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }

label { font-size: 0.8rem; color: var(--muted); margin-bottom: -6px; }

input {
  background: #0e1524;
  border: 1px solid var(--card-line);
  border-radius: 10px;
  padding: 14px;
  color: var(--text);
  font-size: 16px; /* < 16px заставляет iOS Safari зумить при фокусе */
  width: 100%;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn {
  border: 0;
  border-radius: 12px;
  padding: 16px;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  min-height: 52px;
  transition: opacity 0.15s, transform 0.05s;
}
.btn:active:not(:disabled) { transform: scale(0.985); }
.btn:disabled { opacity: 0.5; cursor: default; }

.btn-primary { background: var(--accent); }
.btn-on { background: var(--on); }
.btn-off { background: var(--off); }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--card-line);
  color: var(--muted);
}

.btn-icon {
  background: transparent;
  border: 1px solid var(--card-line);
  color: var(--muted);
  border-radius: 10px;
  min-width: 44px;
  min-height: 44px;
  font-size: 1.1rem;
  cursor: pointer;
  flex-shrink: 0;
}

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

.status-card { gap: 14px; }
.status-row { display: flex; align-items: center; justify-content: space-between; }
.status-label { color: var(--muted); font-size: 0.9rem; }

.badge {
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
}
.badge-on { background: rgba(46, 168, 106, 0.16); color: #6ee7a8; }
.badge-off { background: rgba(214, 76, 76, 0.16); color: #ff9b9b; }
.badge-unknown { background: rgba(141, 154, 181, 0.14); color: var(--muted); }

.updated { margin: 0; font-size: 0.75rem; color: var(--muted); }

.error {
  margin: 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(214, 76, 76, 0.14);
  color: #ff9b9b;
  font-size: 0.85rem;
}

.loading { opacity: 0.55; pointer-events: none; }

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(24px + env(safe-area-inset-bottom));
  background: #26314a;
  color: var(--text);
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 0.88rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 10;
  max-width: calc(100vw - 32px);
  text-align: center;
}

.toast[hidden], .error[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
