:root {
  --bg: #f4f6fa; --card: #ffffff; --text: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --accent: #2563eb; --accent-soft: #dbeafe; --ok: #16a34a; --warn: #d97706; --bad: #dc2626;
  --radius: 14px; --shadow: 0 1px 2px rgba(15,23,42,.06), 0 4px 16px rgba(15,23,42,.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120; --card: #131c2e; --text: #e2e8f0; --muted: #94a3b8; --line: #23304a;
    --accent: #60a5fa; --accent-soft: #1e3a5f; --shadow: 0 1px 2px rgba(0,0,0,.3);
  }
}
* { box-sizing: border-box; }
html, 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); }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 20px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; }
.brand img { height: 36px; width: auto; display: block; }
.brand-sub { color: var(--muted); font-weight: 600; border-left: 1px solid var(--line); padding-left: 10px; }
nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
nav a { padding: 7px 12px; border-radius: 10px; color: var(--muted); text-decoration: none; font-weight: 600; }
nav a.on { background: var(--accent-soft); color: var(--accent); }
.me { display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: var(--line); }
select, input { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 7px 10px; }
input { width: 100%; }

main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 60px; }
h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 18px; margin: 28px 0 12px; }
.sub { color: var(--muted); margin: 0 0 20px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }

.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
a.tile { display: flex; gap: 12px; align-items: center; text-decoration: none; color: var(--text); transition: transform .1s; }
a.tile:hover { transform: translateY(-2px); border-color: var(--accent); }
.tile .ic { width: 42px; height: 42px; border-radius: 12px; background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; flex: none; }
.tile b { display: block; }
.tile small { color: var(--muted); }
svg.i { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.svc-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.svc-head h3 { margin: 0; font-size: 17px; flex: 1; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--ok); } .dot.warn, .dot.stale { background: var(--warn); } .dot.bad, .dot.error, .dot.offline { background: var(--bad); }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); gap: 10px; }
.kv div { background: var(--bg); border-radius: 10px; padding: 8px 10px; }
.kv small { display: block; color: var(--muted); font-size: 12px; }
.kv b { font-size: 16px; }

.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px;
  background: var(--accent-soft); color: var(--accent); }
.badge.warn { background: #fef3c7; color: #92400e; } .badge.bad { background: #fee2e2; color: #991b1b; }
.badge.grey { background: var(--bg); color: var(--muted); }

.list { display: flex; flex-direction: column; gap: 10px; }
.item { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.item .who { flex: 1; min-width: 180px; }
.item .who b { display: block; }
.item .who small { color: var(--muted); }
.item .avatar { width: 40px; height: 40px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid transparent; border-radius: 10px;
  padding: 8px 14px; font: inherit; font-weight: 600; cursor: pointer; background: var(--accent); color: #fff; text-decoration: none; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn.danger { background: transparent; color: var(--bad); border-color: var(--line); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.scroll { overflow-x: auto; }

dialog { border: none; border-radius: var(--radius); padding: 0; width: min(520px, calc(100vw - 32px));
  background: var(--card); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(15,23,42,.45); }
dialog form { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
dialog h3 { margin: 0 0 4px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-weight: 500; font-size: 14px; }
label.check input { width: auto; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.linkbox { font-family: ui-monospace, Consolas, monospace; font-size: 13px; word-break: break-all;
  background: var(--bg); padding: 10px; border-radius: 10px; user-select: all; }
.hint { color: var(--muted); font-size: 13px; }
.err { color: var(--bad); font-size: 13px; min-height: 1em; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(120px); background: var(--text);
  color: var(--bg); padding: 10px 18px; border-radius: 12px; transition: transform .25s; z-index: 20; max-width: calc(100vw - 32px); }
#toast.show { transform: translateX(-50%) translateY(0); }
.loading { height: 40px; width: 40px; margin: 80px auto; border-radius: 50%; border: 4px solid var(--line);
  border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.center { text-align: center; padding: 80px 16px; }
.empty { color: var(--muted); padding: 10px 0; }

.grid.wide { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
a.tile.svc { align-items: flex-start; }
a.tile.svc .dot { margin-top: 7px; }
a.tile.svc > span:nth-child(2) { flex: 1; }
.tile small.facts { margin-top: 4px; color: var(--text); }
.crumb { margin: 0 0 8px; } .crumb a { text-decoration: none; font-weight: 600; }
.logbox { background: #0b1120; color: #cbd5e1; font: 12px/1.45 ui-monospace, Consolas, monospace; padding: 12px; border-radius: 10px;
  max-height: 60vh; overflow: auto; white-space: pre-wrap; word-break: break-all; margin: 0; }
dialog:has(.logbox) { width: min(900px, calc(100vw - 32px)); }
.toplist { margin: 8px 0 0; padding-left: 22px; font-size: 14px; }
.toplist li { padding: 3px 0; } .toplist li span { word-break: break-all; } .toplist li b { float: right; margin-left: 8px; font-weight: 600; }
textarea { font: 13px/1.4 ui-monospace, Consolas, monospace; color: var(--text); background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px; width: 100%; resize: vertical; }
dialog textarea { font-family: inherit; font-size: 14px; }
code { font-family: ui-monospace, Consolas, monospace; font-size: 13px; background: var(--bg); padding: 1px 5px; border-radius: 6px; word-break: break-all; }
.nowrap { white-space: nowrap; }
.row.nowrap { flex-wrap: nowrap; }
.appicon { width: 48px; height: 48px; border-radius: 12px; object-fit: cover; flex: none; }
.appicon.ic { display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.appdetail h1 { margin: 0; }
.appdetail .appicon { width: 64px; height: 64px; }
.qr { display: inline-flex; flex-direction: column; align-items: center; gap: 4px; margin-top: 8px; }
.qr img { width: 160px; height: 160px; border-radius: 10px; background: #fff; }
.qr small { color: var(--muted); }
.bkgrid { align-items: start; }
.timeline { max-height: 520px; overflow: auto; display: flex; flex-direction: column; gap: 10px; }
.tday small { color: var(--muted); font-weight: 600; display: block; margin-bottom: 4px; }
.btn.on { background: var(--accent); color: #fff; border-color: var(--accent); }
#browser { max-height: 520px; overflow: auto; }
.pathbar { font-size: 13px; word-break: break-all; }
.files { display: flex; flex-direction: column; }
.frow { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.frow > a, .frow > span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; }
.frow small { white-space: nowrap; }
td .btn + .btn, td .btn + a.btn, td a.btn + .btn { margin-left: 4px; }

@media (max-width: 640px) {
  .top { padding: 10px 16px; gap: 10px; }
  .brand-sub { display: none; }
  nav { order: 3; flex-basis: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .two { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
}
