/* Hall Heater Control — modern responsive stylesheet
   Works on mobile and desktop. Light/dark aware. */

:root {
  --bg: #0f1115;
  --bg-elev: #171a21;
  --bg-elev-2: #1e222b;
  --border: #2a2f3a;
  --text: #e7e9ee;
  --text-muted: #9aa1ad;
  --primary: #ff7a18;
  --primary-600: #e96a0c;
  --primary-tint: rgba(255, 122, 24, 0.14);
  --success: #22c55e;
  --success-tint: rgba(34, 197, 94, 0.15);
  --danger: #ef4444;
  --danger-tint: rgba(239, 68, 68, 0.15);
  --info: #3b82f6;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --ring: 0 0 0 3px rgba(255, 122, 24, 0.35);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6fb;
    --bg-elev: #ffffff;
    --bg-elev-2: #f0f2f7;
    --border: #e2e6ee;
    --text: #1b1f27;
    --text-muted: #5b6472;
    --shadow: 0 10px 30px rgba(20, 30, 60, 0.08);
    --shadow-sm: 0 1px 4px rgba(20, 30, 60, 0.08);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: radial-gradient(
      1200px 600px at 100% -10%,
      var(--primary-tint),
      transparent 60%
    ),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--primary);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

h1,
h2,
h3,
h4 {
  margin: 0 0 0.4em;
  line-height: 1.2;
  font-weight: 700;
}

/* ---------- Layout ---------- */
.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: color-mix(in srgb, var(--bg-elev) 88%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: 0.2px;
  color: var(--text);
}
.brand .logo {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), #ffb057);
  box-shadow: var(--shadow-sm);
  font-size: 20px;
}
.brand small {
  display: block;
  font-weight: 500;
  color: var(--text-muted);
  font-size: 11px;
}

.topbar .spacer {
  flex: 1;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  color: var(--text-muted);
}
.user-chip b {
  color: var(--text);
}

/* mobile menu toggle */
.menu-toggle {
  display: none;
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--text);
  border-radius: var(--radius-sm);
  width: 42px;
  height: 42px;
  font-size: 18px;
  cursor: pointer;
}

.nav {
  display: flex;
  align-items: center;
  gap: 6px;
}
.nav a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 14px;
}
.nav a:hover {
  background: var(--bg-elev-2);
  color: var(--text);
  text-decoration: none;
}
.nav a.active {
  background: var(--primary-tint);
  color: var(--primary);
}

/* ---------- Cards & grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
  margin-top: 16px;
}
.col-4 {
  grid-column: span 4;
}
.col-6 {
  grid-column: span 6;
}
.col-8 {
  grid-column: span 8;
}
.col-12 {
  grid-column: span 12;
}

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.card h3 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 14px;
}

/* card header row with an action on the right */
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.card-head h3 {
  margin-bottom: 0;
}

/* small button / input variants */
.btn-sm {
  padding: 8px 12px;
  font-size: 13px;
}
.input-sm {
  width: auto;
  padding: 8px 10px;
  font-size: 14px;
}

.field-inline {
  display: flex;
  align-items: center;
  gap: 8px;
}
.field-inline label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

/* day-browsing toolbar */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.day-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.day-label {
  font-weight: 700;
  font-size: 15px;
  min-width: 160px;
  text-align: center;
}

/* ---------- Status ---------- */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--text-muted);
}
.status-pill .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: currentColor;
}
.status-pill.on {
  color: var(--success);
  background: var(--success-tint);
  border-color: transparent;
}
.status-pill.off {
  color: var(--danger);
  background: var(--danger-tint);
  border-color: transparent;
}

.temp-readout {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 6px;
}
.temp-readout .value {
  font-size: 48px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
}
.temp-readout .unit {
  font-size: 20px;
  color: var(--text-muted);
  font-weight: 600;
}
.temp-label {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 10px;
}

