:root {
  --bg: #0d1117;
  --bg2: #161b22;
  --bg3: #1c2129;
  --border: #30363d;
  --fg: #e6edf3;
  --fg2: #9ea7b3;
  --fg3: #6e7681;
  --accent: #58a6ff;
  --mono: ui-monospace, 'SF Mono', 'Cascadia Code', Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--fg); }
body { font: 14px/1.45 -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); }

/* ---------- header ---------- */
#hdr {
  position: sticky; top: 0; z-index: 50;
  background: rgba(13,17,23,.95); backdrop-filter: blur(4px);
  border-bottom: 1px solid var(--border);
  padding: 10px 18px 0;
}
#hdr .row1 { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
#hdr h1 { font-size: 17px; margin: 0; letter-spacing: .2px; }
#hdr h1 .dim { color: var(--fg3); font-weight: 400; }
#hdr .stats { color: var(--fg2); font-size: 12.5px; }
#hdr .stats b { color: var(--fg); }
#globalsearch {
  margin-left: auto; position: relative;
}
#globalsearch input {
  width: 320px; padding: 5px 10px 5px 28px;
  background: var(--bg2); color: var(--fg);
  border: 1px solid var(--border); border-radius: 6px; font-size: 13px;
}
#globalsearch input:focus { outline: none; border-color: var(--accent); }
#globalsearch .icon { position: absolute; left: 9px; top: 5px; color: var(--fg3); }
#searchdrop {
  position: absolute; right: 0; top: 34px; width: 460px; max-height: 60vh; overflow: auto;
  background: var(--bg3); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 30px rgba(0,0,0,.6); display: none; z-index: 99;
}
#searchdrop.open { display: block; }
#searchdrop .sr { padding: 6px 12px; cursor: pointer; display: flex; gap: 8px; align-items: baseline; border-bottom: 1px solid #21262d; }
#searchdrop .sr:hover, #searchdrop .sr.sel { background: #21304a; }
#searchdrop .sr .kind { font-size: 10px; text-transform: uppercase; letter-spacing: .6px; color: var(--fg3); width: 52px; flex: none; }
#searchdrop .sr .main { font-family: var(--mono); font-size: 13px; }
#searchdrop .sr .sub { color: var(--fg2); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#tabs { display: flex; gap: 2px; margin-top: 8px; }
#tabs .tab {
  padding: 7px 14px; cursor: pointer; color: var(--fg2); font-size: 13.5px;
  border: 1px solid transparent; border-bottom: none; border-radius: 8px 8px 0 0;
}
#tabs .tab:hover { color: var(--fg); }
#tabs .tab.active {
  color: var(--fg); background: var(--bg); border-color: var(--border);
  position: relative; top: 1px;
}
#tabs .tab .n { color: var(--fg3); font-size: 11px; }

#main { padding: 16px 18px 80px; }

