:root {
  --bg: #f3f5f2;
  --surface: #ffffff;
  --surface-2: #eef1ec;
  --text: #17201a;
  --muted: #66716a;
  --line: #dde3dc;
  --accent: #2f8f4e;
  --accent-soft: #e2f2e6;
  --accent-text: #ffffff;
  --cool: #2f7dd1;
  --cool-soft: #e3eefb;
  --warn: #c77a12;
  --warn-soft: #fbf0dc;
  --danger: #c93c3c;
  --danger-soft: #fbe5e5;
  --shadow: 0 1px 2px rgba(20, 30, 20, .06), 0 4px 16px rgba(20, 30, 20, .05);
  --radius: 18px;
  --s1: #2f8f4e; --s2: #2f7dd1; --s3: #c77a12; --s4: #8a5cc7; --s5: #c93c7a; --s6: #1d9a9a;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1310;
    --surface: #171e19;
    --surface-2: #202923;
    --text: #e8eee9;
    --muted: #93a097;
    --line: #2a352d;
    --accent: #4cb86c;
    --accent-soft: #1d3424;
    --accent-text: #0b130d;
    --cool: #5aa2ec;
    --cool-soft: #17293d;
    --warn: #e8a03c;
    --warn-soft: #3a2c14;
    --danger: #ec6b6b;
    --danger-soft: #3d1b1b;
    --shadow: none;
    --s1: #4cb86c; --s2: #5aa2ec; --s3: #e8a03c; --s4: #a985e0; --s5: #e46aa3; --s6: #3cc4c4;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
  min-height: 100vh;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { display: block; }

/* ---------- topo ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
}
.top-row { display: flex; align-items: center; gap: 10px; max-width: 760px; margin: 0 auto; }
#subnav { max-width: 760px; margin: 0 auto; }
#subnav:empty { display: none; }
.top h1 { font-size: 28px; line-height: 1.1; margin: 0; letter-spacing: -.02em; flex: 1; }
.top .sub { display: block; font-size: 13px; font-weight: 400; color: var(--muted); letter-spacing: 0; margin-top: 2px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 0;
  background: var(--surface); box-shadow: var(--shadow);
  display: grid; place-items: center; position: relative; color: var(--text);
}
.icon-btn svg { width: 20px; height: 20px; }
.badge {
  position: absolute; top: -2px; right: -2px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700;
  display: grid; place-items: center;
}
.badge[hidden] { display: none; }

main { max-width: 760px; margin: 0 auto; padding: 4px 16px 24px; }
.section-title {
  font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin: 22px 4px 8px; display: flex; justify-content: space-between; align-items: center;
}
.section-title button { text-transform: none; letter-spacing: 0; font-weight: 600; font-size: 14px;
  background: none; border: 0; color: var(--accent); padding: 0; }

.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }

/* ---------- ambientes ---------- */
.env { margin-top: 26px; }
.env-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 4px 10px; }
.env-head[role=button] { cursor: pointer; }
.env-head h2 { font-size: 21px; margin: 0; letter-spacing: -.01em; }
.env-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; font-size: 13px; color: var(--muted); }
.env-edit { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: var(--accent); background: var(--surface); box-shadow: var(--shadow); flex: none; }
.env-edit svg { width: 17px; height: 17px; }
.block { margin-top: 12px; }
.linked-cap { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin: 0 4px 6px; }
.linked-cap svg { width: 15px; height: 15px; flex: none; }
.pill.stage-clone { background: var(--cool-soft); color: var(--cool); }
.pill.stage-vega { background: var(--accent-soft); color: var(--accent); }
.pill.stage-flora { background: color-mix(in srgb, var(--s4) 16%, transparent); color: var(--s4); }
.pill.stage-secagem { background: var(--warn-soft); color: var(--warn); }
.env-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 26px; }
.btn.secondary { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); font-size: 15px; padding: 12px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.btn.secondary svg { width: 18px; height: 18px; }
.btn:disabled { opacity: .5; }
.check-row { cursor: pointer; }
.check-row .ic-sm { color: var(--muted); display: grid; place-items: center; }
.check-row .ic-sm svg { width: 20px; height: 20px; }
.check-row .t { flex: 1; font-size: 15px; }
.check-row .t small { display: block; font-size: 12px; color: var(--muted); }
.check-row input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--accent); }