/* ---------- Stepper ---------- */
.setpoint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.setpoint:last-of-type {
  border-bottom: 0;
}
.setpoint .label {
  font-weight: 600;
}
.setpoint .label small {
  display: block;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 12px;
}
.stepper {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
}
.stepper button {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  font-size: 22px;
  font-weight: 700;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.15s;
}
.stepper button:hover {
  background: var(--primary-tint);
  color: var(--primary);
}
.stepper button:active {
  transform: scale(0.94);
}
.stepper .num {
  min-width: 56px;
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.stepper .num small {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
}

/* ---------- Buttons ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--text);
  font-family: inherit;
  font-weight: 700;
  font-size: 15px;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform 0.06s ease, filter 0.15s ease, background 0.15s ease;
}
.btn:hover {
  filter: brightness(1.05);
}
.btn:active {
  transform: translateY(1px);
}
.btn:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-block {
  width: 100%;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-600));
  border-color: transparent;
  color: #fff;
}
.btn-success {
  background: var(--success);
  border-color: transparent;
  color: #04210f;
}
.btn-danger {
  background: var(--danger);
  border-color: transparent;
  color: #fff;
}

/* big power button */
.power-btn {
  width: 100%;
  min-height: 160px;
  border: 0;
  border-radius: var(--radius);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 0.08s ease, box-shadow 0.2s ease, background 0.25s ease;
  box-shadow: var(--shadow-sm);
}
.power-btn .icon {
  font-size: 40px;
  line-height: 1;
}
.power-btn:active {
  transform: scale(0.985);
}
.power-btn.state-off {
  background: linear-gradient(135deg, #22c55e, #16a34a);
}
.power-btn.state-on {
  background: linear-gradient(135deg, #ef4444, #dc2626);
}

/* ---------- Alerts ---------- */
.alert {
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 14px;
  margin: 0 0 14px;
  border: 1px solid transparent;
}
.alert-error {
  background: var(--danger-tint);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.35);
}
.alert-info {
  background: rgba(59, 130, 246, 0.12);
  color: #93c5fd;
  border-color: rgba(59, 130, 246, 0.35);
}
.alert-success {
  background: var(--success-tint);
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.35);
}
.alert-warning {
  background: rgba(234, 179, 8, 0.12);
  color: #fde68a;
  border-color: rgba(234, 179, 8, 0.35);
  font-size: 13px;
}

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.data th,
table.data td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data th {
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
table.data tr:last-child td {
  border-bottom: 0;
}
table.data tbody tr:hover,
table.data tr:hover td {
  background: var(--bg-elev-2);
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-yes {
  background: var(--success-tint);
  color: var(--success);
}
.badge-no {
  background: var(--danger-tint);
  color: var(--danger);
}

.link-danger {
  color: var(--danger);
  font-weight: 600;
}

/* ---------- Activity list ---------- */
.activity {
  list-style: none;
  margin: 0;
  padding: 0;
}
.activity-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.activity-item:last-child {
  border-bottom: 0;
}
.activity .avatar {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 15px;
  color: var(--primary);
  background: var(--primary-tint);
}
.activity-body {
  min-width: 0;
  flex: 1;
}
.activity-text {
  margin: 0;
  font-size: 14px;
  color: var(--text);
}
.activity-text b {
  margin-right: 4px;
}
.activity-time {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ---------- Forms ---------- */
.form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.input {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
}
.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--ring);
}

/* ---------- Auth screen ---------- */
.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}
.auth-card .brand {
  justify-content: center;
  margin-bottom: 6px;
}
.auth-card h1 {
  text-align: center;
  font-size: 22px;
}
.auth-sub {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 20px;
}
.auth-foot {
  text-align: center;
  margin-top: 16px;
  font-size: 14px;
}

/* ---------- Footer ---------- */
.footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  padding: 28px 16px 40px;
}

.muted {
  color: var(--text-muted);
}
.center {
  text-align: center;
}
.mt-0 {
  margin-top: 0;
}

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .col-4,
  .col-6,
  .col-8 {
    grid-column: span 12;
  }
  .menu-toggle {
    display: grid;
    place-items: center;
  }
  .nav {
    position: absolute;
    top: 64px;
    left: 8px;
    right: 8px;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: 8px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: none;
  }
  .nav.open {
    display: flex;
  }
  .nav a {
    padding: 12px 14px;
    font-size: 15px;
  }
  .user-chip .lbl {
    display: none;
  }
}

@media (max-width: 420px) {
  .temp-readout .value {
    font-size: 40px;
  }
  .brand small {
    display: none;
  }
}