/* ---------- generic ---------- */
.badge {
  display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px;
  border: 1px solid var(--border); color: var(--fg2); vertical-align: middle;
}
.badge.grp { border-color: transparent; color: #0d1117; font-weight: 600; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; margin: 2px;
  border: 1px solid var(--border); border-radius: 12px; font-size: 12px; cursor: pointer;
  color: var(--fg); background: var(--bg2);
}
.chip:hover { border-color: var(--accent); }
.chip .pct { color: var(--fg3); font-size: 11px; }
.gatebadge {
  display: inline-block; font-size: 10.5px; padding: 0 6px; border-radius: 8px;
  border: 1px dashed #bb8009; color: #e3b341; margin-left: 6px; vertical-align: 1px;
}
button, select {
  background: var(--bg2); color: var(--fg); border: 1px solid var(--border);
  border-radius: 6px; padding: 4px 10px; font-size: 13px; cursor: pointer;
}
button:hover { border-color: var(--accent); }
button.primary { background: #1f6feb; border-color: #1f6feb; }
button.on { background: #1f6feb33; border-color: var(--accent); }
input[type=text] {
  background: var(--bg2); color: var(--fg); border: 1px solid var(--border);
  border-radius: 6px; padding: 4px 10px; font-size: 13px;
}
input[type=text]:focus { outline: none; border-color: var(--accent); }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .sep { width: 1px; height: 20px; background: var(--border); }
.toolbar label { color: var(--fg2); font-size: 12.5px; }
.hint { color: var(--fg3); font-size: 12px; }
.legend { display: inline-flex; gap: 14px; align-items: center; color: var(--fg2); font-size: 12px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: -1px; }
.dot.hollow { background: transparent !important; border: 2px solid; width: 7px; height: 7px; }

/* ---------- matrix ---------- */
#matrixwrap { overflow: auto; max-height: calc(100vh - 210px); border: 1px solid var(--border); border-radius: 8px; }
table.matrix { border-collapse: separate; border-spacing: 0; font-size: 12px; }
table.matrix th, table.matrix td { padding: 0; }
table.matrix thead th { position: sticky; background: var(--bg2); z-index: 20; }
table.matrix thead tr.groups th { top: 0; height: 20px; font-size: 10.5px; font-weight: 700; color: #0d1117; }
table.matrix thead tr.cols th { top: 20px; height: 108px; vertical-align: bottom; border-bottom: 1px solid var(--border); }
table.matrix thead th.corner { left: 0; z-index: 30; background: var(--bg2); }
table.matrix .colhead {
  writing-mode: vertical-rl; transform: rotate(180deg);
  padding: 6px 0; margin: 0 auto; display: block;
  font-family: var(--mono); font-size: 11.5px; cursor: pointer; color: var(--fg2);
  max-height: 100px; overflow: hidden; white-space: nowrap;
}
table.matrix .colhead:hover { color: var(--fg); }
table.matrix .colhead b { font-weight: 700; }
table.matrix tbody th {
  position: sticky; left: 0; background: var(--bg); z-index: 10;
  text-align: right; padding: 0 10px 0 12px; font-weight: 500; white-space: nowrap;
  border-right: 1px solid var(--border); cursor: pointer; max-width: 240px;
  overflow: hidden; text-overflow: ellipsis; font-size: 12.5px; height: 26px;
}
table.matrix tbody tr:hover th { color: var(--accent); }
table.matrix tbody tr:hover td { background: #ffffff0a; }
table.matrix td.cell { width: 26px; min-width: 26px; height: 26px; text-align: center; cursor: pointer; border-radius: 3px; }
table.matrix td.cell:hover { outline: 1px solid var(--accent); outline-offset: -1px; }
table.matrix td.cell.colhl { background: #ffffff0a; }
table.matrix td.count { color: var(--fg3); font-family: var(--mono); font-size: 11px; padding: 0 8px; text-align: right; }
table.matrix td.gsep, table.matrix th.gsep { border-left: 1px solid #2a3038; }
.mdot {
  display: inline-block; border-radius: 50%; vertical-align: middle;
  min-width: 8px; min-height: 8px; line-height: 1;
}
.mdot.both { box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.5px currentColor; }
.mdot.gatedonly { background: transparent !important; border: 1.5px solid; }
.mdot .cnt { font-size: 9px; color: #0d1117; font-weight: 700; display: block; }

/* ---------- tooltip ---------- */
#tip {
  position: fixed; z-index: 200; pointer-events: none; display: none;
  background: #1c2129f2; border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 11px; font-size: 12px; max-width: 380px; box-shadow: 0 6px 24px rgba(0,0,0,.5);
}
#tip h4 { margin: 0 0 4px; font-size: 12px; }
#tip .t { font-family: var(--mono); font-size: 11.5px; }
#tip .g { color: #e3b341; }
#tip .d { color: var(--fg2); }

/* ---------- drawer ---------- */
#drawer {
  position: fixed; top: 0; right: -560px; width: 540px; max-width: 92vw; height: 100vh;
  background: var(--bg2); border-left: 1px solid var(--border); z-index: 100;
  transition: right .18s ease; display: flex; flex-direction: column;
  box-shadow: -12px 0 40px rgba(0,0,0,.5);
}
#drawer.open { right: 0; }
#drawer .dhead {
  padding: 14px 18px 10px; border-bottom: 1px solid var(--border); flex: none;
  display: flex; align-items: flex-start; gap: 10px;
}
#drawer .dhead h2 { margin: 0; font-size: 17px; font-family: var(--mono); }
#drawer .dhead .sub { color: var(--fg2); font-size: 12.5px; margin-top: 3px; }
#drawer .dbody { overflow-y: auto; padding: 14px 18px 40px; flex: 1; }
#drawer .x { margin-left: auto; background: none; border: none; color: var(--fg2); font-size: 20px; cursor: pointer; padding: 0 4px; }
#drawer .x:hover { color: var(--fg); }
#drawer h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--fg3); margin: 20px 0 8px; }
#drawer h3:first-child { margin-top: 0; }
.kv { display: flex; gap: 18px; flex-wrap: wrap; margin: 8px 0; }
.kv .k { color: var(--fg3); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
.kv .v { font-size: 16px; font-weight: 600; }
.kv .v small { color: var(--fg2); font-weight: 400; font-size: 12px; }
.toolrow { padding: 6px 8px; border-radius: 6px; margin: 2px -8px; }
.toolrow:hover { background: #ffffff08; }
.toolrow.hl { background: #1f6feb2e; outline: 1px solid #1f6feb; }
.toolrow .tn { font-family: var(--mono); font-size: 13px; }
.toolrow .td { color: var(--fg2); font-size: 12.5px; margin-top: 1px; }
.toolrow .tq { color: var(--fg3); font-size: 12px; font-style: italic; margin-top: 2px; border-left: 2px solid var(--border); padding-left: 8px; }
.classgrouphdr {
  display: flex; align-items: center; gap: 8px; margin: 14px 0 4px; cursor: pointer;
}
.classgrouphdr .cname { font-family: var(--mono); font-size: 13px; font-weight: 600; }
.classgrouphdr .cnt { color: var(--fg3); font-size: 11.5px; }
.swatch { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.bar { height: 14px; border-radius: 3px; background: var(--bg3); overflow: hidden; display: flex; }
.bar > i { display: block; height: 100%; }
.namebar { display: grid; grid-template-columns: 170px 1fr 40px; gap: 8px; align-items: center; margin: 3px 0; font-size: 12.5px; }
.namebar .nm { font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; }
.namebar .n { color: var(--fg3); font-family: var(--mono); font-size: 11.5px; }
.fingerprint { display: inline-flex; gap: 1.5px; }
.fingerprint i { width: 8px; height: 14px; border-radius: 1.5px; background: #21262d; }
.gatelist { font-size: 12.5px; color: var(--fg2); }
.gatelist li { margin: 2px 0; }
details.tgroup { margin: 6px 0; }
details.tgroup summary { cursor: pointer; font-size: 13px; }
details.tgroup summary:hover { color: var(--accent); }
details.tgroup .inner { margin: 4px 0 8px 16px; }

/* ---------- cards (classes tab) ---------- */
.groupsec h2 { font-size: 14px; margin: 22px 0 10px; display: flex; align-items: center; gap: 8px; }
.cardgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.ccard {
  border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; cursor: pointer;
  background: var(--bg2); transition: border-color .1s;
}
.ccard:hover { border-color: var(--accent); }
.ccard .top { display: flex; align-items: baseline; gap: 8px; }
.ccard .code { font-family: var(--mono); font-weight: 700; font-size: 14px; }
.ccard .lbl { color: var(--fg2); font-size: 12.5px; }
.ccard .nums { margin: 8px 0 6px; color: var(--fg2); font-size: 12px; display: flex; gap: 14px; }
.ccard .nums b { color: var(--fg); font-size: 14px; }
.ccard .names { color: var(--fg3); font-size: 11.5px; font-family: var(--mono); margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- harness tab ---------- */
table.hlist { border-collapse: collapse; width: 100%; font-size: 13px; }
table.hlist th { text-align: left; color: var(--fg3); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; padding: 6px 10px; border-bottom: 1px solid var(--border); cursor: pointer; white-space: nowrap; position: sticky; top: 0; background: var(--bg); }
table.hlist th:hover { color: var(--fg); }
table.hlist td { padding: 5px 10px; border-bottom: 1px solid #21262d; }
table.hlist tbody tr { cursor: pointer; }
table.hlist tbody tr:hover { background: #ffffff08; }
table.hlist .hname { font-weight: 600; }
table.hlist .org { color: var(--fg3); font-size: 11.5px; }
table.hlist td.num { font-family: var(--mono); text-align: right; color: var(--fg2); }

/* ---------- tools tab ---------- */
table.tlist { border-collapse: collapse; width: 100%; font-size: 12.5px; }
table.tlist th { text-align: left; color: var(--fg3); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; padding: 6px 10px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg); }
table.tlist td { padding: 4px 10px; border-bottom: 1px solid #1c2129; vertical-align: top; }
table.tlist tr:hover td { background: #ffffff06; }
table.tlist .tool { font-family: var(--mono); white-space: nowrap; }
table.tlist .repo { white-space: nowrap; cursor: pointer; color: var(--accent); }
table.tlist .desc { color: var(--fg2); }

/* ---------- compare ---------- */
#comparetray {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
  background: var(--bg3); border-top: 1px solid var(--border);
  padding: 8px 18px; display: none; align-items: center; gap: 10px;
}
#comparetray.show { display: flex; }
table.cmp { border-collapse: collapse; font-size: 12.5px; width: 100%; }
table.cmp th, table.cmp td { border: 1px solid #21262d; padding: 6px 10px; vertical-align: top; text-align: left; }
table.cmp thead th { background: var(--bg2); position: sticky; top: 0; z-index: 5; }
table.cmp .clsname { font-family: var(--mono); white-space: nowrap; font-weight: 600; }
table.cmp td .t { font-family: var(--mono); font-size: 12px; display: inline-block; margin: 1px 6px 1px 0; }
table.cmp td .t.g { color: #e3b341; }
table.cmp tr.diff td { background: #2d1a0e33; }
table.cmp tr.samecnt td.clscell { }
table.cmp td.absent { color: var(--fg3); }
.cmpcards { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.cmpcard { border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; background: var(--bg2); min-width: 200px; }
.cmpcard .nm { font-weight: 700; }
.cmpcard .meta { color: var(--fg2); font-size: 12px; margin-top: 2px; }

/* ---------- overview ---------- */
.ovgrid { display: grid; grid-template-columns: 1.2fr .8fr; gap: 24px; align-items: start; }
@media (max-width: 1100px) { .ovgrid { grid-template-columns: 1fr; } }
.bignums { display: flex; gap: 26px; flex-wrap: wrap; margin: 10px 0 18px; }
.bignums .bn .v { font-size: 30px; font-weight: 700; }
.bignums .bn .k { color: var(--fg2); font-size: 12px; }
.adoptrow { display: grid; grid-template-columns: 110px 1fr 88px; gap: 10px; align-items: center; margin: 2.5px 0; cursor: pointer; }
.adoptrow:hover .code { color: var(--accent); }
.adoptrow .code { font-family: var(--mono); font-size: 12px; text-align: right; }
.adoptrow .n { font-size: 11px; color: var(--fg3); font-family: var(--mono); }
.panel { border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; background: var(--bg2); margin-bottom: 16px; }
.panel h2 { margin: 0 0 10px; font-size: 15px; }
.panel p { color: var(--fg2); font-size: 13px; }
.tryit { display: flex; flex-direction: column; gap: 6px; }
.tryit a { font-size: 13px; }
.histo { display: flex; align-items: flex-end; gap: 3px; height: 90px; margin: 10px 0 4px; }
.histo .hb { background: #388bfd66; border: 1px solid #388bfd; border-radius: 2px 2px 0 0; flex: 1; min-width: 10px; position: relative; cursor: default; }
.histo .hb:hover { background: #388bfdaa; }
.histolbl { display: flex; gap: 3px; color: var(--fg3); font-size: 10px; }
.histolbl span { flex: 1; text-align: center; min-width: 10px; }
.mutedlist { color: var(--fg2); font-size: 13px; }
.mutedlist b { color: var(--fg); }
kbd { background: var(--bg3); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; font-size: 11px; font-family: var(--mono); }
.footer-note { color: var(--fg3); font-size: 11.5px; margin-top: 26px; }

/* ---------- atlas integration (ported from :8000) ---------- */
.cluster-map { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; margin: 4px 0 14px; }
.cbox { background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; cursor: pointer; transition: border-color .15s; }
.cbox:hover { border-color: var(--accent); }
.cbox.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.cbox h3 { margin: 0 0 3px; font-size: 12.5px; color: #76e3ea; }
.cbox .cnt { color: var(--fg3); font-size: 11.5px; }
.cbox .top { font-size: 11.5px; color: var(--fg2); margin-top: 4px; }
.flag { font-size: 11px; border-radius: 4px; padding: 1px 5px; margin-left: 6px; vertical-align: 2px; font-weight: 400; }
.f-warn { background: #4a3a12; color: #fbbf24; }
.f-dead { background: #4a1f1f; color: #f87171; }
.f-vendor { background: #12304a; color: #7dd3fc; }
.f-stalled { background: #3a3a3a; color: #d4d4d8; }
.coh { font-size: 10.5px; font-weight: 700; font-family: var(--mono, monospace); border: 1px solid var(--cc); color: var(--cc); border-radius: 4px; padding: 0 4px; margin-left: 6px; vertical-align: 1px; }
table.atlas .stars { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; color: #eac54f; }
table.atlas .tool { font-weight: 600; white-space: nowrap; }
table.atlas .tool a { color: inherit; }
table.atlas .cl { font-size: 11.5px; color: var(--fg2); max-width: 210px; }
table.atlas .desc { color: var(--fg2); font-size: 12px; min-width: 260px; }
table.atlas .nosurf { color: var(--fg3); font-size: 11.5px; font-style: italic; }
table.atlas tbody tr { cursor: pointer; }
tr.shelleyrow td { background: #12362a !important; border-top: 1px solid #7ee787; border-bottom: 1px solid #7ee787; }
#semmap .dot:hover { outline: 2px solid #fff !important; z-index: 20; }
.demolink { display: inline-block; margin: 4px 14px 2px 0; font-size: 13px; cursor: pointer; padding: 3px 10px; border: 1px solid #1f6feb; border-radius: 6px; background: #1f6feb22; }
.demolink:hover { background: #1f6feb44; text-decoration: none; }
.oppbadge { font-size: 10px; text-transform: uppercase; letter-spacing: .8px; background: #238636; color: #fff; border-radius: 8px; padding: 2px 8px; vertical-align: 3px; }
.panel ol li { margin: 3px 0; }