/* abas de ambiente */
/* VPD: azul = úmido demais, verde = no alvo, laranja = seco demais */
.vpd { margin-top: 6px; font-size: 14px; font-variant-numeric: tabular-nums; display: flex; flex-direction: column; gap: 1px; }
.vpd b { font-size: 16px; }
.vpd small { font-size: 11.5px; color: var(--muted); }
.vpd-ok, .vpd-ok b { color: var(--accent); }
.vpd-low, .vpd-low b { color: var(--cool); }
.vpd-high, .vpd-high b { color: var(--warn); }
.ov-vpd { font-size: 13px !important; font-weight: 600; padding: 1px 6px; border-radius: 6px; background: var(--surface-2); }
/* fases da tabela de VPD (mesmas cores) */
.pill.phase-red { background: color-mix(in srgb, #d9534f 18%, transparent); color: #d9534f; }
.pill.phase-green { background: color-mix(in srgb, #5cb85c 20%, transparent); color: #3f9d3f; }
.pill.phase-orange { background: color-mix(in srgb, #f0ad4e 22%, transparent); color: #c67f12; }
@media (prefers-color-scheme: dark) {
  .pill.phase-red { color: #f08482; } .pill.phase-green { color: #7fd17f; } .pill.phase-orange { color: #f5bd6b; }
}
.vpd-hint { background: var(--surface); border-radius: 12px; padding: 10px 12px; margin: 0 0 14px; line-height: 1.9; }

/* VPD automático no cartão do ar */
.climate { margin-top: 14px; padding: 12px; border-radius: 14px; background: var(--surface-2); }
.climate.on { background: var(--accent-soft); }
.climate-head { display: flex; align-items: center; gap: 10px; }
.climate-head > div { flex: 1; min-width: 0; }
.climate-head b { display: block; font-size: 15px; }
.climate-head small { display: block; font-size: 12px; color: var(--muted); }
.link { border: 0; background: none; color: var(--accent); font-weight: 600; font-size: 14px; padding: 4px; }
.climate-status { font-size: 13px; color: var(--muted); margin-top: 8px; line-height: 1.35; }
.climate-status b { color: var(--text); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font-size: 12.5px; font-weight: 600; padding: 3px 8px; border-radius: 99px; background: var(--surface); }
.prio { border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 99px; font-size: 12px; padding: 4px 9px; white-space: nowrap; }
.prio.sel { border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* abas grandes, dividindo a largura toda da tela (rolam só se houver muitos ambientes) */
.env-tabs {
  display: flex; gap: 4px; margin-top: 12px; padding: 4px; border-radius: 16px;
  background: var(--surface-2); overflow-x: auto; scrollbar-width: none; scroll-behavior: smooth;
}
.env-tabs::-webkit-scrollbar { display: none; }
.env-tabs button {
  flex: 1 0 0; min-width: 112px; min-height: 52px; border: 0; border-radius: 12px; padding: 6px 10px;
  font-size: 16px; font-weight: 600; line-height: 1.15; text-align: center;
  background: none; color: var(--muted);
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.env-tabs button.sel { background: var(--accent); color: var(--accent-text); box-shadow: 0 2px 8px rgba(0,0,0,.18); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.dot.warn { background: var(--warn); }
.dot.off { background: var(--danger); }
.env-tabs button.sel .dot { box-shadow: 0 0 0 2px var(--accent-text); }

/* cartões de resumo */
.ov-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); margin-top: 14px; }
.ov-card { cursor: pointer; display: flex; flex-direction: column; gap: 8px; }
.ov-card:active { transform: scale(.99); }
.ov-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.ov-head b { font-size: 18px; letter-spacing: -.01em; }
.ov-sensor { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; border-top: 1px solid var(--line); padding-top: 8px; }
.ov-name { font-size: 13px; color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ov-val { display: flex; align-items: baseline; gap: 10px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ov-val b { font-size: 24px; font-weight: 600; letter-spacing: -.02em; }
.ov-val span { display: inline-flex; align-items: center; gap: 2px; font-size: 15px; }
.ov-val svg { width: 13px; height: 13px; color: var(--cool); }
.ov-line { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.ov-line svg { width: 15px; height: 15px; flex: none; }
.back-link { border: 0; background: none; color: var(--accent); font-size: 16px; font-weight: 600; padding: 14px 4px 0; }

/* escolha de layout */
.layout-opts { display: grid; gap: 10px; }
.layout-opt {
  display: flex; gap: 14px; align-items: center; text-align: left; border: 2px solid transparent;
  background: var(--surface); border-radius: 16px; padding: 12px; box-shadow: var(--shadow);
}
.layout-opt.sel { border-color: var(--accent); }
.lo-t b { display: block; font-size: 16px; }
.lo-t span { font-size: 13px; color: var(--muted); }
.lp { width: 74px; height: 92px; flex: none; border-radius: 10px; background: var(--surface-2); padding: 7px; display: flex; flex-direction: column; gap: 5px; }
.lp-box { background: var(--line); border-radius: 4px; flex: 1; }
.lp-box.short { flex: .6; }
.lp-line { height: 6px; width: 60%; border-radius: 3px; background: var(--muted); opacity: .5; }
.lp-tabs { display: flex; gap: 3px; }
.lp-tabs i { height: 8px; flex: 1; border-radius: 4px; background: var(--line); }
.lp-tabs i.sel { background: var(--accent); }
.lp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; flex: 1; }
.layout-opt.sel .lp-box { background: color-mix(in srgb, var(--accent) 35%, var(--line)); }

/* ---------- sensores ---------- */
.sensor .name { font-size: 14px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.sensor .name svg { width: 16px; height: 16px; flex: none; }
.sensor .temp { font-size: 40px; font-weight: 600; letter-spacing: -.03em; line-height: 1.1; margin-top: 6px; font-variant-numeric: tabular-nums; }
.sensor .temp small { font-size: 20px; font-weight: 500; color: var(--muted); }
.sensor .hum { font-size: 17px; margin-top: 2px; font-variant-numeric: tabular-nums; display: flex; gap: 4px; align-items: center; }
.sensor .hum svg { width: 15px; height: 15px; color: var(--cool); }
.sensor .range { font-size: 12px; color: var(--muted); margin-top: 8px; }
.out { color: var(--warn); }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.pill.ok { background: var(--accent-soft); color: var(--accent); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.off { background: var(--danger-soft); color: var(--danger); }

/* ---------- ar-condicionado ---------- */
.ac-head { display: flex; align-items: center; gap: 12px; }
.ac-head .ic { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); flex: none; }
.ac-head .ic.on { background: var(--cool-soft); color: var(--cool); }
.ac-head .ic svg { width: 24px; height: 24px; }
.ac-head .t { flex: 1; min-width: 0; }
.ac-head .t b { display: block; }
.ac-head .t span { font-size: 13px; color: var(--muted); }
.ac-body { margin-top: 16px; }
.ac-body.disabled { opacity: .45; pointer-events: none; }
.stepper { display: flex; align-items: center; justify-content: center; gap: 22px; margin: 6px 0 16px; }
.stepper button {
  width: 52px; height: 52px; border-radius: 50%; border: 0; background: var(--surface-2);
  font-size: 26px; display: grid; place-items: center; color: var(--text);
}
.stepper button:active { transform: scale(.94); }
.stepper .val { font-size: 52px; font-weight: 600; letter-spacing: -.04em; min-width: 110px; text-align: center; font-variant-numeric: tabular-nums; }
.stepper .val small { font-size: 22px; color: var(--muted); font-weight: 500; }
.stepper .val .lbl { display: block; font-size: 12px; color: var(--muted); font-weight: 500; letter-spacing: 0; margin-top: -4px; }

.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button {
  flex: 1; border: 0; background: none; padding: 8px 10px; border-radius: 9px; font-size: 14px;
  white-space: nowrap; color: var(--muted); font-weight: 500;
}
.seg button.sel { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); font-weight: 600; }
.field-label { font-size: 13px; color: var(--muted); margin: 14px 2px 6px; }

/* ---------- switch ---------- */
.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--line); transition: background .2s; }
.switch span::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.2); transition: transform .2s;
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:disabled + span { opacity: .5; }

/* ---------- lista de aparelhos ---------- */
.list { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; min-height: 64px; }
.row + .row { border-top: 1px solid var(--line); }
.row .ic { width: 38px; height: 38px; border-radius: 11px; background: var(--surface-2); color: var(--muted); display: grid; place-items: center; flex: none; }
.row .ic.on { background: var(--accent-soft); color: var(--accent); }
.row .ic svg { width: 21px; height: 21px; }
.row .t { flex: 1; min-width: 0; }
.row .t b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .t span { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.row .actions { display: flex; gap: 4px; }
.row .actions button { border: 0; background: none; color: var(--muted); width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; }
.row .actions button svg { width: 18px; height: 18px; }
.row .actions button:active { background: var(--surface-2); }
.row.disabled .t { opacity: .5; }
.row[data-act] { cursor: pointer; }
.row[data-act] .t b { white-space: normal; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); font-size: 15px; }

.energy-sum { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.energy-sum .card { padding: 12px 14px; min-width: 0; }
.energy-sum .k { font-size: 13px; color: var(--muted); }
.energy-sum .v { font-size: 21px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.energy-sum .v small { font-size: 12px; color: var(--muted); font-weight: 500; }

/* ---------- gráficos ---------- */
.chart-card { padding: 14px 10px 10px 4px; }
.chart-card h3 { margin: 0 0 4px 12px; font-size: 16px; }
.chart { position: relative; touch-action: pan-y; }
.chart svg text { fill: var(--muted); font-size: 11px; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .band { fill: var(--accent); opacity: .08; }
.chart .cursor { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.tip {
  position: absolute; top: 4px; pointer-events: none; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 6px 9px; font-size: 12px; box-shadow: var(--shadow); white-space: nowrap; z-index: 2;
}
.tip b { display: block; font-size: 11px; color: var(--muted); font-weight: 500; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 6px 12px 2px; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.chart-stack { display: grid; gap: 12px; }
.chart-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 4px 6px 12px; }
.chart-title h3 { margin: 0; }
.seg-sm button { padding: 5px 10px; font-size: 13px; }
.chart-note { font-size: 12px; color: var(--muted); margin: 4px 12px 2px; }
.import-btn { margin-top: 16px; }

/* ---------- alertas ---------- */
.alert-row { display: flex; gap: 12px; padding: 12px 16px; align-items: flex-start; }
.alert-row + .alert-row { border-top: 1px solid var(--line); }
.alert-row .dot { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.alert-row .dot svg { width: 16px; height: 16px; }
.alert-row .dot.info { background: var(--surface-2); color: var(--muted); }
.alert-row .dot.warning { background: var(--warn-soft); color: var(--warn); }
.alert-row .dot.critical { background: var(--danger-soft); color: var(--danger); }
.alert-row .m { flex: 1; font-size: 15px; }
.alert-row .m span { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.alert-row.unread .m { font-weight: 600; }

/* ---------- navegação inferior ---------- */
nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: saturate(1.4) blur(16px); -webkit-backdrop-filter: saturate(1.4) blur(16px);
  border-top: 1px solid var(--line);
}
nav.tabs button {
  flex: 1; max-width: 110px; border: 0; background: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; font-weight: 500; padding: 4px 0;
  position: relative;
}
nav.tabs button svg { width: 25px; height: 25px; }
nav.tabs button.sel { color: var(--accent); }
nav.tabs .badge { top: 0; right: calc(50% - 22px); }

/* ---------- folha (modal) ---------- */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 30; display: flex; align-items: flex-end; justify-content: center; animation: fade .2s; }
.sheet {
  background: var(--bg); width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  border-radius: 22px 22px 0 0; padding: 8px 16px calc(20px + env(safe-area-inset-bottom));
  animation: up .25s cubic-bezier(.2,.8,.2,1);
}
@media (min-width: 600px) { .sheet-bg { align-items: center; } .sheet { border-radius: 22px; } }
.sheet .grab { width: 36px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 10px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sheet-head h2 { font-size: 19px; margin: 0; }
.sheet-head button { border: 0; background: none; color: var(--accent); font-weight: 600; font-size: 16px; padding: 6px 0; }
.sheet-head button.cancel { color: var(--muted); font-weight: 500; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

.form-group { background: var(--surface); border-radius: 14px; overflow: hidden; margin-bottom: 14px; box-shadow: var(--shadow); }
.form-row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; min-height: 48px; }
.form-row + .form-row { border-top: 1px solid var(--line); }
.form-row label { flex: 1; font-size: 15px; }
.form-row input[type=text], .form-row input[type=number], .form-row input[type=time], .form-row input[type=date], .form-row select, .form-row input[type=password] {
  border: 0; background: none; text-align: right; font-size: 15px; color: var(--muted); max-width: 60%; outline: none; padding: 4px 0;
}
.form-row input[type=text], .form-row input[type=password] { flex: 1; text-align: left; max-width: none; color: var(--text); }
.form-row select { appearance: none; -webkit-appearance: none; cursor: pointer; color: var(--accent); }
.form-row .unit { color: var(--muted); font-size: 14px; margin-left: -6px; }
.form-hint { font-size: 13px; color: var(--muted); margin: -6px 6px 14px; }
.form-group-title { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 4px 6px 6px; }
.days { display: flex; gap: 6px; padding: 10px 14px; }
.days button { flex: 1; aspect-ratio: 1; max-width: 44px; border-radius: 50%; border: 0; background: var(--surface-2); font-size: 12px; font-weight: 600; color: var(--muted); }
.days button.sel { background: var(--accent); color: var(--accent-text); }
.btn {
  display: block; width: 100%; border: 0; border-radius: 14px; padding: 14px; font-weight: 600; font-size: 16px;
  background: var(--accent); color: var(--accent-text);
}
.btn.danger { background: var(--danger-soft); color: var(--danger); margin-top: 10px; }

/* ---------- login / toast ---------- */
.login { max-width: 360px; margin: 18vh auto 0; padding: 0 16px; text-align: center; }
.login .logo { width: 76px; height: 76px; margin: 0 auto 14px; border-radius: 20px; }
.login h1 { margin: 0 0 18px; }
.login .form-group { text-align: left; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(90px + env(safe-area-inset-bottom)); z-index: 40;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px;
  max-width: calc(100% - 32px); box-shadow: 0 6px 24px rgba(0,0,0,.2); animation: up .2s;
}
.offline-banner { background: var(--danger-soft); color: var(--danger); text-align: center; font-size: 14px; padding: 8px; border-radius: 12px; margin-top: 8px; }
.ios-tip { background: var(--accent-soft); color: var(--text); border-radius: 14px; padding: 12px 14px; font-size: 14px; margin-top: 12px; display: flex; gap: 10px; align-items: flex-start; }
.ios-tip button { border: 0; background: none; color: var(--muted); font-size: 18px; padding: 0 2px; line-height: 1; }

/* ---------- versão enxuta: só o essencial de cada aparelho ---------- */
.pill.cool { background: var(--cool-soft); color: var(--cool); }
.pill.phase-none { background: var(--surface-2); color: var(--muted); }
.muted { color: var(--muted); }
.sensor-row { display: flex; gap: 12px; align-items: baseline; margin-top: 4px; font-size: 16px; font-variant-numeric: tabular-nums; flex-wrap: wrap; }
.sensor-row span { display: inline-flex; align-items: center; gap: 3px; }
.sensor-row svg { width: 15px; height: 15px; color: var(--cool); }
.sensor-row .vpd-ok, .sensor-row .vpd-low, .sensor-row .vpd-high { font-weight: 500; }

/* ar-condicionado: temperatura do cômodo x alvo */
.ac-temps { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.ac-temps.disabled { opacity: .5; }
.ac-now, .ac-set { background: var(--surface-2); border-radius: 14px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.ac-now span, .ac-set span { font-size: 12.5px; color: var(--muted); }
.ac-now b { font-size: 30px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.ac-now b small, .stepper-sm b small { font-size: 15px; color: var(--muted); font-weight: 500; }
.stepper-sm { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.stepper-sm b { font-size: 30px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stepper-sm button { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--surface); font-size: 20px; color: var(--text); flex: none; }
.stepper-sm button:disabled { opacity: .4; }
.more-toggle { border: 0; background: none; color: var(--muted); font-size: 14px; width: 100%; padding: 12px 0 0; }
.climate-energy { display: flex; gap: 6px; align-items: flex-start; font-size: 12.5px; color: var(--muted); margin-top: 8px; padding-top: 8px; border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent); }
.climate-energy svg { width: 14px; height: 14px; flex: none; margin-top: 1px; color: var(--warn); }
.climate-energy b { color: var(--text); }
.prio-seg { margin-top: 10px; background: var(--surface); }
.prio-seg button.sel { background: var(--accent); color: var(--accent-text); }

/* tomadas: timer em uma linha */
.timer-sum { display: flex !important; align-items: center; gap: 4px; font-size: 12.5px !important; color: var(--accent) !important; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timer-sum.muted { color: var(--muted) !important; }
.timer-sum svg { width: 13px; height: 13px; flex: none; }
.chev { color: var(--muted); font-size: 22px; padding: 0 4px; }
.timer-types { display: grid; gap: 10px; }
.type-card { display: grid; grid-template-columns: 34px 1fr; grid-template-rows: auto auto; column-gap: 10px; text-align: left; border: 0; background: var(--surface); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); }
.type-card svg { grid-row: span 2; width: 28px; height: 28px; color: var(--accent); align-self: center; }
.type-card b { font-size: 15px; }
.type-card span { font-size: 13px; color: var(--muted); }
.chip.removable { border: 0; cursor: pointer; }
.form-row.dur input[type=number] { max-width: 56px; text-align: right; color: var(--text); }
.form-row.dur label { flex: 1; }

/* guia da fase (faixas automáticas) */
.phase-guide { display: grid; gap: 10px; margin-bottom: 10px; }
.phase-row { background: var(--surface); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); }
.phase-title { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.phase-title small { color: var(--muted); font-size: 12px; }
.phase-vals { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; font-size: 13.5px; color: var(--muted); }
.phase-vals b { color: var(--text); }
.tips { margin: 8px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--muted); }
.tips li + li { margin-top: 3px; }
.sources { font-size: 11px; color: var(--muted); margin: 0 4px; }

/* ---------- painel mínimo ---------- */
.env-head .pill { margin-top: 6px; display: inline-block; }
.clim { padding: 14px 16px; cursor: pointer; }
.clim-row + .clim-row { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; }
.clim-name { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.clim-vals { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; }
.clim-vals div { display: flex; flex-direction: column; }
.clim-vals b { font-size: 30px; font-weight: 600; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.clim-vals b.warn { color: var(--warn); }
.clim-vals span { font-size: 12px; color: var(--muted); }
.clim-status { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 14.5px; font-weight: 500; }
.clim-status i { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--accent); }
.clim-status.warn i { background: var(--warn); }
.clim-status.bad i { background: var(--danger); }
.clim-status.bad { color: var(--danger); }
.ov-card .clim-status { margin-top: 2px; padding-top: 8px; font-size: 13.5px; }
.ac-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer; }
.ac-row .ic { width: 38px; height: 38px; border-radius: 11px; background: var(--surface-2); color: var(--muted); display: grid; place-items: center; flex: none; }
.ac-row .ic.on { background: var(--cool-soft); color: var(--cool); }
.ac-row .ic svg { width: 21px; height: 21px; }
.ac-row .t { flex: 1; min-width: 0; }
.ac-row .t b { display: block; }
.ac-row .t span { font-size: 13px; color: var(--muted); }
.tmr { display: inline-flex; vertical-align: -2px; color: var(--accent); }
.tmr svg { width: 14px; height: 14px; }
.row.manual .lvl { margin-top: 6px; max-width: 220px; }
.energy-line { display: flex; align-items: center; gap: 8px; width: 100%; margin-top: 18px; border: 0; background: none; color: var(--muted); font-size: 14px; padding: 6px 4px; text-align: left; }
.energy-line svg { width: 16px; height: 16px; color: var(--warn); flex: none; }
.energy-line b { color: var(--text); }
.add-manual { margin-bottom: 10px; }
small.inline { display: inline !important; font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 0 4px; margin-left: 4px; }
.danger-link { color: var(--danger) !important; font-weight: 500; }
.ov-vals { font-size: 15px; font-variant-numeric: tabular-nums; }
.ov-vals small { display: block; font-size: 12px; color: var(--muted); }
.ov-vals b { font-weight: 600; }
.ac .ac-head { margin-top: 2px; }
#ac-sheet .card { box-shadow: none; padding: 4px 0 0; background: none; }
.ac-row .t span { display: block; }
.ac-row .t span b { display: inline; color: var(--text); font-weight: 600; }
.ac-row em.auto { font-style: normal; color: var(--accent); font-weight: 600; }
.climate-learn { font-size: 12px; color: var(--muted); margin-top: 6px; }
.phase-vpd { margin-top: 8px; font-size: 13.5px; }
.phase-vpd small { display: block; color: var(--muted); font-size: 12px; }

/* espaços (tendas) dentro do cômodo */
.space { margin-top: 18px; padding: 12px; border-radius: 20px; background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.space-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 2px 10px; cursor: pointer; }
.space-head h3 { font-size: 17px; margin: 0 0 4px; }
.space .clim { box-shadow: none; }
.space .env-edit { width: 32px; height: 32px; }

/* =========================================================
   Visual de app: VPD em destaque, animações suaves
   ========================================================= */
:root { --ease: cubic-bezier(.22, 1, .36, 1); --spring: cubic-bezier(.34, 1.56, .64, 1); }

/* entrada da tela ao trocar de ambiente */
.page.enter > * { animation: rise .55s var(--ease) both; }
.page.enter > *:nth-child(2) { animation-delay: .04s; }
.page.enter > *:nth-child(3) { animation-delay: .08s; }
.page.enter.from-right .env > *, .page.enter.from-left .env > * { animation: slide-in .5s var(--ease) both; }
.page.enter.from-left .env > * { animation-name: slide-in-l; }
.page.enter .env > *:nth-child(2) { animation-delay: .05s; }
.page.enter .env > *:nth-child(3) { animation-delay: .1s; }
.page.enter .env > *:nth-child(4) { animation-delay: .15s; }
.page.enter .env > *:nth-child(n+5) { animation-delay: .2s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes slide-in { from { opacity: 0; transform: translateX(28px); } }
@keyframes slide-in-l { from { opacity: 0; transform: translateX(-28px); } }

/* abas: troca suave */
.env-tabs button { transition: background .3s var(--ease), color .3s, box-shadow .3s, transform .2s; }
.env-tabs button:active { transform: scale(.97); }

/* rótulo discreto entre blocos */
.sec-label { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 22px 6px 8px; }

/* ---------- cartão de VPD ---------- */
.hero-grid { display: grid; gap: 12px; margin-top: 4px; }
.hero-grid.multi { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.hero {
  position: relative; padding: 14px 14px 12px; cursor: pointer; overflow: hidden;
  transition: transform .25s var(--ease);
  background:
    radial-gradient(120% 80% at 50% 0%, color-mix(in srgb, var(--accent) 8%, transparent), transparent 70%),
    var(--surface);
}
.hero:active { transform: scale(.985); }
.hero.offline { opacity: .6; }
.hero-head { display: flex; align-items: center; gap: 6px; min-height: 20px; }
.hero-head b { font-size: 15px; font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.moon { color: var(--muted); font-size: 15px; }
.hero-gauge { position: relative; max-width: 240px; margin: 2px auto 0; }
.hero-grid.multi .hero-gauge { max-width: 190px; }
.hero-val { position: absolute; left: 0; right: 0; bottom: 0; text-align: center; line-height: 1; }
.hero-val b { display: block; font-size: 44px; font-weight: 650; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.hero-grid.multi .hero-val b { font-size: 34px; }
.hero-val span { font-size: 10.5px; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.hero-word { text-align: center; font-size: 14px; font-weight: 600; margin-top: 6px; }
.hero-word.vpd-none { color: var(--muted); }

.gauge { width: 100%; height: auto; overflow: visible; }
.g-track, .g-band { fill: none; stroke-linecap: round; }
.g-track { stroke: var(--surface-2); stroke-width: 10; }
.g-band { stroke: color-mix(in srgb, var(--accent) 40%, transparent); stroke-width: 10; stroke-linecap: butt; }
.g-needle { transform-origin: 60px 60px; transform-box: view-box; transition: transform 1.1s var(--spring); }
.g-dot { fill: var(--surface); stroke-width: 3.5; stroke: var(--muted); }
.g-halo { fill: var(--muted); opacity: .18; transform-origin: 60px 10px; transform-box: view-box; animation: halo 2.6s ease-in-out infinite; }
.g-ok .g-dot { stroke: var(--accent); } .g-ok .g-halo { fill: var(--accent); }
.g-low .g-dot { stroke: var(--cool); } .g-low .g-halo { fill: var(--cool); }
.g-high .g-dot { stroke: var(--warn); } .g-high .g-halo { fill: var(--warn); }
.g-none .g-halo { animation: none; opacity: 0; }
@keyframes halo { 0%, 100% { transform: scale(.7); opacity: .28; } 50% { transform: scale(1.35); opacity: .06; } }

.hero-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.hero-stats > div { background: var(--surface-2); border-radius: 12px; padding: 8px 10px 9px; min-width: 0; }
.hs-line { display: flex; align-items: baseline; gap: 3px; white-space: nowrap; }
.hero-grid.multi .hero-stats { gap: 6px; }
.hero-grid.multi .hero-stats > div { padding: 7px 8px 8px; }
.hero-grid.multi .hero-stats b { font-size: 17px; }
.hero-grid.multi .hero-stats .hs-k svg { width: 13px; height: 13px; }
/* cartão largo: medidor à esquerda, números à direita */
.hero-grid.multi .hero.wide { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(130px, 1fr) 1.15fr; column-gap: 14px; align-items: center; }
.hero.wide > .hero-head, .hero.wide > .hero-status, .hero.wide > .hero-more { grid-column: 1 / -1; }
.hero.wide .hero-gauge { grid-row: 2 / span 2; width: 100%; }
.hero.wide .hero-word { grid-column: 2; grid-row: 2; text-align: left; margin: 0; align-self: end; }
.hero.wide .hero-stats { grid-column: 2; grid-row: 3; margin-top: 6px; align-self: start; }
.hero-stats .hs-k { color: var(--muted); align-self: center; }
.hero-stats .hs-k svg { width: 15px; height: 15px; }
.hero-stats b { font-size: 20px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.hero-stats small { font-size: 12px; color: var(--muted); }
.rbar { display: block; position: relative; height: 4px; border-radius: 2px; background: color-mix(in srgb, var(--line) 80%, transparent); margin-top: 7px; }
.rb-band { position: absolute; top: 0; bottom: 0; border-radius: 2px; background: color-mix(in srgb, var(--accent) 45%, transparent); }
.rb-dot { position: absolute; top: 50%; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; border-radius: 50%; background: var(--surface); border: 2.5px solid var(--accent); }
.rb-dot.out { border-color: var(--warn); }

.hero-status { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 13.5px; font-weight: 500; line-height: 1.3; }
.hero-status i { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--accent); animation: breathe 2.4s ease-in-out infinite; }
.hero-status.warn i { background: var(--warn); }
.hero-status.bad i { background: var(--danger); }
.hero-status.bad { color: var(--danger); }
@keyframes breathe { 50% { opacity: .35; transform: scale(.8); } }

/* detalhes ao tocar */
.hero-more { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .4s var(--ease); }
.hero-more > div { overflow: hidden; min-height: 0; transition: padding .4s var(--ease); }
.hero.open .hero-more { grid-template-rows: 1fr; }
.hero.open .hero-more > div { padding-top: 10px; }
.hm-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 7px 2px; font-size: 13.5px; border-top: 1px solid var(--line); }
.hm-row span { color: var(--muted); }
.hm-row span small { display: block; font-size: 11px; }
.hm-row b { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.hm-row.bad b { color: var(--danger); }
.hm-btn { margin-top: 8px; padding: 10px; font-size: 14px; box-shadow: none; background: var(--surface-2); }

/* ---------- ar e aparelhos ---------- */
.ac-row { transition: transform .2s var(--ease); }
.ac-row:active, .row[data-act]:active { transform: scale(.985); }
.ac-row .ic.on svg path:last-child { animation: blow 1.8s ease-in-out infinite; }
.ac-row .ic.on.m-fan svg path:last-child { animation-duration: 3.2s; }
@keyframes blow { 50% { transform: translateY(1.5px); opacity: .5; } }
.row .ic, .ac-row .ic { transition: background .3s, color .3s; }
.switch span, .switch span::after { transition-timing-function: var(--spring); transition-duration: .3s; }
.focus-hint { font-size: 12.5px; color: var(--muted); margin: 6px 2px 0; line-height: 1.35; }
.climate .field-label { margin: 12px 2px 6px; }

/* espaços: só os aparelhos (o clima fica no topo) */
.space { margin-top: 22px; padding: 12px; }
.space-empty { font-size: 13px; color: var(--muted); padding: 2px 4px 4px; }

/* ---------- visão geral ---------- */
.ov-card { transition: transform .2s var(--ease); }
.ov-sens { display: flex; align-items: center; gap: 12px; }
.ov-sens + .ov-sens { border-top: 1px solid var(--line); padding-top: 8px; }
.ov-g { position: relative; width: 84px; flex: none; }
.ov-g b { position: absolute; left: 0; right: 0; bottom: -2px; text-align: center; font-size: 17px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.gauge.small .g-track, .gauge.small .g-band { stroke-width: 12; }
.gauge.small .g-halo { display: none; }
.ov-t { min-width: 0; font-variant-numeric: tabular-nums; }
.ov-t small { display: block; font-size: 12px; color: var(--muted); }
.ov-t span { font-size: 15px; }
.ov-t em { display: block; font-style: normal; font-size: 12.5px; font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
