:root {
  --bg: #eef1f6;
  --sheet: #ffffff;
  --ink: #1a2332;
  --muted: #7a8494;
  --line: #e4e8ef;
  --navy: #1e2a44;
  --navy-soft: #2a3a58;
  --now: #2f6bff;
  --lamp: #1faa6e;
  --ok: #1faa6e;
  --bad: #e5484d;
  --warn: #d99200;
  --mixed: #c5ccd8;
  --edge: #d3dbe6;
  --shadow: 0 10px 24px rgba(26, 35, 50, 0.10), 0 1px 2px rgba(26, 35, 50, 0.06);
  --lift: 0 5px 14px rgba(26, 35, 50, 0.08);
  --radius: 18px;
  --font: "Manrope", system-ui, sans-serif;
  --font-brand: "Unbounded", system-ui, sans-serif;
  --safe: env(safe-area-inset-bottom, 0px);
  --track: #e6ebf2;
  --offbar: #c5ceda;
  --raised: #f6f8fb;
  --sunken: #e7ecf3;
  --hero-on: #146b45;
  --hero-on-bg: linear-gradient(180deg, #e7f9ef 0%, #f5fbf8 100%);
  --hero-off: #c2353b;
  --hero-off-bg: linear-gradient(180deg, #fdecee 0%, #fff7f7 100%);
}

html[data-theme="dark"] {
  --bg: #0e131b;
  --sheet: #171d27;
  --ink: #eef3f8;
  --muted: #8d98aa;
  --line: #2b3444;
  --ok: #3ddc84;
  --lamp: #3ddc84;
  --bad: #ff6b70;
  --edge: #343e50;
  --shadow: 0 12px 28px rgba(0, 0, 0, 0.42);
  --lift: 0 6px 16px rgba(0, 0, 0, 0.38);
  --track: #2a3342;
  --offbar: #3d485c;
  --raised: #222b39;
  --sunken: #121820;
  --hero-on: #6dffb0;
  --hero-on-bg: linear-gradient(180deg, #143528 0%, #10261d 100%);
  --hero-off: #ff9aa0;
  --hero-off-bg: linear-gradient(180deg, #3a1c22 0%, #241418 100%);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.shell {
  width: min(430px, 100%);
  margin: 0 auto;
  padding: 0.85rem 0.85rem calc(1.6rem + var(--safe));
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.25rem 0.2rem 0.85rem;
}

.top-left {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}

.top-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.menu-btn {
  appearance: none;
  -webkit-appearance: none;
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 12px;
  border: 1px solid var(--edge);
  background: var(--sheet);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.28rem;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: var(--shadow);
}

.menu-btn span {
  display: block;
  width: 1rem;
  height: 2px;
  border-radius: 999px;
  background: var(--ink);
}

.menu-btn:active { transform: scale(0.96); }
.menu-btn:focus-visible {
  outline: 2px solid var(--now);
  outline-offset: 2px;
}

.logout {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--muted);
  text-decoration: none;
  padding: 0.4rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--edge);
  background: var(--sheet);
  box-shadow: var(--lift);
}

.brand {
  margin: 0;
  font-family: var(--font-brand);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  white-space: nowrap;
}

.brand span { color: var(--ok); transition: color 0.2s ease; }
body.state-offline .brand span { color: var(--bad); }

.live {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.32rem 0.55rem;
  border-radius: 999px;
  background: var(--sheet);
  border: 1px solid var(--edge);
  box-shadow: var(--lift);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.live i {
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 50%;
  background: currentColor;
}

.live.on { color: var(--ok); border-color: rgba(31, 170, 110, 0.25); }
.live.off { color: var(--bad); border-color: rgba(229, 72, 77, 0.25); }
.live.on i { animation: pulse 2s ease-out infinite; }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(31, 170, 110, 0.45); }
  70% { box-shadow: 0 0 0 8px rgba(31, 170, 110, 0); }
  100% { box-shadow: 0 0 0 0 rgba(31, 170, 110, 0); }
}

.panel {
  background: var(--sheet);
  border-radius: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--edge);
  padding: 0.95rem 0.85rem 1rem;
}

.status-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
  padding: 0 0.15rem;
}

