:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #121212;
  color: #f3f3f0;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  background: #121212;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 42px;
  border: 1px solid #3b3b36;
  border-radius: 8px;
  padding: 0 14px;
  color: #f3f3f0;
  background: #262622;
}

button:active {
  transform: translateY(1px);
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid #3b3b36;
  border-radius: 8px;
  padding: 0 12px;
  color: #f3f3f0;
  background: #181815;
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: #aaa79d;
  font-size: 0.86rem;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

h1 {
  font-size: 1.45rem;
}

h2 {
  font-size: 1rem;
}

h3 {
  font-size: 1.05rem;
}

h4 {
  font-size: 0.95rem;
}

main {
  width: min(980px, calc(100% - 24px));
  margin: 0 auto;
  padding: 16px 0 32px;
  display: grid;
  gap: 12px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px max(12px, calc((100vw - 980px) / 2));
  border-bottom: 1px solid #2f2f2b;
  background: #171717;
}

.top-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.topbar p,
.section-heading span,
.device p {
  color: #aaa79d;
  font-size: 0.86rem;
}

.tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid #30302c;
}

.tab-button {
  min-height: 40px;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  color: #aaa79d;
  background: transparent;
}

.tab-button.active {
  color: #f3f3f0;
  border-color: #4b4b43;
  border-bottom-color: #1b1b18;
  background: #1b1b18;
}

.panel,
.device {
  border: 1px solid #30302c;
  border-radius: 8px;
  background: #1b1b18;
}

.panel {
  padding: 14px;
}

.section-heading,
.device-head,
.device-state,
.button-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.auth-grid,
.schedule-form {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(160px, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-top: 12px;
}

.device-list {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.device {
  padding: 14px;
  display: grid;
  gap: 14px;
}

.empty-state {
  min-height: 160px;
  display: grid;
  place-items: center;
  border: 1px dashed #3b3b36;
  border-radius: 8px;
  color: #aaa79d;
  text-align: center;
  padding: 24px;
}

.pill {
  min-width: 82px;
  border-radius: 999px;
  padding: 5px 10px;
  text-align: center;
  color: #bbb8ad;
  background: #2a2a26;
}

.pill.online {
  color: #baf0cc;
  background: #183c24;
}

.pill.offline {
  color: #ffb8ad;
  background: #4c211c;
}

.toggle-line {
  display: flex;
  grid-auto-flow: column;
  align-items: center;
  justify-content: start;
  gap: 8px;
  color: #f3f3f0;
  font-size: 0.95rem;
}

.toggle-line input {
  width: 18px;
  min-height: 18px;
}

.button-row {
  justify-content: start;
  flex-wrap: wrap;
}

.button-row button[data-role="on"] {
  background: #14532d;
  border-color: #1c7c42;
}

.button-row button[data-role="off"] {
  background: #651c1c;
  border-color: #9d2a2a;
}

.schedule-block {
  border-top: 1px solid #30302c;
  padding-top: 14px;
}

.device-details {
  border-top: 1px solid #30302c;
  padding-top: 10px;
}

.device-details summary {
  cursor: pointer;
  color: #d6d2c5;
}

.details-grid {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.schedule-form {
  grid-template-columns: 80px 140px 120px 140px 110px auto;
}

.schedule-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.schedule-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  border: 1px solid #30302c;
  border-radius: 8px;
  padding: 8px 10px;
  background: #181815;
}

.schedule-row.disabled {
  border-color: #282824;
  background: #121210;
  opacity: 0.72;
}

.schedule-row small {
  color: #aaa79d;
}

@media (max-width: 760px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    justify-content: stretch;
  }

  .top-actions button {
    flex: 1;
  }

  .auth-grid,
  .schedule-form {
    grid-template-columns: 1fr;
  }

  .device-head,
  .device-state {
    align-items: start;
    flex-direction: column;
  }

  .button-row button {
    flex: 1 1 45%;
  }

  .schedule-row {
    grid-template-columns: 1fr;
  }
}
