:root {
  --bg: #f4f6fa; --panel: #ffffff; --panel-2: #eef1f7; --text: #18202e; --muted: #5d6879;
  --line: #dde2ec; --accent: #2f6fed; --accent-2: #1d4fc0; --accent-soft: #e4ecfd;
  --ok: #16a34a; --warn: #d97706; --crit: #dc2626; --off: #94a3b8;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 4px 16px rgba(16,24,40,.06);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e131c; --panel: #161d29; --panel-2: #1d2635; --text: #e6ebf3; --muted: #93a0b4;
    --line: #273245; --accent: #5b8cff; --accent-2: #86a8ff; --accent-soft: #1c2a47;
    --ok: #22c55e; --warn: #f59e0b; --crit: #f87171; --off: #64748b;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 18px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8;
        stroke-linecap: round; stroke-linejoin: round; }

/* --- top bar --- */
.top { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--panel) 88%, transparent);
       backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1180px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 18px; }
.brand:hover { text-decoration: none; }
.logo { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #fff;
        background: linear-gradient(135deg, var(--accent), #8b5cf6); }
.top .sp { flex: 1; }
.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--panel);
       color: var(--text); padding: 9px 14px; border-radius: 10px; font: inherit; font-size: 15px; cursor: pointer; }
.btn:hover { text-decoration: none; background: var(--panel-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { color: var(--crit); }
.btn.danger.solid { background: var(--crit); border-color: var(--crit); color: #fff; }
.btn.small { padding: 6px 10px; font-size: 14px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

nav.side { max-width: 1180px; margin: 0 auto; padding: 8px 16px 0; display: flex; gap: 6px; overflow-x: auto;
           scrollbar-width: none; }
nav.side::-webkit-scrollbar { display: none; }
nav.side a { white-space: nowrap; padding: 6px 12px; border-radius: 999px; color: var(--muted); font-size: 14px; }
nav.side a.on, nav.side a:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }

main { max-width: 1180px; margin: 0 auto; padding: 20px 16px 48px; }
h1 { font-size: 26px; margin: 4px 0 4px; letter-spacing: -.01em; }
h2 { font-size: 18px; margin: 0 0 12px; }
.sub { color: var(--muted); margin: 0 0 20px; }
.path { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .86em; color: var(--muted);
        font-weight: 500; }

/* --- cards --- */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
        padding: 18px; }
a.tile { display: flex; flex-direction: column; gap: 10px; color: var(--text); transition: transform .12s, border-color .12s; }
a.tile:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-2px); }
.tile-h { display: flex; align-items: center; gap: 12px; }
.tile-ic { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
           background: var(--accent-soft); color: var(--accent); }
.tile-ic svg.i { width: 22px; height: 22px; }
.tile-t { font-weight: 650; font-size: 17px; line-height: 1.25; }
.tile-d { color: var(--muted); font-size: 14px; }
.tile-s { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin-top: auto; }

.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--off); display: inline-block; flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
.dot.warn { background: var(--warn); }
.dot.crit { background: var(--crit); }

.banner span { overflow-wrap: anywhere; min-width: 0; }
.banner { border-radius: 12px; padding: 12px 14px; margin: 0 0 16px; border: 1px solid var(--line); background: var(--panel);
          display: flex; gap: 10px; align-items: flex-start; }
.banner.ok { border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); background: color-mix(in srgb, var(--ok) 9%, var(--panel)); }
.banner.warn { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); background: color-mix(in srgb, var(--warn) 9%, var(--panel)); }
.banner.crit { border-color: color-mix(in srgb, var(--crit) 45%, var(--line)); background: color-mix(in srgb, var(--crit) 9%, var(--panel)); }

/* --- dashboard --- */
.stats { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); margin-bottom: 14px; }
.stat-l { color: var(--muted); font-size: 14px; display: flex; align-items: center; gap: 8px; }
.stat-v { font-size: 30px; font-weight: 700; letter-spacing: -.02em; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.stat-v small { font-size: 15px; color: var(--muted); font-weight: 500; }
.stat-x { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.bar { height: 8px; border-radius: 99px; background: var(--panel-2); overflow: hidden; margin: 8px 0 4px; }
.bar > i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .5s; }
.bar.warn > i { background: var(--warn); } .bar.crit > i { background: var(--crit); }
svg.spark { width: 100%; height: 46px; display: block; margin-top: 6px; }
svg.spark path.l { fill: none; stroke: var(--accent); stroke-width: 2; }
svg.spark path.a { fill: color-mix(in srgb, var(--accent) 14%, transparent); stroke: none; }
svg.spark path.l2 { fill: none; stroke: #8b5cf6; stroke-width: 2; }
.two { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); margin-bottom: 14px; }
.rows { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.row:last-child { border-bottom: 0; }
.row .n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.row .m { color: var(--muted); font-size: 13px; text-align: right; }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 5px; }

/* --- forms --- */
label { display: block; font-size: 14px; color: var(--muted); margin: 12px 0 6px; }
input[type=password], input[type=text], input[type=time], input[type=date] {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel);
  color: var(--text); font: inherit; }
input:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); border-color: var(--accent); }
.pw { position: relative; }
.pw input { padding-right: 84px; }
.pw button { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none;
             color: var(--accent); cursor: pointer; font: inherit; font-size: 14px; padding: 6px 8px; }
.err { color: var(--crit); font-size: 14px; margin: 8px 0 0; }
.ok-t { color: var(--ok); }
.meter { height: 6px; border-radius: 6px; background: var(--panel-2); margin-top: 8px; overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; transition: width .2s, background .2s; }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; }
.days { display: flex; flex-wrap: wrap; gap: 6px; }
.days label { margin: 0; }
.days input { position: absolute; opacity: 0; pointer-events: none; }
.days span { display: inline-block; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer;
             color: var(--text); min-width: 52px; text-align: center; user-select: none; }
.days input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.days input:focus-visible + span { outline: 2px solid var(--accent); }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; color: var(--text); font-size: 16px; margin: 0; }
.switch input { appearance: none; width: 46px; height: 26px; border-radius: 99px; background: var(--off); position: relative;
                cursor: pointer; transition: background .2s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
                       background: #fff; transition: left .2s; }
.switch input:checked { background: var(--ok); }
.switch input:checked::after { left: 23px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 15px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-variant-numeric: tabular-nums; word-break: break-word; }
code, .mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .9em; background: var(--panel-2);
              padding: 1px 6px; border-radius: 6px; }
.secret { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* --- login --- */
.center { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 400px; }
.login .brand { justify-content: center; margin-bottom: 18px; font-size: 22px; }
.login .logo { width: 44px; height: 44px; }

dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--text);
         padding: 20px; max-width: 420px; width: calc(100% - 32px); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(10,14,22,.55); }

@media (max-width: 560px) {
  h1 { font-size: 22px; }
  .top .who { display: none; }
  .stat-v { font-size: 26px; }
  .two { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 0 0; } .kv dd { margin-bottom: 8px; }
}
