:root {
  --blue: #1660a8;
  --blue-dark: #0c3f73;
  --green: #4faf36;
  --green-light: #8fce5a;
  --bg: #eef3f0;
  --text: #14241e;
  --muted: #6a7a73;
  --card: rgba(255,255,255,0.86);
  --line: rgba(20, 50, 40, 0.08);
  --radius: 20px;
  --shadow: 0 16px 40px rgba(16, 48, 40, 0.08);
  --danger: #d64545;
  --warn: #d08912;
  --sidebar-w: 268px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body.app {
  min-height: 100%;
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background:
    radial-gradient(900px 420px at 0% -10%, rgba(143,206,90,0.16), transparent 50%),
    radial-gradient(700px 380px at 100% 0%, rgba(22,96,168,0.1), transparent 46%),
    var(--bg);
  color: var(--text);
}

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100dvh;
  transition: grid-template-columns 0.22s ease;
}
.shell.pick-mode { grid-template-columns: 1fr; }
.shell.pick-mode .sidebar,
.shell.pick-mode .nav-mask,
.shell.pick-mode .menu-btn { display: none !important; }
.shell:not(.pick-mode) #btnLogoutTop { display: none; }

.nav-mask {
  display: none;
  position: fixed; inset: 0;
  background: rgba(10, 22, 18, 0.42);
  z-index: 30;
}

.sidebar {
  position: sticky; top: 0;
  height: 100dvh;
  margin: 0;
  padding: 20px 14px 16px;
  display: flex; flex-direction: column;
  color: #1e293b;
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.06);
  border-left: 0;
  border-radius: 0 24px 24px 0;
  box-shadow: 4px 0 10px rgba(15, 23, 42, 0.05);
  overflow: hidden auto;
  z-index: 40;
}

.sidebar .logo {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 6px 10px 18px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  border-radius: 12px;
  cursor: default;
}
.sidebar .logo img { width: 44px; height: 44px; object-fit: contain; pointer-events: none; }
.sidebar .logo .logo-name {
  font-size: 15px;
  line-height: 1.35;
  font-weight: 650;
  color: #0f172a;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.nav-btn {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left; border: 0;
  background: transparent; color: #64748b;
  padding: 11px 14px; border-radius: 12px;
  cursor: pointer; font-size: 15px; margin-bottom: 4px;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
}
.nav-btn svg { flex-shrink: 0; width: 20px; height: 20px; }
#navDash svg { color: #1660a8; }
#navWx svg { color: #0284c7; }
#navDev svg { color: #6d5efc; }
#navSw svg { color: #5eb838; }
#navMail svg { color: #db2777; }
#navUsers svg { color: #e2a00a; }
#navSys svg { color: #0f766e; }
#btnLogout svg { color: #d64545; }
.nav-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}
.nav-btn.active {
  background: #eef5fb;
  color: #1660a8;
  font-weight: 600;
  box-shadow: none;
}
.nav-group { margin-bottom: 4px; }
.nav-group .nav-btn { margin-bottom: 0; }
.nav-caret {
  width: 16px !important;
  height: 16px !important;
  margin-left: auto;
  color: #94a3b8;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}
.nav-group.open .nav-caret { transform: rotate(180deg); }
.nav-sub {
  display: none;
  padding: 4px 0 6px 8px;
}
.nav-group.open .nav-sub { display: flex; flex-direction: column; gap: 2px; }
.nav-sub-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: #64748b;
  padding: 11px 14px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 15px;
  white-space: nowrap;
}
.nav-sub-btn svg { flex-shrink: 0; width: 20px; height: 20px; }
#navRainIrr svg { color: #0284c7; }
#navValvePump svg { color: #f97316; }
#navLeakValve svg { color: #0f766e; }
#navFlowDelay svg { color: #2563eb; }
#navClock svg { color: #7c3aed; }
.nav-sub-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}
.nav-sub-btn.active {
  background: #eef5fb;
  color: #1660a8;
  font-weight: 600;
}
.sidebar .spacer { flex: 1; }

.sidebar-toggle {
  display: none;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-top: 8px;
  padding: 10px 14px;
  border: 0;
  border-radius: 12px;
  background: #f8fafc;
  color: #64748b;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.2s, color 0.2s;
}
.sidebar-toggle svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  transition: transform 0.22s ease;
}
.sidebar-toggle:hover {
  background: #eef2f7;
  color: #0f172a;
}

