* {
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  background: #f4f7fb;
  color: #1f2937;
}

/* ── Login page ─────────────────────────────────────── */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  background: #fff;
  border: 1px solid #d9e2ec;
  border-radius: 16px;
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 8px 24px rgba(15,23,42,0.08);
}

.login-title {
  margin: 0 0 28px;
  font-size: 1.4rem;
  text-align: center;
  color: #1e3a5f;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.88rem;
  font-weight: 600;
  color: #374151;
}

.login-input {
  padding: 9px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.login-input:focus { border-color: #2563eb; }

.login-btn {
  display: block;
  width: 100%;
  padding: 11px;
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  border: none;
  margin-top: 4px;
}

.login-btn--primary {
  background: #1e3a5f;
  color: #fff;
}
.login-btn--primary:hover { background: #16305a; }

.login-btn--oidc {
  background: #fff;
  color: #1e3a5f;
  border: 2px solid #1e3a5f;
  margin-top: 0;
}
.login-btn--oidc:hover { background: #eef2f7; }

.login-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 14px;
  color: #9ca3af;
  font-size: 0.85rem;
}
.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #e5e7eb;
}

.login-msg {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  margin: 0 0 16px;
}
.login-msg--error { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.login-msg--info  { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; }

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.page-header h1 {
  margin: 0;
  font-size: 2rem;
}

.admin-link {
  text-decoration: none;
  color: #4a5568;
  border: 1px solid #cbd5e0;
  border-radius: 8px;
  padding: 6px 8px;
  line-height: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.admin-link:hover { background: #f1f5f9; color: #1a202c; }

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

.logout-btn { background: none; 
  border: 1px solid #cbd5e0; 
  border-radius: 8px; 
  cursor: pointer; 
  color: #4a5568; 
  padding: 6px 8px; 
  line-height: 0; 
  display: inline-flex; 
  align-items: center; 
  justify-content: center; 
} 
  
.logout-btn:hover { 
  background: #f1f5f9; 
  color: #1a202c; 
}

.back-link {
  font-size: 1rem;
  text-decoration: none;
  color: #4a5568;
  padding: 6px 14px;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
}
.back-link:hover { background: #edf2f7; }

/* Tab navigation */
.tab-nav {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 2px solid #d9e2ec;
}
.tab-btn {
  padding: 8px 20px;
  font-size: 1rem;
  border: none;
  background: none;
  cursor: pointer;
  color: #4a5568;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  font-family: inherit;
}
.tab-btn:hover { color: #1a202c; }
.tab-btn.active { color: #2563eb; border-bottom-color: #2563eb; font-weight: 600; }

.tab-panel.hidden { display: none; }

/* Admin table */
.admin-panel { max-width: 900px; }
.admin-section { margin-bottom: 36px; }
.admin-section h2 { font-size: 1.1rem; margin: 0 0 10px; color: #1f2937; }
.log-count { font-size: 0.85rem; color: #6b7280; font-weight: 400; }
.admin-form-inline,
.admin-form-grid {
  display: grid;
  gap: 10px;
  margin: 10px 0 14px;
}

.admin-form-inline {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  align-items: end;
}

.admin-form-inline label,
.admin-form-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.82rem;
  color: #4b5563;
}

.admin-form-grid {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  align-items: end;
}

.admin-form-grid--room-row {
  grid-template-columns: 1.2fr 1.5fr 1.5fr auto;
  align-items: center;
}

.admin-form-grid--alert-row {
  grid-template-columns: 1fr 1fr 1fr 1.2fr 1fr 1fr 1fr 0.8fr auto;
  align-items: center;
  gap: 8px;
}

.admin-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
}

.topology-villages {
  display: grid;
  gap: 18px;
}

.village-block {
  border-radius: 14px;
  padding: 14px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: linear-gradient(180deg, rgba(255,255,255,0.7), rgba(255,255,255,0.9));
}

.village-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
}

.village-color-tag {
  font-size: 0.8rem;
  color: #334155;
  background: rgba(255,255,255,0.65);
  border-radius: 999px;
  padding: 3px 10px;
}

.village-add-house {
  background: rgba(255,255,255,0.72);
  border: 1px solid rgba(15,23,42,0.08);
  border-radius: 10px;
  padding: 10px;
}

.village-houses {
  display: grid;
  gap: 12px;
  margin-top: 10px;
}

.topology-house-card {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 12px;
}

.house-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.house-header h3 {
  margin: 0;
}

.house-title-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.house-edit-btn {
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #334155;
  border-radius: 8px;
  padding: 2px 8px;
  cursor: pointer;
  line-height: 1.2;
  font-size: 0.9rem;
}

.house-edit-btn:hover {
  background: #eef2f7;
  border-color: #94a3b8;
}

.topology-area-create-bottom {
  display: flex;
  justify-content: flex-end;
}

.modal-context {
  margin: 0 0 10px;
  color: #475569;
  font-size: 0.9rem;
}

.modal-warning {
  margin: 8px 0 0;
  color: #b91c1c;
  font-size: 0.85rem;
}

.admin-form-inline--end {
  justify-items: end;
}

#delete-room-form {
  margin-top: 8px;
}

#create-house-form {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #e5e7eb;
}

.topology-room-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.topology-room-card {
  background: #f8fafc;
  border: 1px solid #dbe4ee;
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.topology-room-card:hover,
.topology-room-card:focus {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(15,23,42,0.09);
  border-color: #93c5fd;
  outline: none;
}

.topology-room-card h4 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.topology-room-card dl,
.cloud-device-card dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 8px;
  font-size: 0.84rem;
}

.topology-room-card dt,
.cloud-device-card dt {
  color: #64748b;
}

.topology-room-card dd,
.cloud-device-card dd {
  margin: 0;
  color: #0f172a;
  word-break: break-all;
}

.room-card-hint {
  margin: 8px 0 0;
  font-size: 0.75rem;
  color: #64748b;
}

.cloud-device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.cloud-device-card {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.cloud-device-card:hover,
.cloud-device-card:focus {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(15,23,42,0.09);
  border-color: #93c5fd;
  outline: none;
}

.cloud-device-card--external {
  background: #f3f4f6;
  border-color: #cbd5e1;
}

.cloud-device-card--external:hover,
.cloud-device-card--external:focus {
  border-color: #94a3b8;
  box-shadow: 0 6px 16px rgba(15,23,42,0.07);
}

.cloud-device-card--external h3,
.cloud-device-card--external dd {
  color: #1f2937;
}

.status-tag-external {
  font-size: 0.72rem;
  color: #334155;
  border: 1px solid #94a3b8;
  border-radius: 999px;
  padding: 2px 8px;
  background: #e5e7eb;
}

.cloud-device-card header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.cloud-device-card h3 {
  margin: 0;
  font-size: 0.98rem;
}

.admin-modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 40;
}

.admin-modal.hidden {
  display: none;
}

.admin-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}

.admin-modal__content {
  position: relative;
  width: min(760px, calc(100% - 28px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: #fff;
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 14px 40px rgba(15,23,42,0.25);
}

.admin-modal__close {
  position: absolute;
  top: 8px;
  right: 10px;
  border: none;
  background: transparent;
  font-size: 1.4rem;
  cursor: pointer;
  color: #475569;
}

#shelly-device-modal .admin-form-grid {
  margin-top: 14px;
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}
.admin-table th, .admin-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid #e2e8f0;
}
.admin-table th { background: #f8fafc; font-weight: 600; }
.log-table { font-size: 0.85rem; }
.log-ts { white-space: nowrap; color: #6b7280; }
.log-type { white-space: nowrap; font-weight: 600; min-width: 80px; }
.log-table tbody tr:nth-child(odd) {
  background: #f8fafc;
}

.log-table tbody tr:hover {
  background: #eef6ff;
}

.log-table td {
  vertical-align: top;
  line-height: 1.4;
}

.log-pagination {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.log-page-status {
  color: #475569;
  font-size: 0.88rem;
}

.alert-config-card {
  border: 1px solid rgba(37, 99, 235, 0.18);
  background: linear-gradient(180deg, rgba(239, 246, 255, 0.88), rgba(255, 255, 255, 0.95));
}

.alert-config-grid {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  font-size: 0.9rem;
}

.alert-config-grid dt {
  color: #475569;
}

.alert-config-grid dd {
  margin: 0;
  color: #0f172a;
  font-weight: 600;
}

.alert-config-note {
  margin: 12px 0;
  color: #334155;
  font-size: 0.86rem;
}

.alert-room-grid {
  margin-top: 8px;
}

.alert-room-card {
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  border-color: #cbdaf0;
}

.status-online  { color: #16a34a; }
.status-offline { color: #dc2626; }
.action-btn {
  display: inline-block;
  padding: 8px 18px;
  background: #2563eb;
  color: #fff;
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.95rem;
  border: none;
  cursor: pointer;
}
.action-btn:hover { background: #1d4ed8; }

.action-btn:disabled {
  background: #94a3b8;
  cursor: not-allowed;
}

.action-btn--secondary {
  background: #e2e8f0;
  color: #1e293b;
}

.action-btn--secondary:hover {
  background: #cbd5e1;
}

.action-btn--small {
  padding: 6px 12px;
  font-size: 0.84rem;
}

.action-btn--danger {
  background: #dc2626;
}

.action-btn--danger:hover {
  background: #b91c1c;
}

.empty-tab { color: #6b7280; }

@media (max-width: 960px) {
  .admin-form-grid--room-row,
  .admin-form-grid--alert-row {
    grid-template-columns: 1fr;
  }

  .alert-config-grid {
    grid-template-columns: 1fr;
    gap: 2px 0;
  }

  .village-header {
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
  }

  .house-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .topology-area-create-bottom {
    justify-content: stretch;
  }

  .topology-area-create-bottom .action-btn {
    width: 100%;
  }
}

.page-footer {
  margin-top: 24px;
  text-align: center;
}

.build-meta {
  color: #9ca3af;
  font-size: 0.75rem;
}

.areas {
  display: grid;
  gap: 16px;
}

.area-card {
  background: #ffffff;
  border: 1px solid #d9e2ec;
  border-left: 6px solid var(--area-color);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
}

.area-card h2 {
  margin: 0 0 12px;
  font-size: 1.2rem;
}

/* Area header with inline toggle */
.area-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.area-header h2 { margin: 0; }

/* Global switch row at top of heating tab */
.global-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #1e3a5f;
  color: #fff;
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 18px;
}
.global-switch-label {
  font-size: 1.05rem;
  font-weight: 600;
}

.global-switch-row--disabled {
  background: #9ca3af;
  color: #eef2f7;
}

/* Larger toggle for area/global controls */
.toggle--large .slider,
.toggle--area .slider {
  width: 52px;
  height: 28px;
}
.toggle--large .slider::before,
.toggle--area .slider::before {
  width: 22px;
  height: 22px;
  bottom: 3px;
  left: 3px;
}
.toggle--large input:checked + .slider::before,
.toggle--area input:checked + .slider::before {
  transform: translateX(24px);
}

.house-card {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 12px 14px;
}

.house-card + .house-card {
  margin-top: 10px;
}

.house-card h3 {
  margin: 0 0 10px;
  font-size: 1rem;
  color: #374151;
  letter-spacing: 0.01em;
}

.room-card--alert {
  background: #fff5f5;
  border-radius: 8px;
  padding-left: 8px;
  padding-right: 8px;
  border-top-color: #fecaca;
}

.temp--alert {
  color: #dc2626;
  font-weight: 700;
}

.alert-threshold {
  font-size: 0.78rem;
  color: #6b7280;
  font-style: italic;
}

.room-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 10px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  margin-top: 8px;
}

.room-card--overheat {
  border-color: #f97316;
  background: #fff7ed;
}

.room-meta {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.room-name {
  font-weight: 700;
  font-size: 1rem;
}

.room-readings {
  display: flex;
}

/* ── Outdoor Lighting Admin ─────────────────────────── */

.outdoor-timing-card {
  border: 1px solid rgba(34, 197, 94, 0.18);
  background: linear-gradient(180deg, rgba(240, 253, 244, 0.88), rgba(255, 255, 255, 0.95));
}

.outdoor-timing-grid {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  font-size: 0.9rem;
}

.outdoor-timing-grid dt {
  color: #475569;
  font-weight: 600;
}

.outdoor-timing-grid dd {
  margin: 0;
  color: #0f172a;
  font-weight: 600;
  font-family: 'Courier New', monospace;
}

.outdoor-timing-note {
  margin: 12px 0;
  color: #334155;
  font-size: 0.86rem;
}

.position-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  color: #0f172a;
}

.position-info div {
  line-height: 1.4;
}

.outdoor-lighting-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  margin-top: 8px;
}

.outdoor-lighting-card {
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: all 0.2s ease;
}

.outdoor-lighting-card:hover {
  border-color: #9ca3af;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.outdoor-light-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 10px;
}

.outdoor-light-header h3 {
  margin: 0;
  font-size: 1rem;
  color: #1f2937;
}

.outdoor-light-status {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.outdoor-light-status.status-auto {
  background: rgba(34, 197, 94, 0.1);
  color: #15803d;
}

.outdoor-light-status.status-manual {
  background: rgba(239, 68, 68, 0.1);
  color: #b91c1c;
}

.outdoor-light-info {
  margin: 10px 0;
  padding: 8px;
  background: #f9fafb;
  border-radius: 6px;
  font-size: 0.85rem;
}

.outdoor-light-info p {
  margin: 4px 0;
  color: #475569;
}

.outdoor-light-info code {
  background: #e5e7eb;
  padding: 2px 6px;
  border-radius: 3px;
  font-family: 'Courier New', monospace;
  font-size: 0.8rem;
  color: #1f2937;
}

.outdoor-light-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.form-group--checkbox {
  display: flex;
  align-items: center;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #dbe4f0;
  background: linear-gradient(180deg, #ffffff, #f4f8ff);
  cursor: pointer;
  color: #1f2937;
  transition: all 0.2s ease;
}

.toggle-label:hover {
  border-color: #94a3b8;
  box-shadow: 0 4px 10px rgba(59, 130, 246, 0.08);
}

.toggle-label--automation {
  background: linear-gradient(180deg, #ffffff, #f2fbf7);
}

.toggle-label--quiet {
  background: linear-gradient(180deg, #fffdf9, #fff5d5);
}

.toggle-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  gap: 2px;
  flex: 1;
}

.toggle-copy strong {
  font-size: 0.92rem;
}

.toggle-copy small {
  font-size: 0.72rem;
  color: #64748b;
}

.outdoor-toggle {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-switch {
  position: relative;
  width: 52px;
  height: 30px;
  border-radius: 999px;
  background: linear-gradient(180deg, #cbd5e1, #94a3b8);
  box-shadow: inset 0 2px 5px rgba(15, 23, 42, 0.18);
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.toggle-switch::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(15, 23, 42, 0.2);
  transition: transform 0.2s ease;
}

.toggle-icon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.8rem;
  line-height: 1;
  z-index: 1;
}

.toggle-icon--sun,
.toggle-icon--clock {
  left: 8px;
  opacity: 0.75;
}

.toggle-icon--moon,
.toggle-icon--off {
  right: 8px;
  opacity: 0.4;
}

.outdoor-toggle:checked + .toggle-switch {
  background: linear-gradient(180deg, #22c55e, #16a34a);
}

.outdoor-toggle:checked + .toggle-switch::before {
  transform: translateX(22px);
}

.outdoor-toggle:checked + .toggle-switch .toggle-icon--sun,
.outdoor-toggle:checked + .toggle-switch .toggle-icon--clock {
  opacity: 0.4;
}

.outdoor-toggle:checked + .toggle-switch .toggle-icon--moon,
.outdoor-toggle:checked + .toggle-switch .toggle-icon--off {
  opacity: 1;
}

.form-group--quiet-hours {
  background: #fef3c7;
  border: 1px solid rgba(217, 119, 6, 0.2);
  padding: 10px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all 0.3s ease;
}

.form-group--quiet-hours.hidden {
  display: none;
}

.form-group--quiet-hours label {
  font-size: 0.85rem;
  color: #1f2937;
  font-weight: 600;
  margin: 0;
}

.form-group--quiet-hours input[type="time"] {
  padding: 6px 8px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 0.9rem;
  font-family: 'Courier New', monospace;
}

.form-hint {
  font-size: 0.8rem;
  color: #6b7280;
  margin: 4px 0;
  font-style: italic;
}

.form-group--quiet-hours .form-hint {
  color: #92400e;
}
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.room-reading {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.88rem;
  color: #374151;
  white-space: nowrap;
}

.room-reading .icon {
  font-size: 1rem;
  line-height: 1;
}

.room-reading--temp-hot {
  color: #dc2626;
  font-weight: 700;
}

.room-reading--overheat {
  color: #ea580c;
  font-weight: 700;
}

.room-reading--muted {
  color: #9ca3af;
}

.room-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.wifi {
  display: flex;
  align-items: center;
  min-width: 24px;
  justify-content: flex-end;
}

.wifi-bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 14px;
}

.wifi-bars span {
  width: 3px;
  background: #d1d5db;
  border-radius: 2px;
}

.wifi-bars span:nth-child(1) { height: 4px; }
.wifi-bars span:nth-child(2) { height: 7px; }
.wifi-bars span:nth-child(3) { height: 10px; }
.wifi-bars span:nth-child(4) { height: 13px; }

.wifi-bars.level-1 span:nth-child(1),
.wifi-bars.level-2 span:nth-child(-n+2),
.wifi-bars.level-3 span:nth-child(-n+3),
.wifi-bars.level-4 span {
  background: #22c55e;
}

.wifi.offline .wifi-bars span {
  background: #d1d5db !important;
}

.toggle {
  position: relative;
  width: 46px;
  height: 26px;
  display: inline-block;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  background: #cbd5e1;
  border-radius: 999px;
  transition: background 0.2s ease;
}

.slider:before {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s ease;
}

.toggle input:checked + .slider {
  background: #22c55e;
}

.toggle input:checked + .slider:before {
  transform: translateX(20px);
}

.toggle input:disabled + .slider {
  background: #e5e7eb;
  cursor: not-allowed;
}

@media (max-width: 640px) {
  .room-card {
    grid-template-columns: 1fr;
  }

  .room-controls {
    width: 100%;
    justify-content: space-between;
  }

  .room-readings {
    gap: 8px;
  }
}

/* ── Outdoor Lights (Main Page) ────────────────────── */

.outdoor-lights-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  padding: 16px 0;
}

.outdoor-light-card-main {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: all 0.2s ease;
}

.outdoor-light-card-main:hover {
  border-color: #9ca3af;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.outdoor-light-main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 10px;
}

.outdoor-light-main-header h3 {
  margin: 0;
  font-size: 1.1rem;
  color: #1f2937;
}

.outdoor-light-status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.outdoor-light-status-badge.status-on {
  background: rgba(34, 197, 94, 0.15);
  color: #15803d;
}

.outdoor-light-status-badge.status-off {
  background: rgba(239, 68, 68, 0.15);
  color: #b91c1c;
}

.outdoor-light-main-info {
  margin: 0;
  padding: 10px;
  background: #f9fafb;
  border-radius: 6px;
  font-size: 0.9rem;
}

.outdoor-light-main-info p {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
  color: #475569;
  flex-wrap: wrap;
}

.outdoor-light-main-info code {
  background: #e5e7eb;
  padding: 2px 6px;
  border-radius: 3px;
  font-family: 'Courier New', monospace;
  font-size: 0.8rem;
  color: #1f2937;
}

.solar-timing {
  font-family: 'Courier New', monospace;
  font-weight: 700;
  color: #1f2937;
}

.solar-icon {
  font-size: 1rem;
}

.auto-enabled {
  color: #15803d;
  font-weight: 600;
}

.auto-disabled {
  color: #b91c1c;
  font-weight: 600;
}

.outdoor-light-main-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-top: 4px;
}

.outdoor-light-main-controls .toggle {
  transform: scale(1.2);
}

.toggle--room input:checked + .slider::before {
  transform: translateX(24px);
}

.inline-form {
  flex: 1;
}

.inline-form button {
  width: 100%;
}
