:root {
  --bg: #f4f5f7; --surface: #fff; --ink: #14161a; --muted: #5d6572; --line: #e3e6eb;
  --accent: #1d4ed8; --accent-ink: #fff; --ok: #0f7a3d; --ok-bg: #e4f5ea;
  --warn: #a15c00; --warn-bg: #fff1d6; --bad: #b42318; --bad-bg: #fde8e6;
  --shadow: 0 1px 2px rgba(20,22,26,.06), 0 4px 16px rgba(20,22,26,.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1013; --surface: #171a1f; --ink: #eceef2; --muted: #98a1b0; --line: #2a2f37;
    --accent: #6c93ff; --accent-ink: #0b1020; --ok: #5ad08a; --ok-bg: #12301f;
    --warn: #f3b44f; --warn-bg: #33270f; --bad: #ff8a80; --bad-bg: #3a1815;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  padding: env(safe-area-inset-top) 16px calc(24px + env(safe-area-inset-bottom));
}
#app { max-width: 720px; margin: 0 auto; padding-top: 16px; }
[hidden] { display: none !important; }
h1 { font-size: 22px; margin: 0; letter-spacing: .2px; }
h2 { font-size: 17px; margin: 0 0 4px; }
h3 { font-size: 15px; margin: 16px 0 6px; }
code { font-size: 13px; background: var(--bg); padding: 1px 5px; border-radius: 5px; }
.muted { color: var(--muted); font-size: 14px; margin: 4px 0 14px; }
.hint { font-size: 13px; color: var(--muted); }
.center { text-align: center; }

.top { display: flex; align-items: center; justify-content: space-between; padding: 6px 2px 16px; }
.top-actions { display: flex; align-items: center; gap: 8px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px; box-shadow: var(--shadow); margin-bottom: 14px; }
.card.narrow { max-width: 420px; margin: 8vh auto 14px; }

label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 12px; }
input[type=password] {
  display: block; width: 100%; margin-top: 4px; padding: 11px 12px; font: inherit; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
}
input:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn { font: inherit; font-weight: 600; border-radius: 10px; border: 1px solid transparent; padding: 11px 16px; cursor: pointer; min-height: 44px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); width: 100%; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost[aria-pressed=true] { background: var(--surface); border-color: var(--accent); color: var(--accent); }
.btn.small { min-height: 34px; padding: 4px 12px; font-size: 14px; font-weight: 500; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* 入口 */
.tiles { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.tile {
  display: flex; flex-direction: column; gap: 8px; height: 100%; padding: 16px; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
  transition: transform .12s, border-color .12s;
}
a.tile:hover { transform: translateY(-2px); border-color: var(--tile, var(--accent)); }
.tile.dim { opacity: .62; }
.tile .ico {
  width: 48px; height: 48px; border-radius: 13px; display: grid; place-items: center; font-size: 26px;
  background: color-mix(in srgb, var(--tile, var(--accent)) 16%, transparent);
}
.tile .name { font-weight: 650; font-size: 17px; overflow-wrap: anywhere; }
.tile .desc { color: var(--muted); font-size: 13px; line-height: 1.4; flex: 1; overflow-wrap: anywhere; }
.tile .st { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.online { background: var(--ok); }
.dot.offline { background: var(--bad); }

/* 管理 */
.rows { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 10px; }
.row { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--bg); }
.row .h { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.row .t { font-weight: 650; overflow-wrap: anywhere; }
.row .t small { color: var(--muted); font-weight: 400; margin-left: 6px; }
.pill { font-size: 12px; font-weight: 600; padding: 1px 9px; border-radius: 99px; white-space: nowrap; }
.pill.online { color: var(--ok); background: var(--ok-bg); }
.pill.offline { color: var(--bad); background: var(--bad-bg); }
.row .kv { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.row .warn { color: var(--warn); }
.invalid { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 6px; font-size: 13px; }
.invalid li { background: var(--bad-bg); color: var(--bad); border-radius: 8px; padding: 8px 10px; overflow-wrap: anywhere; }

#toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  max-width: calc(100% - 32px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px;
  font-size: 15px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.bad { background: var(--bad); color: #fff; }
@media (prefers-reduced-motion: reduce) { #toast, .tile { transition: none; } a.tile:hover { transform: none; } }