@media (min-width: 861px) {
  .sidebar-toggle { display: flex; }
  .sidebar .logo { cursor: pointer; }
  .sidebar .logo:hover { background: #f8fafc; }
  .shell.sidebar-collapsed { --sidebar-w: 76px; }
  .shell.sidebar-collapsed .sidebar { padding: 18px 8px 14px; }
  .shell.sidebar-collapsed .sidebar .logo {
    justify-content: center;
    padding: 6px 0 16px;
  }
  .shell.sidebar-collapsed .sidebar .logo .logo-name,
  .shell.sidebar-collapsed .nav-btn span,
  .shell.sidebar-collapsed .nav-caret,
  .shell.sidebar-collapsed .nav-sub,
  .shell.sidebar-collapsed .sidebar-toggle span {
    display: none;
  }
  .shell.sidebar-collapsed .nav-btn,
  .shell.sidebar-collapsed .sidebar-toggle {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
  }
  .shell.sidebar-collapsed .sidebar-toggle svg { transform: rotate(180deg); }
}

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  min-height: 72px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 12px 24px;
  background: rgba(255,255,255,0.72);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}
.menu-btn {
  display: none; border: 0; background: #eef4f0;
  width: 40px; height: 40px; border-radius: 12px; cursor: pointer;
}
.top-left { min-width: 0; }
.page-title { font-size: 18px; font-weight: 700; }
.who { color: var(--muted); font-size: 13px; margin-top: 2px; }
.who b { color: var(--blue); }
.top-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.pick-toolbar {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 18px; flex-wrap: wrap;
}
.pick-hint { color: var(--muted); font-size: 14px; line-height: 1.55; max-width: 52em; }
.pick-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.pick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.pick-card {
  text-align: left; border: 1px solid rgba(255,255,255,0.7);
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px 18px 16px;
  cursor: pointer; display: flex; flex-direction: column; gap: 10px;
}
.pick-card:hover { box-shadow: 0 18px 36px rgba(16, 48, 40, 0.12); transform: translateY(-1px); }
.pick-card .sw-ch { font-size: 12px; letter-spacing: 0.06em; color: var(--muted); }
.pick-card-name { font-size: 22px; font-weight: 750; color: var(--blue); }
.pick-card-enter { font-size: 13px; color: var(--muted); }

