:root {
  --ink: #0b1c2d;
  --muted: #46607a;
  --bg: #f4f8fb;
  --card: #ffffff;
  --line: #d6e2ee;
  --accent: #e25f2f;
  --accent-2: #1f8fa6;
  --ok: #2f9e44;
  --warn: #c92a2a;
  --soft-ok: #edf9ef;
  --soft-warn: #fff3ef;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  background: radial-gradient(circle at 8% 15%, #d8edf8 0%, transparent 42%),
    radial-gradient(circle at 95% 88%, #ffe4d8 0%, transparent 36%),
    var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

.bg-shape {
  position: fixed;
  pointer-events: none;
  border-radius: 50%;
  filter: blur(10px);
  opacity: 0.45;
}

.bg-a {
  width: 280px;
  height: 280px;
  background: #c4ecf1;
  top: -80px;
  right: -40px;
}

.bg-b {
  width: 300px;
  height: 300px;
  background: #ffd7c8;
  bottom: -100px;
  left: -60px;
}

.shell {
  width: min(1120px, 94vw);
  margin: 1.4rem auto 2rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1.2rem;
}

.subtitle {
  margin: 0.35rem 0 0;
  color: var(--muted);
  max-width: 64ch;
}

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.6rem;
  margin-bottom: 0.7rem;
}

.summary-card {
  padding: 0.75rem 0.9rem;
}

.summary-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.summary-value {
  margin: 0.2rem 0 0;
  font-family: "Syne", sans-serif;
  font-size: 1.4rem;
}

.summary-small {
  font-size: 1rem;
}

.flash {
  margin: 0 0 0.9rem;
  padding: 0.62rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font-weight: 600;
}

.flash.ok {
  border-color: #bce0c5;
  background: var(--soft-ok);
  color: #236a31;
}

.flash.err {
  border-color: #f0c9bc;
  background: var(--soft-warn);
  color: #8c2d14;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.8rem;
}

h1,
h2,
h3 {
  font-family: "Syne", sans-serif;
  margin: 0;
}

h1 {
  font-size: clamp(1.4rem, 2.4vw, 2.2rem);
}

.status-pill {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  font-weight: 700;
  color: var(--warn);
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 10px 34px rgba(30, 58, 90, 0.08);
}

.login-card {
  max-width: 420px;
  padding: 1rem;
  margin: 2rem auto;
}

.login-card form {
  display: grid;
  gap: 0.8rem;
}

label {
  display: grid;
  gap: 0.35rem;
  font-weight: 600;
  color: var(--muted);
}

input,
button {
  font: inherit;
}

input {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.62rem 0.7rem;
}

button {
  border: 0;
  border-radius: 10px;
  background: var(--accent-2);
  color: white;
  padding: 0.55rem 0.9rem;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  transform: translateY(-1px);
}

button.warn {
  background: var(--accent);
}

button.ghost {
  background: #eff6fc;
  color: var(--ink);
  border: 1px solid var(--line);
}

.error {
  color: var(--warn);
  min-height: 1.2rem;
}

.panel {
  padding: 0.9rem;
}

.helper {
  margin: 0 0 0.7rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.schedule-head {
  margin-top: 1rem;
}

.schedule-card {
  padding: 0.9rem;
  margin-bottom: 0.8rem;
}

.planner-wrap {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem;
  margin-bottom: 0.9rem;
  background: #fbfdff;
}

.planner-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 0.8rem;
}

.planner-grid {
  margin-top: 0.55rem;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 0.4rem;
}

.planner-table {
  display: grid;
  grid-template-columns: 72px repeat(24, minmax(36px, 1fr));
  gap: 4px;
  min-width: 980px;
}

.planner-hour,
.planner-day,
.planner-cell {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 28px;
}

.planner-hour {
  font-size: 0.72rem;
  color: var(--muted);
  background: #f3f8fc;
  display: flex;
  align-items: center;
  justify-content: center;
}

.planner-day {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  background: #f3f8fc;
  display: flex;
  align-items: center;
  justify-content: center;
}

.planner-cell {
  font-size: 0.7rem;
  font-weight: 700;
  background: #fff;
  cursor: pointer;
}

.planner-cell:hover {
  border-color: #8ec2df;
  background: #f2f9ff;
}

.planner-cell.on {
  background: #eaf9ee;
  border-color: #bfe3c8;
  color: #1c6b2a;
}

.planner-cell.off {
  background: #fff2ed;
  border-color: #f0c9bc;
  color: #8c2d14;
}

.planner-cell.toggle {
  background: #eef5ff;
  border-color: #bfcee7;
  color: #33527f;
}

.planner-cell.paused {
  opacity: 0.45;
}

.planner-legend {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin-top: 0.55rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  margin-right: 0.3rem;
  border: 1px solid var(--line);
}

.dot.on {
  background: #eaf9ee;
}

.dot.off {
  background: #fff2ed;
}

.dot.toggle {
  background: #eef5ff;
}

.dot.paused {
  background: #f1f1f1;
}

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

.schedule-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-start;
}

.weekday-presets {
  display: flex;
  gap: 0.3rem;
  margin-bottom: 0.4rem;
}

.small {
  padding: 0.22rem 0.5rem;
  font-size: 0.78rem;
}

.inline-check {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.4rem;
}

.inline-check input {
  width: auto;
}

.schedule-form fieldset {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.4rem 0.6rem 0.6rem;
  margin: 0;
}

.schedule-form legend {
  font-weight: 700;
  color: var(--muted);
  font-size: 0.88rem;
}

.weekday-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(52px, 1fr));
  gap: 0.2rem;
}

.weekday {
  font-size: 0.85rem;
}

.schedule-list {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.8rem;
}

.schedule-row {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.5rem 0.6rem;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
}

.schedule-row .row-main {
  display: grid;
  gap: 0.2rem;
}

.schedule-row .row-name {
  font-weight: 700;
}

.schedule-row .row-meta {
  color: var(--muted);
  font-size: 0.86rem;
}

.schedule-row .row-actions {
  display: flex;
  gap: 0.35rem;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.8rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0.8rem;
}

.node {
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  min-height: 240px;
  overflow: hidden;
}

.node-head {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
}

.power-badge {
  border-radius: 999px;
  padding: 0.25rem 0.55rem;
  font-size: 0.8rem;
  border: 1px solid var(--line);
  color: var(--muted);
}

.power-badge.off {
  background: #f3f7fb;
}

.power-badge.on {
  border-color: #bce0c5;
  color: var(--ok);
  background: #edf9ef;
}

.temp {
  font-size: 1.65rem;
  margin: 0.55rem 0 0.3rem;
}

.virtual {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.virtual-state.on {
  color: var(--ok);
}

.virtual-state.off {
  color: #9a5a14;
}

.meta {
  margin: 0 0 0.7rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: auto;
}

.actions button {
  min-height: 2.35rem;
  flex: 1 1 120px;
  max-width: 100%;
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}

.hidden {
  display: none;
}

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

  .shell {
    width: 95vw;
  }

  .schedule-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .weekday-grid {
    grid-template-columns: repeat(3, minmax(48px, 1fr));
  }

  .planner-head {
    flex-direction: column;
    align-items: stretch;
  }
}
