:root {
  --bg: #0d1117;
  --bg2: #131a23;
  --panel: #18212c;
  --line: #24303e;
  --ink: #e6edf3;
  --dim: #8b98a5;
  --ok: #3fb950;
  --warn: #d29922;
  --bad: #f85149;
  --acc: #58a6ff;
  --mono: ui-monospace, "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.5 system-ui, -apple-system, "Noto Sans CJK SC", sans-serif;
}
h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 16px; letter-spacing: .3px; }
h2 { font-size: 15px; }
h3 { font-size: 13px; color: var(--dim); margin: 18px 0 8px; text-transform: none; }
p { margin: 8px 0; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.dim { color: var(--dim); }
.small { font-size: 12px; }
.center { text-align: center; padding: 40px 0; }
.grow { flex: 1; }

.bar {
  display: flex; align-items: center; gap: 14px; justify-content: space-between;
  padding: 12px 20px; background: var(--bg2); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { width: 26px; height: 26px; border-radius: 7px; display: block;
  background: conic-gradient(from 210deg, var(--acc), #1f6feb 40%, #39c5cf 70%, var(--acc)); }
.sub { margin: 0; font-size: 11.5px; color: var(--dim); }
.bar-right { display: flex; align-items: center; gap: 10px; }

.pill { padding: 3px 10px; border-radius: 999px; font-size: 12px; border: 1px solid var(--line); background: var(--panel); white-space: nowrap; }
.brand h1 { white-space: nowrap; }
.pill.ok { color: var(--ok); border-color: #14431f; }
.pill.bad { color: var(--bad); border-color: #4d1a1a; }

button {
  font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line);
  border-radius: 7px; padding: 6px 12px; cursor: pointer; white-space: nowrap;
}
button:hover { border-color: #33415a; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: #1f6feb; border-color: #1f6feb; }
button.primary:hover { background: #388bfd; }
button.ghost { background: transparent; }
button.danger { color: var(--bad); border-color: #4d1a1a; background: transparent; }

input, select {
  font: inherit; color: var(--ink); background: var(--bg2);
  border: 1px solid var(--line); border-radius: 7px; padding: 6px 10px;
}
input:focus, select:focus, button:focus { outline: 2px solid #1f6feb55; outline-offset: 1px; }

main { padding: 20px; max-width: 1440px; margin: 0 auto; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; }
.row { display: flex; gap: 10px; margin-top: 10px; }
.row input { flex: 1; }

.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input[type=search] { width: 240px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; background: transparent; padding: 6px 12px; }
.seg button.on { background: #1f2c3d; color: var(--acc); }

.stats { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; min-width: 108px; display: flex; flex-direction: column; gap: 2px; justify-content: center; }
.stat button { align-self: flex-start; }
.stat b { display: block; font-size: 19px; font-weight: 600; }
.stat span { font-size: 11.5px; color: var(--dim); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(276px, 1fr)); gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px; cursor: pointer; position: relative; }
.card:hover { border-color: #33415a; }
.card.sel { border-color: var(--acc); }
.card-top { display: flex; align-items: center; gap: 8px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--dim); flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px #14431f; }
.dot.off { background: var(--bad); }
.dot.q { background: var(--warn); box-shadow: 0 0 0 3px #3d2c07; }
.dev { font-family: var(--mono); font-size: 13.5px; }
.card .meta { margin-top: 10px; display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; font-size: 12px; }
.card .meta dt { color: var(--dim); }
.card .meta dd { margin: 0; font-family: var(--mono); }
.badge { position: absolute; right: 12px; top: 12px; font-size: 11px; color: var(--warn); }
.ackline { margin-top: 10px; font-size: 11.5px; padding-top: 9px; border-top: 1px dashed var(--line); color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ackline b { color: var(--ok); font-weight: 500; }
.ackline b.no { color: var(--bad); }
.chk { margin-right: 2px; }
.bar-fill { height: 4px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 9px; }
.bar-fill i { display: block; height: 100%; background: var(--acc); }

.drawer-head { display: flex; justify-content: space-between; align-items: center; }
#drawer {
  position: fixed; right: 0; top: 0; height: 100%; width: min(430px, 96vw); z-index: 40;
  background: var(--bg2); border-left: 1px solid var(--line); padding: 16px 18px; overflow: auto;
  box-shadow: -16px 0 40px #00000066;
}
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; }
.facts dt { color: var(--dim); font-size: 12px; }
.facts dd { margin: 0; font-family: var(--mono); font-size: 12.5px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { padding: 4px 9px; font-size: 12px; font-family: var(--mono); }
.raw { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-size: 11.5px; overflow: auto; max-height: 190px; }

#toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--acc);
  border-radius: 9px; padding: 9px 14px; font-size: 12.5px; max-width: 640px; }
.toast.bad { border-left-color: var(--bad); }
.toast.ok { border-left-color: var(--ok); }

table.calc { border-collapse: collapse; width: 100%; margin-top: 10px; font-size: 12.5px; }
table.calc th, table.calc td { border-bottom: 1px solid var(--line); padding: 5px 8px; text-align: left; }
table.calc td { font-family: var(--mono); }
dialog { background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; padding: 18px; width: min(520px, 94vw); }
dialog::backdrop { background: #000a; }
