/* Grubtech design tokens (see ~/.claude/brand/grubtech/DESIGN.md) applied to a home dashboard. */
:root {
  --navy-900: #10285b;
  --navy: #1e3a72;
  --navy-600: #4b5a89;
  --blue: #2b7ebc;
  --blue-400: #6a9fd8;
  --blue-200: #bfd9f1;
  --blue-100: #ddf2fd;
  --bg-soft: #f3f6f9;
  --line: #dee2e6;
  --line-strong: #c9ced3;
  --text: #212529;
  --muted: #6c757d;
  --gold: #c49a55;
  --gold-100: #fedbb3;
  --red: #c63c32;
  --red-100: #fde0e0;
  --card: #ffffff;
  --radius: 16px;
  --font-head: "Poppins", system-ui, sans-serif;
  --font-body: "Raleway", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--text);
  background: linear-gradient(135deg, #ffffff 0%, #e0ebfb 100%) fixed;
  background-color: #f3f6f9;
}
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled, select:disabled { cursor: not-allowed; }
:focus-visible { outline: 3px solid var(--blue-400); outline-offset: 2px; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 16px 48px;
}

.eyebrow {
  margin: 0 0 4px;
  font-family: var(--font-head);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--blue);
}
h1 {
  margin: 0;
  font-family: var(--font-head);
  font-weight: 800;
  font-size: clamp(26px, 6vw, 36px);
  line-height: 1.1;
  color: var(--navy);
  letter-spacing: -.01em;
}
.muted { color: var(--muted); }

/* top bar */
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.topbar-actions { display: flex; gap: 8px; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 44px; height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--navy);
}
.icon-btn:hover { border-color: var(--blue-400); }
.icon-btn.spinning svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.banner {
  margin: 0 0 16px; padding: 12px 16px;
  border-radius: 12px;
  background: var(--blue-100); color: var(--navy);
  font-weight: 500;
}
.banner-error { background: var(--red-100); color: #a51e22; }

/* device grid */
.grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 780px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; } }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 1px 2px rgba(16, 40, 91, .04);
  display: flex; flex-direction: column; gap: 18px;
  min-width: 0;
}
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.card-head h2 {
  margin: 0;
  font-family: var(--font-head); font-weight: 700; font-size: 20px; color: var(--navy);
  overflow-wrap: anywhere;
}
.meta { margin: 4px 0 0; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--blue); display: inline-block; }
.dot.offline { background: var(--red); }
.state-pill {
  font-family: var(--font-head); font-weight: 600; font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  padding: 2px 8px; border-radius: 999px; background: var(--bg-soft); color: var(--muted);
}
.state-pill.on { background: var(--blue-100); color: var(--navy); }

.power {
  width: 56px; height: 56px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid var(--line-strong);
  background: var(--bg-soft); color: var(--muted);
  transition: background .2s, color .2s, border-color .2s;
}
.power svg { width: 26px; height: 26px; stroke-width: 2.4; }
.power.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.power:hover:not(:disabled) { border-color: var(--blue-400); }

/* temperature */
.temp-row { display: grid; grid-template-columns: 56px 1fr 56px; align-items: center; gap: 8px; }
.step {
  width: 56px; height: 56px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--card); color: var(--navy);
  font-family: var(--font-head); font-size: 26px; font-weight: 600; line-height: 1;
}
.step:hover:not(:disabled) { border-color: var(--blue-400); background: var(--blue-100); }
.temp { text-align: center; }
.target {
  font-family: var(--font-head); font-weight: 800; color: var(--navy);
  font-size: clamp(56px, 16vw, 72px); line-height: 1; letter-spacing: -.03em;
}
.target .deg { font-size: .4em; font-weight: 600; vertical-align: top; margin-left: 2px; letter-spacing: 0; }
.room { margin-top: 6px; font-size: 14px; color: var(--muted); }
.room strong { color: var(--text); font-weight: 600; }

/* sections */
.section { display: flex; flex-direction: column; gap: 8px; }
.label {
  font-family: var(--font-head); font-weight: 500; font-size: 11px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted);
}
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button, .chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px; padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  font-weight: 600; font-size: 14px; color: var(--navy-600);
}
.seg button svg, .chip svg { width: 18px; height: 18px; }
.seg button:hover:not(:disabled), .chip:hover:not(:disabled) { border-color: var(--blue-400); }
.seg button[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }
.seg .chip[aria-pressed="true"] { background: var(--blue-100); border-color: var(--blue-400); color: var(--navy); }
.seg .chip.gold[aria-pressed="true"] { background: #fdf3e4; border-color: var(--gold); color: #8a5a17; }

.timers { display: grid; gap: 8px; grid-template-columns: 1fr; }
@media (min-width: 420px) { .timers { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); } }
.timer {
  display: flex; flex-direction: column; gap: 6px;
  padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg-soft);
}
.timer-title { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; color: var(--navy); }
.timer-title svg { width: 18px; height: 18px; }
.timer-state { font-size: 12px; color: var(--muted); }
.timer-state.active { color: var(--blue); font-weight: 600; }
.timer select {
  width: 100%; min-height: 36px; padding: 6px 8px;
  border-radius: 8px; border: 1px solid var(--line-strong); background: var(--card);
}

.card-foot {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px;
  padding-top: 14px; border-top: 1px solid var(--line);
  font-size: 12px; color: var(--muted);
}
.card-error { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--red-100); color: #a51e22; font-size: 14px; }

.card.is-off .temp-row, .card.is-off .section:not(.keep-active) { opacity: .45; }
.card.is-offline { border-color: var(--red-100); }

/* login */
.login { min-height: 80vh; display: grid; place-items: center; }
.login-card {
  width: 100%; max-width: 400px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px 24px; display: flex; flex-direction: column; gap: 14px;
}
.login-card p { margin: 0; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; color: var(--navy); }
.field input {
  min-height: 48px; padding: 10px 14px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: #fff; font-weight: 500; font-size: 16px;
}
.field input:focus { border-color: var(--blue-400); outline: none; box-shadow: 0 0 0 3px var(--blue-100); }
.form-error { color: #a51e22; background: var(--red-100); padding: 8px 12px; border-radius: 8px; font-size: 14px; }
.primary {
  min-height: 48px; border: 0; border-radius: 10px;
  background: var(--navy); color: #fff;
  font-family: var(--font-head); font-weight: 600; font-size: 16px;
}
.primary:hover:not(:disabled) { background: var(--navy-900); }
.primary:disabled { opacity: .6; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 12px 16px; border-radius: 12px;
  background: var(--navy); color: #fff; font-weight: 500; font-size: 14px;
  box-shadow: 0 8px 24px rgba(16, 40, 91, .2);
  z-index: 10;
}
.toast.error { background: var(--red); }

.empty {
  grid-column: 1 / -1; text-align: center; padding: 48px 16px;
  border: 1px dashed var(--line-strong); border-radius: var(--radius); background: rgba(255, 255, 255, .6);
}
.skeleton { min-height: 360px; background: linear-gradient(90deg, #fff 0%, var(--bg-soft) 50%, #fff 100%); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
