:root {
  color-scheme: light;
  font-family: Arial, Helvetica, sans-serif;
  background: #f5f7f8;
  color: #172026;
}

* {
  box-sizing: border-box;
}

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

.topbar {
  align-items: center;
  background: #ffffff;
  border-bottom: 1px solid #dde4e8;
  display: flex;
  justify-content: space-between;
  padding: 18px clamp(16px, 4vw, 42px);
}

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

.topbar p {
  color: #61717c;
  margin-top: 4px;
}

.layout {
  display: grid;
  gap: 28px;
  grid-template-columns: minmax(0, 1.3fr) minmax(280px, 0.7fr);
  padding: 28px clamp(16px, 4vw, 42px);
}

section h2 {
  font-size: 1rem;
  margin-bottom: 12px;
  text-transform: uppercase;
}

.pin-grid,
.health-grid {
  display: grid;
  gap: 12px;
}

.pin-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.card {
  background: #ffffff;
  border: 1px solid #dde4e8;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(20, 34, 43, 0.04);
}

.pin-card {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.pin-card h3 {
  font-size: 1rem;
}

.pin-card p {
  color: #61717c;
  font-size: 0.9rem;
  margin-top: 4px;
}

.state {
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  justify-self: start;
  padding: 5px 10px;
  text-transform: uppercase;
}

.state.high {
  background: #dff5e7;
  color: #106132;
}

.state.low {
  background: #edf1f3;
  color: #46545d;
}

.state.unknown {
  background: #fff1d2;
  color: #7a4d00;
}

.controls {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  min-height: 38px;
}

select,
input,
button {
  border: 1px solid #c6d0d6;
  border-radius: 6px;
  font: inherit;
}

select,
input {
  background: #ffffff;
  padding: 8px 10px;
}

button {
  background: #126f8c;
  color: #ffffff;
  cursor: pointer;
  font-weight: 700;
  padding: 9px 14px;
}

button.secondary {
  background: #ffffff;
  color: #172026;
}

button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.pin-actions {
  display: flex;
  gap: 8px;
}

.pin-actions button {
  min-width: 64px;
}

.timer-controls,
.clock-controls {
  border-top: 1px solid #edf1f3;
  display: grid;
  gap: 10px;
  padding-top: 12px;
}

.timer-controls label,
.repeat-controls label,
.clock-controls label {
  color: #61717c;
  display: grid;
  font-size: 0.9rem;
  gap: 6px;
}

.timer-status,
.automation-status,
.clock-status {
  background: #e5f3f7;
  border-radius: 6px;
  color: #126f8c !important;
  padding: 8px;
}

.repeat-controls {
  border-top: 1px solid #edf1f3;
  display: grid;
  gap: 10px;
  padding-top: 12px;
}

.repeat-fields {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.button-link {
  border: 1px solid #c6d0d6;
  border-radius: 6px;
  color: #ffffff;
  display: inline-flex;
  font-weight: 700;
  padding: 9px 14px;
  text-decoration: none;
}

.button-link.secondary {
  background: #ffffff;
  color: #172026;
}

.top-actions {
  align-items: center;
  display: flex;
  gap: 10px;
}

.switch input {
  height: 1px;
  opacity: 0;
  position: absolute;
  width: 1px;
}

.switch span {
  background: #aab7be;
  border-radius: 999px;
  display: block;
  height: 28px;
  position: relative;
  width: 52px;
}

.switch span::after {
  background: #ffffff;
  border-radius: 50%;
  content: "";
  height: 22px;
  left: 3px;
  position: absolute;
  top: 3px;
  transition: transform 120ms ease;
  width: 22px;
}

.switch input:checked + span {
  background: #18a058;
}

.switch input:checked + span::after {
  transform: translateX(24px);
}

.switch.disabled {
  opacity: 0.45;
}

.metric {
  display: flex;
  justify-content: space-between;
  padding: 14px;
}

.metric span {
  color: #61717c;
}

.metric strong {
  color: #172026;
}

.error {
  background: #ffe8e4;
  border-radius: 6px;
  color: #9a2c1e !important;
  padding: 8px;
}

.success {
  background: #dff5e7;
  border-radius: 6px;
  color: #106132;
  padding: 10px;
}

.error-list {
  background: #ffe8e4;
  border-radius: 8px;
  color: #9a2c1e;
  display: grid;
  gap: 6px;
  padding: 12px;
}

.settings-layout {
  display: grid;
  gap: 14px;
  padding: 28px clamp(16px, 4vw, 42px);
}

.config-form,
.config-list {
  display: grid;
  gap: 12px;
}

.config-row {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: 110px minmax(160px, 1fr) 130px 130px 100px;
  padding: 14px;
}

.config-row label {
  color: #61717c;
  display: grid;
  font-size: 0.9rem;
  gap: 6px;
}

.remove-check {
  align-items: center;
  display: flex !important;
  gap: 8px !important;
  min-height: 38px;
}

.settings-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.login-page {
  align-items: center;
  display: flex;
  justify-content: center;
  padding: 20px;
}

.login-panel {
  background: #ffffff;
  border: 1px solid #dde4e8;
  border-radius: 8px;
  padding: 24px;
  width: min(100%, 380px);
}

.login-panel form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.login-panel label {
  display: grid;
  gap: 6px;
}

.login-panel .inline {
  align-items: center;
  display: flex;
  gap: 8px;
}

@media (max-width: 820px) {
  .topbar,
  .layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    gap: 14px;
    flex-direction: column;
  }

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

  .repeat-fields {
    grid-template-columns: 1fr;
  }

  .settings-actions,
  .top-actions {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
  }
}