.status-main {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.status-main .k {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.status-main .v {
  font-family: var(--font-brand);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.status-main .v.on { color: var(--ok); }
.status-main .v.off { color: var(--bad); }

.status-tools {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
}

.tune {
  width: 1.9rem;
  height: 1.9rem;
  margin-top: 0;
  border: 1px solid var(--edge);
  border-radius: 50%;
  background: var(--sheet);
  box-shadow: var(--lift);
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: 0 0 auto;
}

.tune svg {
  width: 1rem;
  height: 1rem;
}

.name-line {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 1.35rem;
}

.name-hit {
  border: 0;
  background: transparent;
  padding: 0;
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: inherit;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}

.name-hit:hover { color: var(--ink); }

.name-edit {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
}

.name-edit[hidden],
.name-hit[hidden] { display: none; }

.name-edit input {
  width: 7.5rem;
  border: 0;
  border-bottom: 1.5px solid var(--line);
  border-radius: 0;
  background: transparent;
  padding: 0.05rem 0;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 750;
  color: var(--ink);
}

.name-edit input:focus {
  outline: none;
  border-bottom-color: var(--ok);
}

.name-ok {
  width: 1.45rem;
  height: 1.45rem;
  border: 0;
  border-radius: 50%;
  background: var(--ok);
  color: #fff;
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  flex: 0 0 auto;
}

.name-ok svg { width: 0.85rem; height: 0.85rem; }

.status-meta {
  text-align: right;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

.status-meta strong {
  display: block;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 700;
}

/* ===== Devices left menu ===== */
body.devmenu-open { overflow: hidden; }

.devmenu-root {
  position: fixed;
  inset: 0;
  z-index: 70;
  pointer-events: none;
}
.devmenu-root.open { pointer-events: auto; }

.devmenu-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(18, 24, 36, 0.42);
  opacity: 0;
  transition: opacity 0.22s ease;
}
.devmenu-root.open .devmenu-backdrop { opacity: 1; }

.devmenu {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: min(320px, 88vw);
  background: var(--sheet);
  box-shadow: 18px 0 40px rgba(26, 35, 50, 0.18);
  padding: 0.85rem 0.85rem calc(1.2rem + var(--safe));
  transform: translateX(-105%);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.devmenu-root.open .devmenu { transform: translateX(0); }

.devmenu-head {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 0.15rem 0.1rem 0.2rem;
}

.devmenu-tools {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.theme-ico {
  width: 2.4rem;
  height: 2.4rem;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--raised);
  color: var(--ink);
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
}

.theme-ico svg { width: 1.2rem; height: 1.2rem; }
.theme-ico .ico-sun { color: #c47d12; }
.theme-ico .ico-moon { color: #7aa2e3; }
html[data-theme="dark"] .theme-ico .ico-sun { display: none; }
html:not([data-theme="dark"]) .theme-ico .ico-moon { display: none; }


.devmenu-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.1rem;
}

.dev {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  column-gap: 0.65rem;
  row-gap: 0.1rem;
  align-items: center;
  padding: 0.85rem 0.9rem;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--raised);
  color: var(--ink);
  text-decoration: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.dev i {
  grid-row: 1 / span 2;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: currentColor;
}
.dev.on i { color: var(--ok); box-shadow: 0 0 0 4px rgba(31, 170, 110, 0.12); }
.dev.off i { color: var(--bad); box-shadow: 0 0 0 4px rgba(229, 72, 77, 0.1); }

.dev-name {
  font-size: 0.92rem;
  font-weight: 750;
  letter-spacing: -0.02em;
  min-width: 0;
}

.dev-link {
  display: none;
  grid-row: 1 / span 2;
  grid-column: 3;
  width: 1.15rem;
  height: 1.15rem;
  color: #3d6fbf;
}

.dev.paired .dev-link { display: block; }

html[data-theme="dark"] .dev-link { color: #8eb4f0; }

.dev-link svg {
  display: block;
  width: 100%;
  height: 100%;
}

.dev-slot { position: relative; }

.dev-ota-note {
  display: none;
  grid-column: 2;
  margin: 0.15rem 5.4rem 0 0;
  font-size: 0.74rem;
  font-weight: 750;
  color: #c47d12;
}

.dev-slot.has-update .dev-ota-note { display: block; }
.dev-slot.is-installing .dev-ota-note { display: none; }

.dev-ota-btn {
  display: none;
  position: absolute;
  right: 0.7rem;
  bottom: 0.65rem;
  z-index: 2;
  border: 0;
  border-radius: 999px;
  padding: 0.32rem 0.7rem;
  background: var(--ok);
  color: #fff;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 750;
  cursor: pointer;
}

.dev-slot.has-update .dev-ota-btn { display: inline-block; }

.dev-slot.is-pending .dev-ota-btn {
  background: var(--sheet);
  color: var(--muted);
  border: 1px solid var(--line);
  cursor: default;
}

.dev-state {
  grid-column: 2;
  font-size: 0.74rem;
  font-weight: 650;
  color: var(--muted);
}
.dev-fw {
  display: none;
  grid-column: 2;
  font-size: 0.72rem;
  font-weight: 650;
  color: var(--muted);
}
.dev-fw:not(:empty) { display: block; }

.dev.on .dev-state { color: var(--ok); }
.dev.off .dev-state { color: var(--bad); }

.dev.active {
  background: var(--sheet);
  border-color: rgba(31, 170, 110, 0.55);
  box-shadow: 0 0 0 3px rgba(31, 170, 110, 0.12);
}

.week-sum {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin: 0;
  padding: 0.15rem 0.35rem 0.15rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.week-sum strong {
  color: var(--ok);
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-transform: none;
}

.week-sum strong::after {
  content: "›";
  margin-left: 0.28rem;
  color: var(--muted);
  font-weight: 700;
}

.week-sum:active { transform: scale(0.985); }
.week-sum:focus-visible {
  outline: 2px solid var(--now);
  outline-offset: 2px;
  border-radius: 10px;
}

.week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.25rem;
  margin-bottom: 0.9rem;
}

.week a {
  text-align: center;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
  padding: 0.55rem 0;
  border-radius: 999px;
}

.week a.active {
  background: var(--raised);
  color: var(--ink);
}

.week a.is-today:not(.active) {
  color: var(--now);
}

.hour-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.55rem;
  margin-bottom: 0.75rem;
}

.cell {
  position: relative;
  aspect-ratio: 1.15;
  border-radius: 14px;
  border: 1px solid var(--edge);
  background: var(--sheet);
  box-shadow: var(--lift);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.28rem;
  overflow: hidden;
  margin: 0;
  padding: 0;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.cell:active { transform: scale(0.97); }
.cell:disabled { opacity: 1; }

.cell .ico {
  width: 1.15rem;
  height: 1.15rem;
  display: none;
  flex-shrink: 0;
}

.cell .ico-empty {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  border: 1.5px solid var(--offbar);
  background: transparent;
}

.cell .t {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}

/* Іконки */
.cell.on .ico-on,
.cell.link .ico-on { display: block; color: var(--lamp); }
.cell.link .ico-on { color: #c47d12; }
.cell.update .ico-on { display: block; color: #3d6fbf; }
.cell.off .ico-off,
.cell.mixed .ico-off { display: block; color: var(--ink); }
.cell.nodata .ico-empty,
.cell.future .ico-empty { display: block; }

.cell .ico,
.cell .t {
  position: relative;
  z-index: 1;
}

/* База всіх «даних»-клітинок — світла */
.cell.on,
.cell.off,
.cell.mixed,
.cell.link,
.cell.update {
  background: var(--sheet);
  border-color: var(--edge);
}

.cell.link {
  border-color: #e2c48a;
}

.cell.update {
  background: var(--sheet);
  border-color: #b7c9ef;
}

.cell.has-fw::after {
  content: "";
  position: absolute;
  left: 18%;
  right: 18%;
  bottom: 7px;
  height: 3px;
  border-radius: 99px;
  background: #3d6fbf;
}

/* Напівпрозорий оверлей «нема світла» зверху клітинки */
.cell.off::after,
.cell.mixed::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  border-radius: inherit;
  background: rgba(30, 42, 68, 0.48);
  pointer-events: none;
  z-index: 0;
  transition: height 0.35s ease, opacity 0.35s ease;
}

/* вся година без світла — повний оверлей */
.cell.off::after {
  height: 100%;
  background: rgba(30, 42, 68, 0.58);
}

/* частково: оверлей лише на частку без світла (зверху),
   --ratio = % зі світлом → висота оверлею = 100% - ratio */
.cell.mixed::after {
  height: calc(100% - var(--ratio, 50%));
  background: rgba(30, 42, 68, 0.45);
}

.cell.off .t,
.cell.off .ico-off {
  color: #fff;
}
.cell.mixed .t {
  color: var(--ink);
}

/* нема даних у базі — без блискавки, без бічної панелі */
.cell.nodata {
  background: var(--sunken);
  border-color: var(--line);
  cursor: default;
}
.cell.nodata .t { color: var(--muted); }
.cell.nodata:active { transform: none; }

/* майбутні години */
.cell.future {
  background: var(--sheet);
  border-style: dashed;
  border-color: var(--line);
  cursor: default;
}
.cell.future .t { color: var(--muted); }
.cell.future .ico-empty { border-style: dashed; opacity: 0.7; }
.cell.future:active { transform: none; }

/* поточна година */
.cell.now {
  box-shadow: 0 0 0 2.5px var(--now), var(--lift);
  border-color: transparent;
  z-index: 1;
}

.layout-block { position: relative; margin-top: 0.85rem; }
.layout-block .climate,
.layout-block .facts { margin-top: 0; }
.layout-block .stat-row,
.layout-block .hour-grid { margin-bottom: 0; }
.layout-tools,
.layout-empty { display: none; }
.layout-bar {
  position: sticky;
  bottom: 0.75rem;
  display: flex;
  justify-content: center;
  margin-top: 0.85rem;
  z-index: 5;
  pointer-events: none;
}
.layout-bar[hidden] { display: none !important; }
.layout-bar button {
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font: inherit;
  font-weight: 700;
  padding: 0.7rem 1.5rem;
  cursor: pointer;
  pointer-events: auto;
}
body.layout-edit .layout-tools {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 1.5rem;
  margin: 0 0 0.2rem;
  cursor: grab;
  touch-action: none;
}
body.layout-edit .layout-tools::before {
  content: "";
  width: 2.1rem;
  height: 0.22rem;
  border-radius: 999px;
  background: var(--muted);
  box-shadow: 0 0.38rem 0 var(--muted);
}
body.layout-edit .layout-block {
  padding: 0.25rem 0.35rem 0.45rem;
  outline: 1px dashed var(--edge);
  border-radius: 18px;
}
body.layout-edit .layout-block.is-dragging {
  opacity: 0.94;
  box-shadow: var(--shadow);
  cursor: grabbing;
  z-index: 30;
}
.layout-placeholder {
  margin-top: 0.85rem;
  border-radius: 18px;
  outline: 1px dashed var(--edge);
  background: rgba(47, 107, 255, 0.07);
}
.layout-block .hero-card { margin-bottom: 0; }
#climate[hidden],
#lux[hidden],
#block-ble[hidden] { display: none !important; }
body.layout-edit #climate[hidden],
body.layout-edit #lux[hidden],
body.layout-edit #block-ble[hidden] { display: block !important; }
body.layout-edit #climate.is-off[hidden],
body.layout-edit #lux.is-off[hidden] { display: none !important; }
body.layout-edit .layout-block[hidden] > :not(.layout-tools):not(.layout-empty) { display: none !important; }
body.layout-edit .layout-block[hidden] .layout-empty {
  display: block;
  margin: 0;
  padding: 0.15rem 0.55rem 0.35rem;
  color: var(--muted);
}

.climate {
  margin: 0.75rem 0 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}
.climate .fact[hidden] { display: none; }
#climate.is-stale .climate,
#lux.is-stale .climate { opacity: 0.55; }
.climate .lux-lit { color: var(--ok); }
.climate .lux-dim { color: var(--warn); }
.climate .lux-dark { color: var(--muted); }

.facts {
  margin-top: 0.75rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}

.fact {
  background: var(--sheet);
  border-radius: 16px;
  border: 1px solid var(--edge);
  box-shadow: var(--shadow);
  padding: 0.75rem 0.8rem;
}

.fact .k {
  display: block;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.fact .v {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.fact strong {
  font-size: 0.98rem;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.fact small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.fact.wide { grid-column: 1 / -1; }
.fact .q-good { color: var(--ok); }
.fact .q-medium { color: var(--warn); }
.fact .q-bad { color: var(--bad); }
.fact.ble-on strong { color: var(--ok); }
.fact.ble-off strong { color: var(--bad); }

/* Коли нема світла — не показуємо «живий» Wi‑Fi з останнього heartbeat */
.wifi-offline { display: none; color: var(--muted); font-weight: 700; }
.fact.is-stale .wifi-live,
.stat.is-stale .stat-body .wifi-live { display: none; }
.fact.is-stale .wifi-offline { display: inline; }
.stat .stat-body .wifi-offline { display: none; }
.stat.is-stale .stat-body .wifi-offline { display: block; }
.fact.is-stale #bleRssi { display: none; }

.wifi {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 0.9rem;
}
.wifi i {
  width: 3px;
  border-radius: 1px;
  background: #d0d5de;
  display: block;
}
.wifi i:nth-child(1) { height: 35%; }
.wifi i:nth-child(2) { height: 55%; }
.wifi i:nth-child(3) { height: 75%; }
.wifi i:nth-child(4) { height: 100%; }
.wifi.q-good i.on { background: var(--ok); }
.wifi.q-medium i.on { background: var(--warn); }
.wifi.q-bad i.on { background: var(--bad); }

.empty {
  background: var(--sheet);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 1.4rem 1.1rem;
}
.empty h2 {
  margin: 0;
  font-family: var(--font-brand);
  font-size: 1.3rem;
}
.empty p {
  color: var(--muted);
  line-height: 1.45;
}
.empty code { color: #c79200; }

.claim-banner {
  margin: 0 0 0.8rem;
  background: rgba(229, 72, 77, 0.08);
  color: var(--bad);
  border: 1px solid rgba(229, 72, 77, 0.25);
  border-radius: 16px;
  padding: 0.75rem 0.9rem;
  font-size: 0.9rem;
  font-weight: 700;
}

.mail-banner {
  margin: 0 0 0.8rem;
  background: rgba(229, 72, 77, 0.08);
  color: var(--bad);
  border: 1px solid rgba(229, 72, 77, 0.25);
  border-radius: 16px;
  padding: 0.75rem 0.9rem;
  font-size: 0.9rem;
  font-weight: 700;
}

.mail-banner.is-ok {
  background: rgba(31, 170, 110, 0.1);
  color: var(--hero-on);
  border-color: rgba(31, 170, 110, 0.28);
}

.mail-state {
  margin: 0 0 0.55rem;
  font-size: 0.88rem;
  font-weight: 650;
}

.mail-form .code-field {
  display: block;
  width: 100%;
}

.claim-form {
  display: flex;
  gap: 0.45rem;
  margin-top: 0.85rem;
}

.claim-form.mail-form {
  display: block;
  width: 100%;
  margin-top: 0.75rem;
}

.claim-form input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.75rem 0.85rem;
  font: inherit;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--raised);
  color: var(--ink);
}

.claim-form button {
  border: 0;
  border-radius: 14px;
  padding: 0.75rem 0.95rem;
  font: inherit;
  font-weight: 800;
  background: var(--ok);
  color: #fff;
  cursor: pointer;
}

.forget-form button {
  border: 0;
  border-radius: 0;
  padding: 0.15rem 0;
  background: transparent;
  color: var(--bad);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
}

.menu-add {
  padding: 0 0.15rem;
}

.menu-add-link {
  border: 0;
  background: none;
  padding: 0.1rem 0 0.15rem;
  color: var(--muted);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 400;
  cursor: pointer;
}

.menu-add-link[hidden] { display: none; }

.menu-add-form {
  display: block;
  margin: 0.35rem 0 0;
}

.menu-add-form[hidden] { display: none; }

.menu-add-form .code-field,
.mail-form .code-field {
  position: relative;
}

.menu-add-form .code-field input,
.mail-form .code-field input {
  width: 100%;
  padding-right: 3.5rem;
  text-align: left;
}

.mail-form .code-field input {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 650;
}

.menu-add-form .code-field button {
  position: absolute;
  top: 50%;
  right: 0.35rem;
  transform: translateY(-50%);
  width: auto;
  height: 1.85rem;
  padding: 0 0.7rem;
  border-radius: 10px;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
}

.mail-form .code-field input {
  padding-right: 2.7rem;
}

.mail-form .code-field button {
  position: absolute;
  top: 50%;
  right: 0.28rem;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 1.85rem;
  height: 1.85rem;
  padding: 0;
  border-radius: 999px;
}

.mail-form .code-field button svg {
  width: 1rem;
  height: 1rem;
}

.menu-add:has(form[hidden]) { display: none; }

.menu-add-form .code-field input {
  padding-right: 4.7rem;
}

.menu-add-form .code-actions {
  position: absolute;
  top: 50%;
  right: 0.28rem;
  transform: translateY(-50%);
  display: flex;
  gap: 0.22rem;
}

.menu-add-form .code-actions button {
  position: static;
  transform: none;
  flex: none;
  width: 1.85rem;
  height: 1.85rem;
  padding: 0;
  border-radius: 999px;
  display: grid;
  place-items: center;
}

.menu-add-form .code-actions svg {
  width: 1rem;
  height: 1rem;
}

.menu-add-form .code-cancel {
  background: var(--raised);
  color: var(--muted);
  border: 1px solid var(--line);
}

#bleList { display: contents; }
#bleList.is-empty { display: none; }

.set-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.set-card-head h2 {
  margin: 0;
  font-family: var(--font-brand);
  font-size: calc(1.25rem - 2pt);
  letter-spacing: -0.03em;
  color: var(--ink);
}

.air-scan {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 2.15rem;
  height: 2.15rem;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--ok);
  color: #fff;
  cursor: pointer;
}

.air-scan svg {
  width: 1.35rem;
  height: 1.35rem;
}

.air-scan.is-wait {
  position: relative;
}

.air-scan.is-wait::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  border: 1.5px solid transparent;
  border-top-color: currentColor;
  animation: scan-spin 1s linear infinite;
}

.air-scan:disabled {
  background: var(--sunken);
  color: var(--muted);
  cursor: default;
}

@keyframes scan-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .air-scan.is-wait::after { animation: none; }
}

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

.air-note {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 650;
  line-height: 1.4;
}

.air-head form {
  margin: 0;
  flex: 0 0 auto;
}

.air-head button,
.air-row button {
  border: 0;
  border-radius: 14px;
  padding: 0.72rem 0.9rem;
  font: inherit;
  font-weight: 800;
  background: var(--ok);
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
}

.air-head button:disabled {
  background: #e7ebf1;
  color: var(--muted);
  cursor: default;
}

.air-block {
  margin-top: 0.95rem;
}

.drawer .air-block > .k {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

#boardDrawer .forget-form {
  margin-top: auto;
  padding-top: 1.5rem;
}

.air-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--line);
}

.air-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.air-row strong {
  display: block;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
}

.air-row small {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.air-row form {
  margin: 0;
}

.air-row button,
.air-kept {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 2.15rem;
  height: 2.15rem;
  margin: 0;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--raised);
  color: var(--muted);
}

.air-row button svg,
.air-kept svg {
  width: 1.05rem;
  height: 1.05rem;
}

.air-row button.is-add {
  border: 0;
  background: var(--ok);
  color: #fff;
}

.air-kept { color: var(--ok); }

.air-empty {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 650;
}

.forget-form {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.35rem;
}

.forget-confirm {
  width: 100%;
  padding: 0.85rem 0.9rem 0.75rem;
  border: 1px solid rgba(229, 72, 77, 0.28);
  border-radius: 16px;
  background: rgba(229, 72, 77, 0.06);
}

.forget-confirm p {
  margin: 0;
  font-weight: 800;
}

.forget-confirm ul {
  margin: 0.55rem 0 0;
  padding-left: 1.1rem;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 650;
  line-height: 1.4;
}

.forget-confirm li + li {
  margin-top: 0.35rem;
}

.forget-actions {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  margin-top: 0.8rem;
}

.forget-actions button[type="button"] {
  color: var(--muted);
}


@media (min-width: 400px) {
  .cell .t { font-size: 0.84rem; }
  .cell .ico:not(.ico-empty) { width: 1.25rem; height: 1.25rem; }
}

/* ===== Side drawer (детальний графік) ===== */
body.drawer-open { overflow: hidden; }

.drawer-root {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
}

.drawer-root.open { pointer-events: auto; }

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 28, 40, 0.35);
  opacity: 0;
  transition: opacity 0.28s ease;
}

.drawer-root.open .drawer-backdrop { opacity: 1; }

.drawer {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: min(100%, 420px);
  background: var(--sheet);
  box-shadow: -12px 0 40px rgba(26, 35, 50, 0.18);
  transform: translateX(105%);
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
  display: flex;
  flex-direction: column;
  padding: 0 1rem calc(1.2rem + var(--safe));
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.drawer-root.open .drawer { transform: translateX(0); }

.drawer-head {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0 -1rem 0.85rem;
  padding: 1rem 1rem 0.7rem;
  background: var(--sheet);
  border-bottom: 1px solid var(--line);
}

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

.drawer-head h2 {
  margin: 0.2rem 0 0;
  font-family: var(--font-brand);
  font-size: 1.25rem;
  letter-spacing: -0.03em;
}

.drawer-close {
  width: 2.4rem;
  height: 2.4rem;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--raised);
  font-size: 1.4rem;
  line-height: 1;
  color: var(--ink);
  cursor: pointer;
}

.drawer-hour-sum {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  margin-bottom: 0.7rem;
}

.hour-sum-row {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.65rem 0.75rem;
  border-radius: 14px;
  border: 1px solid var(--edge);
  background: var(--sheet);
  box-shadow: var(--lift);
}

.hour-sum-row span {
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 750;
}

.hour-sum-row strong {
  font-size: 1.02rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.hour-sum-row.on strong { color: var(--ok); }
.hour-sum-row.off strong { color: var(--bad); }

.chart-wrap {
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.65rem 0.5rem 0.4rem;
  margin-bottom: 1rem;
}

.chart {
  width: 100%;
  height: 190px;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

.chart-axis {
  display: flex;
  justify-content: space-between;
  padding: 0.25rem 0.35rem 0.15rem;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.drawer-section h3 {
  margin: 0 0 0.55rem;
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.switch-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.switch-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  border-radius: 12px;
  background: var(--raised);
  border: 1px solid var(--line);
  cursor: pointer;
  font-size: 0.9rem;
}

.switch-list li strong {
  font-variant-numeric: tabular-nums;
}

.switch-list .sw-on span { color: var(--ok); font-weight: 700; }
.switch-list .sw-off span { color: var(--bad); font-weight: 700; }
.switch-list .sw-link span { color: #c47d12; font-weight: 700; }
.switch-list .sw-fw span { color: #3d6fbf; font-weight: 700; }
.switch-list .sw-fault span { color: #6d5bd0; font-weight: 700; }

.light-btn {
  border: 0;
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  background: var(--ok);
  color: #fff;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 750;
  cursor: pointer;
}

.light-btn:disabled { opacity: 0.55; }

.set-card {
  margin-top: 0.85rem;
  padding: 0.85rem 0.9rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--raised);
}

.drawer > .set-card:first-of-type {
  margin-top: 0.15rem;
}

.set-card > h2 {
  margin: 0;
  font-family: var(--font-brand);
  font-size: calc(1.25rem - 2pt);
  letter-spacing: -0.03em;
  color: var(--ink);
}

.set-card > p,
#placeBox > p {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
  line-height: 1.4;
}

.sensor-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.75rem;
  color: var(--ink);
  font-weight: 700;
}

.sensor-sw {
  position: relative;
  flex: none;
  width: 2.6rem;
  height: 1.5rem;
  border: 0;
  border-radius: 999px;
  background: var(--offbar);
  cursor: pointer;
}

.sensor-sw::after {
  content: "";
  position: absolute;
  top: 0.15rem;
  left: 0.15rem;
  width: 1.2rem;
  height: 1.2rem;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s ease;
}

.sensor-sw[aria-checked="true"] { background: var(--ok); }
.sensor-sw[aria-checked="true"]::after { transform: translateX(1.1rem); }

.place-label {
  display: block;
  margin-top: 0.75rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

#placeInput {
  width: 100%;
  margin-top: 0.35rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.7rem 0.85rem;
  font: inherit;
  font-weight: 650;
  background: var(--raised);
  color: var(--ink);
}

.place-list {
  display: grid;
  gap: 0.3rem;
  margin-top: 0.4rem;
}

.place-list[hidden],
.place-clear[hidden],
.sensor-row[hidden],
#placeBox[hidden],
#luxSettings[hidden],
#sensorBlock[hidden] { display: none !important; }

.place-list button,
.place-empty {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.55rem 0.7rem;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 650;
  text-align: left;
  cursor: pointer;
}

.place-empty { color: var(--muted); cursor: default; }

.place-clear {
  margin-top: 0.5rem;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.pair-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  margin-top: 0.7rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--line);
}

.pair-row strong {
  display: block;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
}

.pair-row small {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.pair-btn {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 2.15rem;
  height: 2.15rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--ok);
  color: #fff;
  cursor: pointer;
}

.pair-btn svg {
  width: 1.15rem;
  height: 1.15rem;
}

.pair-btn.is-on {
  background: var(--sheet);
  color: var(--ink);
  border: 1px solid var(--line);
}

.pair-btn:disabled { opacity: 0.55; }

.dev.link .dev-state { color: #c47d12; }
.dev.upd .dev-state { color: #3d6fbf; }

.drawer-empty {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

/* ===== Today fact → day stats sheet ===== */
.fact-tap {
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  color: inherit;
  text-align: left;
  width: 100%;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.fact-tap:active { transform: scale(0.985); }
.fact-tap:focus-visible {
  outline: 2px solid var(--now);
  outline-offset: 2px;
}

.fact-tap .k {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.fact-tap .k em {
  font-style: normal;
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--now);
  font-weight: 800;
  opacity: 0.85;
}

body.daystat-open { overflow: hidden; }

.daystat-root {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
}

.daystat-root.open { pointer-events: auto; }

.daystat-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(18, 24, 36, 0.42);
  opacity: 0;
  transition: opacity 0.22s ease;
}

.daystat-root.open .daystat-backdrop { opacity: 1; }

.daystat-sheet {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: min(430px, 100%);
  transform: translate(-50%, 110%);
  background: var(--sheet);
  border-radius: 22px 22px 0 0;
  border-top: 1px solid var(--edge);
  box-shadow: 0 -18px 40px rgba(26, 35, 50, 0.18);
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.daystat-root.open .daystat-sheet { transform: translate(-50%, 0); }

/* Шапка поза прокруткою. Висота списку — у dvh/svh, не у відсотках:
   на телефоні 100% і flex лишають панель вищою за видимий екран,
   і кнопка закриття ховається під панеллю браузера. */
.daystat-pin {
  flex: 0 0 auto;
  padding: 0.1rem 1rem 0.45rem;
  background: var(--sheet);
  border-bottom: 1px solid var(--line);
}

.daystat-scroll {
  flex: 0 1 auto;
  min-height: 0;
  max-height: calc(100vh - 11rem);
  max-height: calc(100svh - 8rem);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 0.85rem 1rem calc(1.15rem + var(--safe));
}

.daystat-handle {
  width: 42px;
  height: 4px;
  border-radius: 999px;
  background: var(--line);
  margin: 0.15rem auto 0.65rem;
}

.daystat-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

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

.daystat-head h2 {
  margin: 0.15rem 0 0;
  font-family: var(--font-brand);
  font-size: 1.25rem;
  letter-spacing: -0.03em;
}

.daystat-sub {
  margin: 0 0 0.9rem;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 600;
}

.daystat-bar {
  display: flex;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--sunken);
  margin-bottom: 1rem;
}

.daystat-bar i {
  display: block;
  min-width: 0;
  transition: flex 0.35s ease;
}

.daystat-bar .on {
  background: linear-gradient(90deg, #17a066, #2dca84);
}

.daystat-bar .off {
  background: linear-gradient(90deg, #d96a6e, #e5484d);
}

.daystat-rows {
  display: grid;
  gap: 0.55rem;
}

.daystat-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.7rem;
  padding: 0.85rem 0.9rem;
  border-radius: 16px;
  border: 1px solid var(--edge);
  background: var(--sheet);
  box-shadow: var(--lift);
}

.daystat-row .meta strong {
  color: var(--ink);
}

.daystat-row[hidden],
.daystat-breaks[hidden] {
  display: none !important;
}

.daystat-row .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.daystat-row.on .dot { background: var(--ok); box-shadow: 0 0 0 4px rgba(31, 170, 110, 0.18); }
.daystat-row.off .dot { background: var(--bad); box-shadow: 0 0 0 4px rgba(229, 72, 77, 0.12); }

.daystat-row .meta strong {
  display: block;
  font-size: 0.92rem;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.daystat-row .meta small {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 600;
}

.daystat-row .nums {
  text-align: right;
}

.daystat-row .nums b {
  display: block;
  font-size: 0.98rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.daystat-row .nums em {
  font-style: normal;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.daystat-row.on .nums b { color: var(--ok); }
.daystat-row.off .nums b { color: var(--bad); }

.daystat-breaks {
  margin-top: 1.15rem;
  padding-top: 0.95rem;
  border-top: 1px solid var(--line);
}

.daystat-breaks h3 {
  margin: 0 0 0.7rem;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 800;
}

.daystat-break-list {
  display: grid;
  gap: 0.45rem;
}

.daystat-break {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.55rem;
  align-items: center;
  width: 100%;
  padding: 0.7rem 0.75rem;
  border-radius: 14px;
  border: 1px solid var(--edge);
  background: var(--sheet);
  box-shadow: var(--lift);
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.daystat-break:active { transform: scale(0.985); }
.daystat-break:focus-visible {
  outline: 2px solid var(--now);
  outline-offset: 2px;
}

.daystat-break.is-live {
  border-color: rgba(229, 72, 77, 0.35);
  background: rgba(229, 72, 77, 0.05);
}

.daystat-break .badge {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--bad);
  background: rgba(229, 72, 77, 0.1);
  padding: 0.28rem 0.45rem;
  border-radius: 999px;
  white-space: nowrap;
}

.daystat-break .meta strong {
  color: var(--ink);
  display: block;
  font-size: 0.84rem;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.daystat-break .meta small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
}

.daystat-break .dur {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--bad);
  white-space: nowrap;
}

.daystat-break-empty {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
}

.week-days {
  display: grid;
  gap: 0.4rem;
  margin-top: 1.05rem;
}

.week-day {
  display: grid;
  grid-template-columns: 3.4rem 1fr auto;
  gap: 0.65rem;
  align-items: center;
  width: 100%;
  padding: 0.62rem 0.75rem;
  border-radius: 14px;
  border: 1px solid var(--edge);
  background: var(--sheet);
  box-shadow: var(--lift);
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.week-day:active { transform: scale(0.985); }
.week-day:focus-visible {
  outline: 2px solid var(--now);
  outline-offset: 2px;
}

.week-day.is-today {
  border-color: rgba(31, 170, 110, 0.45);
}

.week-day .who {
  display: block;
  font-size: 0.84rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.week-day .who small {
  display: block;
  margin-top: 0.08rem;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
}

.week-day .track {
  height: 8px;
  border-radius: 999px;
  background: var(--sunken);
  overflow: hidden;
}

.week-day .track i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #17a066, #2dca84);
}

.week-day .nums {
  text-align: right;
  min-width: 4.6rem;
}

.week-day .nums b {
  display: block;
  font-size: 0.84rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.week-day .nums em {
  font-style: normal;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.week-longest {
  margin-top: 1.05rem;
}

.top .name-hit {
  max-width: 6rem;
  padding: 0.38rem 0.7rem;
  border: 1px solid var(--edge);
  border-radius: 999px;
  background: var(--sheet);
  box-shadow: var(--lift);
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: none;
}

.top .name-edit input {
  width: 5.6rem;
  background: transparent;
  color: var(--ink);
}

.hero-card {
  border-radius: 24px;
  padding: 1.15rem 1.15rem 1rem;
  margin-bottom: 0.75rem;
  border: 1px solid transparent;
}

.hero-card.is-on {
  background: var(--hero-on-bg);
  color: var(--hero-on);
  border-color: rgba(20, 107, 69, 0.16);
  box-shadow: 0 10px 24px rgba(20, 80, 50, 0.10), 0 1px 2px rgba(20, 80, 50, 0.05);
}
.hero-card.is-link {
  background: #fff8ec;
  color: #8a5a10;
  border-color: rgba(196, 125, 18, 0.28);
  box-shadow: 0 10px 24px rgba(160, 110, 30, 0.08);
}
.hero-card.is-update {
  background: #eef3ff;
  color: #2a4f93;
  border-color: rgba(61, 111, 191, 0.28);
  box-shadow: 0 10px 24px rgba(40, 70, 140, 0.08);
}
.hero-card.is-off {
  background: var(--hero-off-bg);
  color: var(--hero-off);
  border-color: rgba(194, 53, 59, 0.18);
  box-shadow: 0 10px 24px rgba(160, 40, 48, 0.10), 0 1px 2px rgba(160, 40, 48, 0.05);
}

html[data-theme="dark"] .hero-card.is-on {
  border-color: rgba(109, 255, 176, 0.18);
  box-shadow: var(--shadow);
}
html[data-theme="dark"] .hero-card.is-update {
  background: #152033;
  color: #9eb6f0;
  border-color: rgba(142, 180, 240, 0.28);
}
html[data-theme="dark"] .dev.upd .dev-state,
html[data-theme="dark"] .cell.update .ico-on,
html[data-theme="dark"] .switch-list .sw-fw span { color: #8eb4f0; }
html[data-theme="dark"] .switch-list .sw-fault span { color: #b7a6f5; }
html[data-theme="dark"] .hero-card.is-off {
  border-color: rgba(255, 154, 160, 0.2);
  box-shadow: var(--shadow);
}

.hero-card h2 {
  margin: 0;
  font-size: 1.28rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  text-transform: uppercase;
}

.hero-card p {
  margin: 0.4rem 0 0;
  font-size: 0.92rem;
  font-weight: 650;
  opacity: 0.78;
}

.week a.active {
  background: var(--sheet);
  box-shadow: var(--shadow);
}

.day-card,
.stat {
  background: var(--sheet);
  border: 1px solid var(--edge);
  box-shadow: var(--shadow);
}

.day-card {
  border-radius: 24px;
  padding: 0.95rem 0.95rem 0.4rem;
  margin-bottom: 0.75rem;
}

.day-head span {
  font-size: 1.02rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.ribbon-wrap {
  position: relative;
  margin: 1.55rem 0 0.15rem;
}

.now-pill {
  position: absolute;
  top: -1.45rem;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--sheet);
  font-size: 0.68rem;
  font-weight: 800;
  border-radius: 999px;
  padding: 0.18rem 0.42rem;
  pointer-events: none;
}

.now-pill[hidden] { display: none; }

.ribbon {
  display: flex;
  align-items: stretch;
  gap: 0;
  height: 2.75rem;
  touch-action: manipulation;
}

.hbar {
  flex: 1 1 0;
  min-width: 0;
  height: 100%;
  box-sizing: border-box;
  padding: 0;
  border: 0;
  border-right: 2px solid var(--sheet);
  border-radius: 3px;
  background: var(--track);
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.hbar:last-child { border-right: 0; }

.hbar.on { background: linear-gradient(180deg, #6eeb9a, var(--ok)); }
.hbar.off { background: var(--offbar); }
.hbar.mixed { background: var(--offbar); }
.hbar.mixed::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--ratio, 50%);
  background: linear-gradient(180deg, #6eeb9a, var(--ok));
}
.hbar.nodata,
.hbar.future {
  cursor: default;
  background: var(--track);
}
.hbar.now {
  box-shadow: inset 0 0 0 1.5px var(--ink);
}
.hbar:focus-visible {
  outline: 2px solid var(--ok);
  outline-offset: 2px;
}
.hbar:disabled { opacity: 1; }
.hbar:active:not(:disabled) { filter: brightness(1.18); }

.ribbon-scale {
  position: relative;
  height: 1.15rem;
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.ribbon-scale span {
  position: absolute;
  top: 0.28rem;
  transform: translateX(-50%);
}

.ribbon-scale span:nth-child(1) { left: 0; transform: none; }
.ribbon-scale span:nth-child(2) { left: 25%; }
.ribbon-scale span:nth-child(3) { left: 50%; }
.ribbon-scale span:nth-child(4) { left: 75%; }
.ribbon-scale span:nth-child(5) { left: 100%; transform: translateX(-100%); }

.iv {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 0.62rem 0;
  border-top: 1px solid var(--line);
  font: inherit;
  font-weight: 750;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.iv-time { min-width: 7.4rem; letter-spacing: -0.02em; }
.iv i {
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 50%;
  background: currentColor;
}
.iv.on { color: var(--ok); }
.iv.on .iv-time { color: var(--ink); }
.iv.off { color: var(--muted); }
.iv.off .iv-time { color: var(--ink); }

.iv-empty {
  margin: 0.7rem 0 0.8rem;
  color: var(--muted);
  font-weight: 650;
}

.stat-row {
  display: grid;
  grid-template-columns: 1.05fr 1.25fr 0.82fr;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.stat {
  border-radius: 20px;
  padding: 0.7rem 0.7rem 0.75rem;
  text-align: left;
  color: inherit;
  font: inherit;
  min-width: 0;
}

button.stat { cursor: pointer; }

.stat .k {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 750;
}

.stat-body {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}

.stat-body strong {
  display: block;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.boards-now { min-height: 1.35rem; }
.boards-now strong {
  font-size: 1.35rem;
  line-height: 1;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}
.boards-now .is-all { color: var(--ok); }
.boards-now .is-none { color: var(--bad); }
.boards-now .is-part { color: var(--ink); }

.stat-body small {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.ring {
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 50%;
  background: conic-gradient(var(--ok) calc(var(--pct) * 1%), var(--line) 0);
  position: relative;
  flex: 0 0 auto;
}

.ring::after {
  content: "";
  position: absolute;
  inset: 3.5px;
  border-radius: 50%;
  background: var(--sheet);
}

.menu-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  width: 100%;
  margin-top: 0.35rem;
  border: 0;
  border-radius: 14px;
  background: var(--bad);
  color: #fff;
  font: inherit;
  font-weight: 750;
  text-decoration: none;
  padding: 0.72rem 0.85rem;
  cursor: pointer;
}

.menu-logout svg {
  width: 1.15rem;
  height: 1.15rem;
  flex: 0 0 auto;
}

.menu-logout:active { transform: scale(0.985); }

html[data-theme="dark"] .dev.active,
html[data-theme="dark"] .tune,
html[data-theme="dark"] .air-row button,
html[data-theme="dark"] .air-kept {
  background: var(--sheet);
}

html[data-theme="dark"] .air-row button.is-add {
  background: var(--ok);
  color: #fff;
}

/* Шапка в один ряд: меню і назва програми, справа — ім’я плати або «Вийти». */
.top {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "brand brand name";
  align-items: center;
  column-gap: 0.55rem;
  row-gap: 0.6rem;
}

.top-left { grid-area: brand; min-width: 0; }
.top-right { display: contents; }
.top .name-line { grid-area: name; min-width: 0; justify-self: end; }
.top .logout { grid-area: name; justify-self: end; }

.top .name-hit { max-width: min(14rem, 100%); }

.board-step {
  width: 1.55rem;
  height: 1.55rem;
  flex: 0 0 auto;
  border: 1px solid var(--edge);
  border-radius: 999px;
  background: var(--sheet);
  color: var(--muted);
  box-shadow: var(--lift);
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
}

.board-step svg {
  width: 0.95rem;
  height: 0.95rem;
}

.board-step:hover { color: var(--ink); }
.board-step:active { transform: scale(0.94); }
.board-step[hidden] { display: none; }
.board-step:disabled {
  opacity: 0.32;
  color: var(--muted);
  cursor: default;
  box-shadow: none;
}
.board-step:disabled:hover { color: var(--muted); }
.board-step:disabled:active { transform: none; }

.name-line.has-steps .name-hit {
  max-width: min(9.5rem, 34vw);
}
