:root {
  --bg: #f6f7f5; --surface: #fff; --text: #1c2321; --muted: #5d6865; --line: #dfe3e0;
  --accent: #1f6f5c; --accent-text: #fff; --on: #1f8a4c; --off: #8a8f8d; --warn: #a15c00; --danger: #b3261e;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141917; --surface: #1d2422; --text: #e6ebe9; --muted: #9aa5a1; --line: #2f3936;
    --accent: #4fb89b; --accent-text: #0d1513; --on: #5ccf8c; --off: #7d8683; --warn: #e3a54a; --danger: #ff8a80;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: 0 0 .5rem; }
h2 { font-size: 1.15rem; margin: 2rem 0 .5rem; }
small, .muted, .hint, .lead, .meta { color: var(--muted); }
.hint { font-size: .9rem; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: .75rem max(1rem, calc((100vw - 1100px) / 2)); background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 650; color: var(--text); text-decoration: none; }
.brand img { width: 26px; height: 26px; }
.top nav { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; font-size: .95rem; }
.top nav a { text-decoration: none; }
.who { color: var(--muted); }
main { max-width: 1100px; margin: 0 auto; padding: 2rem 1rem 4rem; }

.hero { max-width: 34rem; margin: 10vh auto; text-align: center; }
.hero p { color: var(--muted); margin-bottom: 1.5rem; }

.button { display: inline-block; padding: .5rem 1rem; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; text-decoration: none; cursor: pointer; }
.button:hover { border-color: var(--accent); }
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; font-size: .85rem; cursor: pointer; text-decoration: underline; }
button.link.danger { color: var(--danger); }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 1rem; margin-top: 1.5rem; }
.tile { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 1.25rem; }
.tile h2 { margin: 0; }
.tile p { margin: .5rem 0; }
.tile-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.tile .actions { display: flex; gap: .5rem; margin-top: auto; padding-top: .75rem; }
.status { font-size: .8rem; white-space: nowrap; }
.status::before { content: "●"; margin-right: .3rem; }
.status.on { color: var(--on); }
.status.off { color: var(--off); }
.badge { display: inline-block; font-size: .78rem; padding: .05rem .45rem; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); }
.badge.warn { color: var(--warn); border-color: currentColor; }
.empty { padding: 2rem; background: var(--surface); border: 1px dashed var(--line); border-radius: 12px; }
.notice { padding: .6rem .9rem; border-radius: 8px; background: var(--surface); border-left: 4px solid var(--on); }

.table-wrap { overflow-x: auto; margin: 1rem 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; }
th, td { padding: .55rem .75rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
.matrix th:not(.who-col), .matrix td.cell { text-align: center; }
.matrix .who-col { min-width: 14rem; }
.vis-row th { font-weight: normal; }
.check input { width: 1.15rem; height: 1.15rem; accent-color: var(--accent); cursor: pointer; }
.check.dim { opacity: .45; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions > * { margin-left: .6rem; }
.log td { font-size: .9rem; }
select, input[type=email], input[type=text] { font: inherit; padding: .4rem .55rem; border-radius: 6px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); }
form.inline { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: center; }
#matrix + h2 + .hint + form.inline { justify-content: flex-start; }

.spinner { width: 42px; height: 42px; margin: 0 auto 1.5rem; border-radius: 50%;
  border: 4px solid var(--line); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
