:root{
  --bg:#ffffff;
  --fg:#111827;
  --muted:#6b7280;
  --border:#e5e7eb;

  /* heatmap endpoints */
  --cell-min:#f6f8ff;
  --cell-max:#173a8a;
  --cell-missing:#f3f4f6;

  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono","Courier New", monospace;
  --sans: system-ui,-apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
}

*{box-sizing:border-box}
body{
  margin:0;
  padding:18px;
  font-family:var(--sans);
  color:var(--fg);
  background:var(--bg);
}
a{color:#2563eb;text-decoration:none}
a:hover{text-decoration:underline}
h1{margin:0 0 6px 0;font-size:22px}
.muted{color:var(--muted)}
.help{margin-top:10px}

.page-header{margin-bottom:14px}
.header-row{display:flex;align-items:baseline;justify-content:space-between;gap:12px;flex-wrap:wrap}
.header-nav{display:flex;gap:10px;align-items:center}

.controls{
  border:1px solid var(--border);
  border-radius:10px;
  padding:12px;
  margin:12px 0 14px 0;
}
.controls-row{
  display:flex;
  flex-wrap:wrap;
  gap:10px 14px;
  align-items:end;
}
.controls label{
  display:flex;
  flex-direction:column;
  gap:6px;
  font-size:12px;
  color:var(--muted);
}
.controls input, .controls select{
  font-size:14px;
  padding:6px 8px;
  border:1px solid var(--border);
  border-radius:8px;
  min-height:34px;
}
.controls input[type="number"]{width:9em}
.controls input[type="search"]{width:20em;max-width:60vw}

.controls button{
  font-size:14px;
  padding:7px 10px;
  border:1px solid var(--border);
  border-radius:8px;
  background:#111827;
  color:white;
  cursor:pointer;
  min-height:34px;
}
.controls button.secondary{
  background:white;
  color:var(--fg);
}
.controls button:hover{filter:brightness(0.97)}

.legend-row{margin-top:10px}
.legend{
  display:flex;
  align-items:center;
  gap:8px;
  font-size:12px;
  color:var(--muted);
}
.legend-bar{
  width:180px;
  height:10px;
  border-radius:999px;
  border:1px solid var(--border);
}

.table-wrap{
  border:1px solid var(--border);
  border-radius:10px;
  overflow:auto;
  max-height:75vh;
}

table.grid{
  border-collapse:collapse;
  width:max-content;
  min-width:100%;
}
table.grid th, table.grid td{
  border:1px solid var(--border);
  padding:6px 8px;
  text-align:center;
  min-width:72px;
  vertical-align:middle;
  background:white;
}
table.grid th.corner{
  min-width:84px;
  font-weight:600;
}
table.grid th.colhead{
  font-weight:600;
}
table.grid th.rowhead{
  font-weight:600;
}
table.grid td.missing{
  background:var(--cell-missing);
}
table.grid td.cell{
  cursor:default;
}
table.grid td.cell.clickable{
  cursor:pointer;
}
.cell-d{
  font-size:16px;
  font-weight:700;
  line-height:1.15;
}
.cell-g{
  margin-top:2px;
  font-size:11px;
  opacity:0.9;
  line-height:1.15;
  white-space:nowrap;
}
.cell-ties{
  margin-top:2px;
  font-size:10px;
  opacity:0.85;
}

/* sticky header + first column */
table.grid thead th{
  position:sticky;
  top:0;
  z-index:3;
}
table.grid tbody th{
  position:sticky;
  left:0;
  z-index:2;
}
table.grid thead th.corner{
  left:0;
  z-index:4;
}

/* list table */
.list-wrap{
  border:1px solid var(--border);
  border-radius:10px;
  overflow:auto;
}
table.list{
  border-collapse:collapse;
  width:100%;
}
table.list th, table.list td{
  border-bottom:1px solid var(--border);
  padding:8px 10px;
  text-align:left;
  font-size:14px;
}
table.list th{
  position:sticky;
  top:0;
  background:white;
  z-index:2;
  cursor:pointer;
  user-select:none;
}
table.list tr:hover td{
  background:#fafafa;
}
code, pre{
  font-family:var(--mono);
}
pre{
  background:#0b1020;
  color:#e5e7eb;
  padding:12px;
  border-radius:10px;
  overflow:auto;
  max-height:50vh;
}

/* modal */
.modal{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.35);
  display:flex;
  align-items:center;
  justify-content:center;
  padding:18px;
  z-index:9999;
}
.modal.hidden{display:none}
.modal-content{
  width:min(980px, 96vw);
  max-height:92vh;
  overflow:auto;
  background:white;
  border-radius:12px;
  border:1px solid var(--border);
  box-shadow:0 20px 60px rgba(0,0,0,.25);
}
.modal-header{
  display:flex;
  justify-content:space-between;
  gap:12px;
  padding:12px 14px;
  border-bottom:1px solid var(--border);
  align-items:flex-start;
}
.modal-title{font-size:16px;font-weight:700}
.modal-sub{font-size:12px}
.modal-close{
  font-size:22px;
  line-height:18px;
  border:none;
  background:transparent;
  cursor:pointer;
  padding:2px 6px;
  color:var(--muted);
}
.modal-close:hover{color:var(--fg)}
.modal-body{padding:14px}
.badge{
  display:inline-block;
  font-size:12px;
  padding:2px 8px;
  border:1px solid var(--border);
  border-radius:999px;
  color:var(--muted);
  margin-left:8px;
}
