:root {
  --green: #166534;
  --green-light: #22c55e;
  --bg: #f4f7f4;
  --card: #ffffff;
  --text: #1a2e1a;
  --muted: #6b7f6b;
  --danger: #dc2626;
  --border: #dbe5db;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101710; --card: #1a241a; --text: #e6efe6;
    --muted: #8fa38f; --border: #2c3a2c;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: system-ui, sans-serif;
  background: var(--bg); color: var(--text);
  padding-bottom: 2rem;
}
header {
  background: var(--green); color: #fff;
  padding: max(env(safe-area-inset-top), 0.6rem) 1rem 0.6rem;
  display: flex; justify-content: space-between; align-items: center;
  position: sticky; top: 0; z-index: 5;
}
h1 { font-size: 1.15rem; margin: 0; }
h2 { font-size: 0.95rem; margin: 0 0 .5rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
main { max-width: 640px; margin: 0 auto; padding: 0.8rem; display: grid; gap: 0.8rem; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 0.9rem; }
.pill { border-radius: 999px; padding: 0.15rem 0.7rem; font-size: 0.8rem; background: #14532d; }
.pill.online { background: var(--green-light); color: #05320f; }
.pill.offline { background: #7f1d1d; }
.row { display: flex; gap: 0.6rem; align-items: center; margin-top: 0.6rem; flex-wrap: wrap; }
button {
  font: inherit; border: 0; border-radius: 8px; padding: 0.55rem 1rem;
  background: var(--green); color: #fff; cursor: pointer;
}
button:active { transform: scale(0.97); }
button:disabled { opacity: 0.5; cursor: default; }
button.danger { background: var(--danger); }
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
button.small { padding: 0.35rem 0.7rem; font-size: 0.85rem; }
input, select {
  font: inherit; padding: 0.45rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
input[type=number] { width: 4.5rem; }
.zone {
  display: flex; justify-content: space-between; align-items: center;
  gap: 0.5rem; padding: 0.6rem 0; border-bottom: 1px solid var(--border);
}
.zone:last-child { border-bottom: 0; }
.zone .info { flex: 1; min-width: 0; }
.zone .name { font-weight: 600; }
.zone .sched { font-size: 0.8rem; color: var(--muted); }
.zone.running .name::after { content: " ● running"; color: var(--green-light); font-size: .8rem; }
.hist-day { margin-bottom: 0.6rem; }
.hist-day h3 { font-size: 0.85rem; margin: 0 0 0.2rem; color: var(--muted); }
.hist-run { display: flex; justify-content: space-between; font-size: 0.9rem; padding: 0.15rem 0; }
.hist-run .src-manual { color: var(--green-light); }
#banner { background: #7f1d1d; color: #fff; border-radius: 12px; padding: 0.7rem 0.9rem; font-size: .9rem; }
.hidden { display: none !important; }
dialog {
  border: 1px solid var(--border); border-radius: 14px; background: var(--card);
  color: var(--text); width: min(92vw, 380px); padding: 1rem;
}
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog label { display: block; margin: 0.7rem 0 0; font-size: 0.9rem; }
dialog input, dialog select { width: 100%; margin-top: 0.25rem; }
.days-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 0.6rem; }
.days-grid button {
  padding: 0.4rem 0; font-size: 0.75rem; background: var(--bg);
  color: var(--text); border: 1px solid var(--border);
}
.days-grid button.on { background: var(--green); color: #fff; border-color: var(--green); }
#toast {
  position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); border-radius: 10px;
  padding: 0.6rem 1.1rem; font-size: 0.9rem; z-index: 20; max-width: 90vw;
}