.btn, button.btn {
  border: 0; border-radius: 12px; padding: 10px 14px;
  font-size: 13px; cursor: pointer; font-weight: 600;
  transition: transform 0.15s, box-shadow 0.2s, opacity 0.2s;
}
.btn:active { transform: scale(0.98); }
.btn-ghost { background: #eef4f0; color: var(--text); }
.btn-primary {
  background: linear-gradient(90deg, var(--blue), var(--green));
  color: #fff; box-shadow: 0 8px 18px rgba(22,96,168,0.2);
}
.btn-danger { background: var(--danger); color: #fff; }
.btn-warn { background: var(--warn); color: #fff; }

.content { padding: 22px 24px 40px; }
.page { display: none; animation: fade .25s ease; }
.page.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.hero {
  display: grid;
  grid-template-columns: 1.4fr 0.9fr;
  gap: 16px;
  margin-bottom: 16px;
}
.hero-weather, .hero-rec, .card {
  background: var(--card);
  border: 1px solid rgba(255,255,255,0.7);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.hero-weather {
  padding: 22px 24px;
  background:
    linear-gradient(135deg, rgba(22,96,168,0.08), rgba(94,184,56,0.08)),
    var(--card);
}
.eyebrow {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; letter-spacing: 0.08em; color: var(--muted); text-transform: uppercase;
}
.live-dot {
  width: 8px; height: 8px; border-radius: 50%; background: #3db83a;
  box-shadow: 0 0 0 4px rgba(61,184,58,0.16);
}
.live-dot.off { background: #9aa7a1; box-shadow: none; }
.hero-weather h2 { margin: 10px 0 16px; font-size: clamp(28px, 4vw, 40px); color: var(--blue); }
.hero-metrics {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px;
}
.hero-metrics div {
  background: rgba(255,255,255,0.7);
  border-radius: 14px; padding: 10px 12px;
}
.hero-metrics span { display: block; color: var(--muted); font-size: 12px; }
.hero-metrics b { display: block; margin-top: 4px; font-size: 16px; }
.hero-rec { padding: 22px 22px 18px; display: flex; flex-direction: column; }
.hero-rec p {
  flex: 1; font-size: 18px; line-height: 1.5; font-weight: 650; margin: 10px 0 16px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.page > .card + .card { margin-top: 16px; }
.card { padding: 18px 18px 16px; min-width: 0; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.card h3, .card-head h3 {
  font-size: 13px; color: var(--muted); letter-spacing: 0.04em; font-weight: 650;
}
.icon-pill {
  width: 36px; height: 36px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(180deg, #e8f6df, #e4eef8);
  color: var(--blue);
}
.soil-refresh {
  width: 36px; height: 36px; border-radius: 12px; border: 0; padding: 0;
  display: grid; place-items: center; cursor: pointer;
  background: linear-gradient(180deg, #e8f6df, #e4eef8);
  color: var(--blue);
}
.soil-refresh:hover { filter: brightness(0.97); }
.soil-refresh:disabled { opacity: 0.65; cursor: wait; }
.soil-refresh.busy svg { animation: sw-spin 0.7s linear infinite; }
.card-tools { display: flex; align-items: center; gap: 8px; }
.mon-link { cursor: pointer; transition: border-color .15s ease, box-shadow .15s ease; }
.mon-link:hover {
  border-color: rgba(22, 96, 168, 0.28);
  box-shadow: 0 8px 18px rgba(22, 96, 168, 0.08);
}
.soil-sensors { display: flex; flex-direction: column; gap: 14px; }
.soil-sensor {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
}
.soil-sensor-mark {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 48px;
}
.soil-sensor-icon {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(180deg, #e8f6df, #e4eef8);
  color: var(--green, #2f8f4e);
}
.soil-sensor-icon-2 { color: var(--blue); }
.soil-sensor-mark em {
  font-style: normal;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.soil-val {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--blue);
  white-space: nowrap;
}
.soil-val svg { flex-shrink: 0; opacity: 0.8; }
.metric { font-size: 30px; font-weight: 750; color: var(--blue); letter-spacing: -0.03em; }
.metric small { font-size: 14px; color: var(--muted); font-weight: 500; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; font-size: 14px; }
.kv span { color: var(--muted); }
.kv div { overflow-wrap: anywhere; }

.gauge-wrap { display: flex; align-items: center; gap: 16px; }
.gauge {
  --p: 0;
  width: 86px; height: 86px; border-radius: 50%; flex-shrink: 0;
  background: conic-gradient(var(--green) calc(var(--p) * 1%), #e6eee8 0);
  display: grid; place-items: center;
}
.gauge::after {
  content: "";
  width: 64px; height: 64px; border-radius: 50%; background: #fff;
}
.gauge-val {
  position: absolute; font-size: 16px; font-weight: 750; color: var(--blue);
}
.gauge-box { position: relative; display: grid; place-items: center; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700;
}
.badge.on { background: #e5f7d8; color: #2d7a14; }
.badge.off { background: #eef1ef; color: #6b7a74; }

.table-wrap { overflow: auto; }
.op-fb { word-break: break-all; font-size: 12px; color: var(--muted); }
.pager {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  margin-top: 12px;
}
.leak-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px 16px;
  margin: 16px 0 8px;
}
.leak-check {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; user-select: none;
  font-size: 15px; font-weight: 650; color: var(--text);
  padding: 10px 8px; border-radius: 10px;
}
.leak-check:hover { background: #f4f8f5; }
.leak-check input {
  width: 18px; height: 18px; margin: 0;
  accent-color: var(--blue); cursor: pointer; flex: 0 0 auto;
}
.leak-now { font-size: 13px; color: var(--muted); font-weight: 650; }
.help-doc { line-height: 1.75; }
.help-doc h1 { font-size: 22px; line-height: 1.4; margin-bottom: 12px; }
.help-doc h2 { font-size: 18px; margin: 22px 0 8px; }
.help-doc h3 { font-size: 15px; margin: 16px 0 6px; }
.help-doc p { margin: 8px 0; }
.help-doc ul, .help-doc ol { margin: 8px 0 8px 1.4em; }
.help-doc li + li { margin-top: 4px; }
.help-doc table { width: 100%; border-collapse: collapse; margin: 10px 0 14px; font-size: 14px; }
.help-doc th, .help-doc td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.help-doc th { background: #f4f8f5; font-weight: 650; }
.help-doc blockquote {
  margin: 12px 0; padding: 10px 12px;
  border-left: 4px solid #f97316; background: #fff7ed;
  border-radius: 0 10px 10px 0; font-weight: 650;
}
#navHelp svg { color: #b45309; }
.rain-irr-caution { margin-bottom: 16px; }
.rain-caution-line {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.rain-caution-line .hint {
  margin-top: 0;
  font-weight: 700;
  flex: 1;
}
.rain-warn-ico {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  margin-top: 1px;
  display: block;
  overflow: visible;
}
.rain-forecast-bar { margin-bottom: 16px; }
.rain-irr-cards { margin-top: 0; margin-bottom: 8px; }
.rain-irr-cards .rain-mm + .rain-mm { margin-top: 10px; }
.rain-mm .btn { align-self: flex-end; white-space: nowrap; }
.flow-delay-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  margin-bottom: 16px;
}
.flow-delay-head .hint { flex: 1; }
.flow-delay-head .btn { flex: 0 0 auto; }
.clock-now {
  font-size: 15px; font-weight: 650; margin: 0;
}
.clock-cal-card {
  display: block;
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
}
.clock-cal-btn {
  min-width: 200px; min-height: 56px;
  padding: 16px 32px; font-size: 20px;
}
.rain-en { padding: 0; font-size: 13px; }
.rain-mm {
  display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap;
}
.rain-mm .field { flex: 1 1 90px; min-width: 90px; }
.rain-mm-unit, .rain-mm-sep {
  font-size: 14px; font-weight: 700; color: var(--muted); padding-bottom: 10px;
}
.rain-fc { margin: 12px 0 0; }
.leak-now.warn { color: #c2410c; }
.pager-info { font-size: 13px; color: var(--muted); }
.pager .btn:disabled { opacity: 0.45; cursor: not-allowed; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid #edf2ee; }
th { color: var(--muted); font-weight: 650; white-space: nowrap; }
td { vertical-align: middle; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
label.field { display: block; font-size: 13px; color: var(--muted); }
label.field input, label.field select {
  width: 100%; margin-top: 6px; border: 1.5px solid #dfe8e3;
  border-radius: 12px; padding: 11px 12px; font: inherit; background: #fafcfb;
}
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.hint { color: var(--muted); font-size: 13px; margin-top: 10px; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }

.mon-stack { display: flex; flex-direction: column; gap: 16px; }
.mon-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: stretch;
}
.mon-row .mon-card {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.mon-row .mon-inds,
.mon-row .mon-grid { flex: 1; }
.mon-card { padding: 20px 22px 16px; }
.mon-card .card-head h3 {
  font-size: 15px;
  color: var(--text);
  letter-spacing: 0.02em;
}
.mon-grid {
  display: grid;
  gap: 12px;
}
.mon-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.mon-cell {
  background: rgba(255,255,255,0.72);
  border: 1px solid rgba(20, 50, 40, 0.05);
  border-radius: 16px;
  padding: 14px 12px;
  text-align: center;
  min-width: 0;
}
.mon-ico {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin: 0 auto 6px;
  border-radius: 10px;
}
.mon-ico svg { width: 18px; height: 18px; }
.ico-temp { color: #f97316; background: rgba(249, 115, 22, 0.14); }
.ico-hum { color: #0ea5e9; background: rgba(14, 165, 233, 0.14); }
.ico-co2 { color: #8b5cf6; background: rgba(139, 92, 246, 0.14); }
.ico-lux { color: #eab308; background: rgba(234, 179, 8, 0.18); }
.ico-rain { color: #2563eb; background: rgba(37, 99, 235, 0.14); }
.mon-cell-ind { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 72px; }
.mon-cell-ind .mon-ind { min-width: 0; gap: 6px; }
.mon-cell b {
  display: block;
  font-size: clamp(15px, 1.8vw, 22px);
  font-weight: 750;
  color: var(--blue);
  letter-spacing: -0.03em;
  word-break: break-word;
}
.mon-cell.soil-cell b {
  display: inline;
  font-size: clamp(13px, 1.4vw, 16px);
  font-weight: 700;
}
.mon-cell.soil-cell span {
  margin-top: 0;
  margin-bottom: 6px;
}
.soil-unit {
  font-size: 10px;
  font-weight: 650;
  color: var(--muted);
  letter-spacing: 0;
}
.mon-cell span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}
.mon-inds {
  display: flex;
  flex-wrap: wrap;
  gap: 18px 28px;
  justify-content: flex-start;
  padding: 8px 8px 4px;
}
.mon-ind {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 72px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}
.mon-ind i {
  width: 16px; height: 16px; border-radius: 50%;
  border: 3px solid #9aa7a1;
  background: transparent;
  box-shadow: none;
}
.mon-ind.on i {
  border-color: #3db83a;
  background: #3db83a;
  box-shadow: 0 0 0 4px rgba(61,184,58,0.16);
}
.mon-ind.on { color: #2d7a14; }
.mon-foot {
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}
.mon-foot b { color: var(--text); font-weight: 650; }

.wx-place {
  padding: 4px 4px 2px;
}
.wx-place-city {
  font-size: clamp(32px, 4.2vw, 46px);
  font-weight: 750;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--text);
}
.wx-place-coord {
  margin-top: 8px;
  font-size: clamp(16px, 2vw, 20px);
  font-weight: 650;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.wx-hero {
  background:
    linear-gradient(135deg, rgba(22,96,168,0.08), rgba(94,184,56,0.08)),
    var(--card);
}
.wx-hero-body h2 {
  margin: 8px 0 14px;
  font-size: clamp(26px, 3.4vw, 38px);
  color: var(--blue);
  letter-spacing: -0.03em;
}
.wx-hero-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.wx-hero-metrics div {
  background: rgba(255,255,255,0.72);
  border-radius: 14px;
  padding: 10px 12px;
}
.wx-hero-metrics span { display: block; color: var(--muted); font-size: 12px; font-weight: 650; }
.wx-hero-metrics b { display: block; margin-top: 4px; font-size: 16px; }
.wx-updated, .wx-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}
.wx-meta { margin: -4px 0 12px; }
.wx-head-tools { gap: 12px; }
.wx-search {
  width: min(220px, 46vw);
  border: 1.5px solid #dfe8e3;
  border-radius: 12px;
  padding: 8px 12px;
  font: inherit;
  background: #fafcfb;
}
.wx-period-grid, .wx-hour-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.wx-now-val {
  font-size: 28px;
  font-weight: 700;
  color: var(--blue);
  padding: 8px 4px 4px;
}
.wx-source {
  color: var(--muted);
  font-size: 12px;
  padding: 4px 2px 8px;
}
.wx-source a { color: var(--blue); }
.wx-period, .wx-day, .wx-area, .wx-st {
  background: rgba(255,255,255,0.72);
  border: 1px solid rgba(20, 50, 40, 0.05);
  border-radius: 16px;
  padding: 14px;
  min-width: 0;
}
.wx-period h4, .wx-day h4, .wx-area strong {
  display: block;
  font-size: 13px;
  margin-bottom: 8px;
}
.wx-period .wx-regs {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}
.wx-period .wx-regs span { color: var(--muted); }
.wx-period .wx-regs b { font-weight: 650; }
.wx-day-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 12px;
}
.wx-day .wx-day-name { color: var(--muted); font-size: 12px; font-weight: 650; letter-spacing: 0.04em; }
.wx-day h4 { font-size: 18px; margin: 6px 0 10px; color: var(--blue); }
.wx-day p { color: var(--muted); font-size: 13px; line-height: 1.5; }
.wx-area-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 10px;
}
.wx-area.focus {
  border-color: rgba(22, 96, 168, 0.28);
  box-shadow: 0 0 0 3px rgba(22, 96, 168, 0.08);
}
.wx-area em { display: block; color: var(--muted); font-style: normal; font-size: 12px; margin-bottom: 6px; }
.wx-badge {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 650;
  background: #eef3f0;
  color: var(--text);
}
.wx-badge.storm { background: #e8eefb; color: #1d4ed8; }
.wx-badge.rain { background: #e7f2fb; color: #1660a8; }
.wx-badge.cloud { background: #eef1f4; color: #475569; }
.wx-badge.fair { background: #eef7e6; color: #3b7a14; }
.wx-badge.haze { background: #f6efe4; color: #9a6b12; }
.wx-station-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 420px;
  overflow: auto;
}
.wx-st {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 14px;
}
.wx-st span { color: var(--text); font-size: 13px; }
.wx-st small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
.wx-st b { color: var(--blue); font-size: 16px; white-space: nowrap; }
.wx-st.wet { background: rgba(22, 96, 168, 0.08); }
.wx-st.wet b { color: #0c3f73; }
.wx-empty { color: var(--muted); padding: 18px 8px; text-align: center; }

.sw-anchor-nav {
  position: sticky;
  top: 72px;
  z-index: 18;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 16px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}
.sw-anchor-nav a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 12px;
  color: #64748b;
  text-decoration: none;
  font-size: 14px;
  font-weight: 650;
}
.sw-anchor-nav a svg { flex-shrink: 0; }
.sw-anchor-nav[hidden] { display: none; }
.sw-anchor-nav a[data-irr="rainirr"] svg { color: #0284c7; }
.sw-anchor-nav a[data-irr="valvepump"] svg { color: #f97316; }
.sw-anchor-nav a[data-irr="leakvalve"] svg { color: #0f766e; }
.sw-anchor-nav a[data-irr="flowdelay"] svg { color: #2563eb; }
.sw-anchor-nav a[data-irr="clock"] svg { color: #7c3aed; }
.sw-anchor-nav a:hover { background: #f1f5f9; color: #0f172a; }
.sw-anchor-nav a.active {
  background: #eef5fb;
  color: #1660a8;
}
.sw-board-tools {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}
.sw-tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  color: var(--text);
  border: 1px solid #d5e2da;
  box-shadow: 0 6px 14px rgba(16, 48, 40, 0.08);
}
.sw-tool-btn:hover { background: #f4faf6; border-color: #b7d0c4; }
.sw-tool-btn:disabled { opacity: 0.65; cursor: wait; }
.sw-tool-btn svg { flex-shrink: 0; }
#btnSwLiveRefresh svg { color: #1660a8; }
#btnSwManualRefresh svg { color: #16a34a; }
.sw-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.sw-pump .sw-card-name { margin-bottom: 0; }
.sw-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 12px 12px 10px;
}
.sw-card.live {
  background:
    linear-gradient(135deg, rgba(22,96,168,0.08), rgba(94,184,56,0.1)),
    var(--card);
}
.sw-card .card-head { margin-bottom: 6px; }
.sw-ch {
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
}
.sw-card-name {
  font-size: 18px;
  font-weight: 750;
  color: var(--text);
  margin: 0 0 8px;
  line-height: 1.25;
}
.sw-valve-ico {
  width: 24px;
  height: 24px;
  display: block;
}
.icon-pill.sw-valve {
  width: 34px;
  height: 34px;
  color: #ff3b1f;
  background: linear-gradient(180deg, #ffe8d8, #ffc4a8);
  box-shadow: 0 4px 10px rgba(255, 59, 31, 0.18);
}
.icon-pill.sw-valve.on {
  color: #00c853;
  background: linear-gradient(180deg, #d8ffde, #8af0a8);
  box-shadow: 0 6px 16px rgba(0, 200, 83, 0.32);
}
.sw-card .badge { align-self: flex-start; }
.sw-card .btn { padding: 7px 10px; }
.sw-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
.sw-manual {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}
.sw-toggle {
  width: 46px; height: 26px; border: 0; padding: 0;
  border-radius: 999px; background: #d5ddd8; cursor: pointer;
  position: relative; flex-shrink: 0;
  transition: background 0.2s, box-shadow 0.2s;
}
.sw-toggle i {
  position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(16, 48, 40, 0.18);
  transition: transform 0.2s;
}
.sw-toggle.on {
  background: linear-gradient(90deg, var(--blue), var(--green));
  box-shadow: 0 6px 14px rgba(22,96,168,0.22);
}
.sw-toggle.on i { transform: translateX(20px); }

.sw-set { display: flex; flex-direction: column; gap: 16px; }
#flowCondCard[hidden] { display: none; }
.sw-hero {
  padding: 20px 22px 18px;
  background:
    linear-gradient(135deg, rgba(22,96,168,0.08), rgba(94,184,56,0.08)),
    var(--card);
}
.sw-hero .card-head { margin-bottom: 18px; }
.sw-hero .btn { display: inline-flex; align-items: center; gap: 6px; }
.sw-hero-body { display: flex; align-items: center; gap: 18px; }
.sw-bulb {
  width: 64px; height: 64px; border-radius: 18px;
  color: var(--blue);
}
.sw-bulb svg { width: 28px; height: 28px; }
.sw-set-name {
  border: 0; background: transparent;
  color: var(--blue); font-size: clamp(24px, 3vw, 34px);
  font-weight: 750; cursor: pointer; padding: 0;
  display: inline-flex; align-items: center; gap: 8px;
  letter-spacing: -0.03em;
}
.sw-set-name svg { width: 16px; height: 16px; color: var(--muted); }
.sw-hero-meta { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.sw-set-grid {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 16px;
}
#moistLinkCard[hidden] { display: none; }
.sw-set-grid.week-only { grid-template-columns: 1fr; }
.sw-week-all {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--muted); font-size: 13px; font-weight: 650;
}
.sw-moist-line {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}
.sw-moist-line > span { color: var(--muted); font-size: 13px; font-weight: 650; }
.sw-moist-actions { display: inline-flex; align-items: center; gap: 8px; }
#btnMoistRefresh[hidden], #btnMoistEnRefresh[hidden] { display: none; }
.sw-link {
  border: 0; background: #f4f8f5; color: var(--blue);
  font-weight: 700; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 12px; padding: 10px 14px; font-size: 16px;
}
.sw-link svg { width: 14px; height: 14px; color: var(--muted); }
.sw-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}
.sw-day {
  border: 1.5px solid #e3ebe6; background: #f4f8f5; color: #8a9690;
  border-radius: 12px; min-height: 44px; cursor: pointer;
  font-weight: 700; font-size: 14px;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.sw-day.on {
  background: linear-gradient(180deg, #1a78d0, #0f5ea8);
  color: #fff;
  border-color: #0c4d8c;
  box-shadow: 0 8px 16px rgba(12, 63, 115, 0.28);
}
.sw-slots {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.sw-slot {
  background: rgba(255,255,255,0.72);
  border: 1px solid rgba(20, 50, 40, 0.06);
  border-radius: 16px; padding: 14px 14px 12px;
  display: flex; flex-direction: column; gap: 10px;
}
.sw-slot-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.sw-slot .sw-link { width: 100%; justify-content: space-between; font-size: 14px; }
.sw-slot.loading { opacity: 0.72; }
.sw-slot.fail { box-shadow: inset 0 0 0 1px rgba(196, 80, 60, 0.22); }
.sw-slot-spin {
  display: inline-block; width: 12px; height: 12px; margin-left: 6px;
  border: 2px solid rgba(22, 96, 168, 0.2); border-top-color: var(--blue);
  border-radius: 50%; vertical-align: -1px;
  animation: sw-spin 0.7s linear infinite;
}
@keyframes sw-spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; right: 20px; bottom: 20px;
  background: #123a2a; color: #fff; padding: 11px 14px;
  border-radius: 12px; display: none; z-index: 50;
}
.modal-mask {
  position: fixed; inset: 0; background: rgba(16,28,24,0.4);
  display: none; align-items: center; justify-content: center;
  z-index: 60; padding: 16px;
}
.modal-mask.show { display: flex; }
.modal {
  width: min(520px, 100%);
  background: #fff; border-radius: 18px; padding: 22px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.18);
}
.modal h3 { margin-bottom: 16px; }
.slot-time-block { margin-bottom: 12px; }
.slot-time-block:last-child { margin-bottom: 0; }
.slot-time-lab { font-size: 13px; color: var(--muted); margin-bottom: 8px; font-weight: 650; }
.slot-hms {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px;
}
.slot-hms label.field input { text-align: center; }

@media (max-width: 1180px) {
  .hero { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr 1fr; }
  .flow-delay-cards { grid-template-columns: 1fr 1fr; }
  .sw-board { grid-template-columns: 1fr 1fr; }
  .sw-set-grid { grid-template-columns: 1fr; }
  .sw-slots { grid-template-columns: 1fr 1fr; }
  .wx-day-grid { grid-template-columns: 1fr 1fr; }
  .wx-period-grid, .wx-hour-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0;
    height: 100dvh;
    width: min(84vw, 300px);
    transform: translateX(-105%);
    transition: transform 0.24s ease;
    border-radius: 0 24px 24px 0;
    box-shadow: 4px 0 12px rgba(15, 23, 42, 0.1);
  }
  .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open .nav-mask { display: block; }
  .menu-btn { display: grid; place-items: center; }
  .content { padding: 16px 14px 28px; }
  .topbar { padding: 10px 14px; }
  .cards, .flow-delay-cards { grid-template-columns: 1fr; }
  .hero-metrics { grid-template-columns: 1fr 1fr; }
  .mon-row { grid-template-columns: 1fr; }
  .wx-day-grid { grid-template-columns: 1fr; }
  .wx-period-grid, .wx-hour-grid { grid-template-columns: 1fr 1fr; }
  .sw-board, .sw-slots { grid-template-columns: 1fr; }
  .sw-anchor-nav { top: 64px; }
  .leak-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rain-irr-cards { grid-template-columns: 1fr; }
  .sw-days { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  table.responsive thead { display: none; }
  table.responsive tr {
    display: block;
    background: #f8fbf8;
    border: 1px solid #e7eee9;
    border-radius: 14px;
    margin-bottom: 10px;
    padding: 6px 4px;
  }
  table.responsive td {
    display: flex; justify-content: space-between; gap: 12px;
    border: 0; padding: 8px 10px;
  }
  table.responsive td::before {
    content: attr(data-label);
    color: var(--muted); font-weight: 650; flex-shrink: 0;
  }
  .row-actions .btn { flex: 1; min-width: 120px; }
  .wx-hero-metrics { grid-template-columns: 1fr; }
  .mon-grid-3 { gap: 8px; }
  .mon-cell { padding: 12px 8px; border-radius: 14px; }
  .soil-sensor { gap: 8px; }
  .soil-sensor-mark { min-width: 40px; }
  .soil-sensor-icon { width: 34px; height: 34px; }
  .mon-card { padding: 16px 14px 12px; }
  .mon-inds { gap: 14px 18px; }
}

.mail-editor-wrap { margin-top: 14px; }
.mail-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin-bottom: 8px;
}
.mail-editor {
  min-height: 180px; border: 1.5px solid #dfe8e3; border-radius: 12px;
  padding: 12px; background: #fff; outline: none;
}
.mail-editor:focus { border-color: #9ec2e8; }
.mail-editor img { max-width: 100%; height: auto; border-radius: 8px; }
.mail-view {
  max-height: 50vh; overflow: auto; border: 1px solid #e7eee9;
  border-radius: 12px; padding: 12px; background: #fff;
}
.mail-view img { max-width: 100%; height: auto; }
.modal-wide { max-width: 720px; width: calc(100% - 24px); }
.mail-row { cursor: pointer; }

.chart-toolbar { gap: 10px; flex-wrap: wrap; }
.chart-toolbar .range-btns { margin-left: auto; }
.range-btns { display: flex; gap: 6px; }
.range-btn {
  border: 1.5px solid #dfe8e3; background: #fafcfb; color: var(--muted);
  border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 12px;
  font-weight: 700; cursor: pointer;
}
.range-btn.active { background: #e8f2fb; border-color: #9ec2e8; color: var(--blue); }
.chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 4px 0 12px; }
.chart-head h2 { font-size: 20px; font-weight: 750; }
.chart-latest { color: var(--blue); font-weight: 750; font-size: 18px; }
.chart-wrap { position: relative; width: 100%; height: 320px; }
.chart-wrap canvas { width: 100%; height: 100%; display: block; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 2;
  background: #14241e; color: #fff; font-size: 12px; font-weight: 650;
  padding: 6px 8px; border-radius: 8px; white-space: nowrap;
  transform: translate(-50%, -120%);
}
.chart-empty { text-align: center; color: var(--muted); padding: 48px 12px; font-weight: 650; }
.hist-row { cursor: default; }
.linkish {
  border: 0; background: none; padding: 0; cursor: pointer;
  color: var(--blue); font: inherit; font-weight: 700;
}
