:root {
  --bg: #0a0b0e;
  --bg-elev: #14161c;
  --bg-row: #12141a;
  --bg-row-alt: #0e1015;
  --bg-cell: transparent;
  --bg-cell-hover: #1c2029;
  --fg: #ebecf0;
  --fg-dim: #8b919e;
  --fg-faint: #5d626d;
  --border: #1e222b;
  --border-soft: #15181f;
  --accent: #5aa9ff;
  --yes: #4ade80;
  --no: #f87171;
  --partial: #f5b942;
  --unknown: #6b7280;
  --na: #3f4350;
  --radius: 12px;
  --radius-sm: 6px;
  --shadow: 0 12px 40px rgba(0,0,0,0.6);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background:
    radial-gradient(1100px 600px at 20% -10%, rgba(90,169,255,0.05), transparent 60%),
    radial-gradient(900px 500px at 90% 0%, rgba(74,222,128,0.035), transparent 60%),
    var(--bg);
  color: var(--fg);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code {
  font: 12px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--bg-elev);
  padding: 1px 6px;
  border-radius: 4px;
}

/* ------------ header ------------ */
header {
  padding: 22px 24px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.masthead h1 {
  margin: 0 0 4px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.masthead h1 .muted { color: var(--fg-dim); font-weight: 400; }
.subtitle {
  margin: 0 0 16px;
  color: var(--fg-dim);
  font-size: 13px;
}

.controls {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
}

#search {
  flex: 0 0 280px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--fg);
  font: inherit;
  padding: 9px 13px;
  outline: none;
  transition: border-color 0.15s;
}
#search:focus { border-color: var(--accent); }
#search::placeholder { color: var(--fg-faint); }

/* filter dropdown — collapses 6 chips into one summary button */
.filter-dd { position: relative; flex: 0 0 auto; }
.filter-dd > summary {
  list-style: none;
  cursor: pointer;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--fg);
  font: inherit;
  font-size: 12.5px;
  padding: 7px 14px 7px 13px;
  border-radius: 999px;
  user-select: none;
  white-space: nowrap;
}
.filter-dd > summary::-webkit-details-marker { display: none; }
.filter-dd > summary::after {
  content: "▾";
  margin-left: 6px;
  color: var(--fg-dim);
  font-size: 10px;
}
.filter-dd[open] > summary {
  background: var(--accent);
  border-color: var(--accent);
  color: #0a0b0e;
}
.filter-dd[open] > summary::after { color: #0a0b0e; }
.filter-dd .filter-dd-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 60;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 260px;
  box-shadow: var(--shadow);
}

.filter-chip {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--fg-dim);
  font: inherit;
  font-size: 12.5px;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.12s;
  user-select: none;
}
.filter-chip:hover { color: var(--fg); border-color: var(--fg-faint); }
.filter-chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #0a0b0e;
  font-weight: 600;
}

.legend {
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 11.5px;
  color: var(--fg-dim);
  white-space: nowrap;
}
.legend .lk { display: inline-flex; align-items: center; gap: 4px; }
.legend .lk i {
  width: 8px; height: 8px; border-radius: 50%; display: inline-block;
}
.legend .lk.yes i      { background: var(--yes); }
.legend .lk.no i       { background: var(--no); }
.legend .lk.partial i  { background: var(--partial); }
.legend .lk.unknown i  { background: var(--unknown); }
.legend .lk.na i       { background: var(--na); }

.profiles { display: flex; gap: 6px; flex: 0 0 auto; }
.profile-chip {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--fg-dim);
  font: inherit;
  font-size: 12.5px;
  padding: 7px 13px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.12s;
  user-select: none;
}
.profile-chip:hover { color: var(--fg); border-color: var(--fg-faint); }
.profile-chip[aria-pressed="true"] {
  background: var(--partial);
  border-color: var(--partial);
  color: #0a0b0e;
  font-weight: 600;
}

/* rank badge on column header */
.rank-badge {
  position: absolute;
  top: 6px;
  right: 8px;
  background: var(--bg);
  color: var(--fg-dim);
  border: 1px solid var(--border);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  letter-spacing: 0.04em;
  min-width: 22px;
  text-align: center;
}
.rank-badge.rank-1,
.rank-badge.rank-2,
.rank-badge.rank-3 {
  background: var(--partial);
  color: #0a0b0e;
  border-color: var(--partial);
  font-weight: 700;
}
thead th.app .col-head { position: relative; }
thead th.app.ranked-1 { background: linear-gradient(180deg, rgba(245,185,66,0.10), var(--bg-elev)); }
thead th.app.ranked-2 { background: linear-gradient(180deg, rgba(245,185,66,0.06), var(--bg-elev)); }
thead th.app.ranked-3 { background: linear-gradient(180deg, rgba(245,185,66,0.04), var(--bg-elev)); }

/* row emphasized when profile weights it */
tbody tr.row-emphasized th.row-label {
  border-left: 3px solid var(--partial);
  padding-left: 11px;
}
tbody tr.row-emphasized th.row-label::after {
  content: "★";
  margin-left: 6px;
  color: var(--partial);
  font-size: 10px;
  vertical-align: middle;
}

/* ------------ main ------------ */
main { padding: 0 0 24px; }

/* horizontal scroll lives inside .table-wrap only — the header above stays
   put while the matrix slides under it. No vertical overflow (height = content)
   so the page scrolls vertically naturally. */
.table-wrap {
  overflow-x: auto;
  border-top: 1px solid var(--border);
}

/* ------------ matrix table ------------ */
table#matrix {
  border-collapse: separate;
  border-spacing: 0;
  width: max-content;
  min-width: 100%;
  font-size: 12.5px;
}

/* corner cell — sticks only on horizontal scroll */
thead th.corner {
  position: sticky;
  left: 0;
  z-index: 20;
  background: var(--bg-elev);
  color: var(--fg-dim);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 14px 16px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  min-width: 240px;
  text-align: left;
}

/* app column header — scrolls normally on vertical */
thead th.app {
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  padding: 14px 14px 12px;
  min-width: 180px;
  max-width: 200px;
}
thead th.app .col-head {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
  font-weight: 400;
  text-align: left;
}
thead th.app .logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--bg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
thead th.app .logo img {
  width: 26px;
  height: 26px;
  object-fit: contain;
  filter: brightness(0) invert(1);
}
thead th.app .logo.logo-colored img { filter: none; }
thead th.app .logo .letter {
  font-size: 18px;
  font-weight: 700;
  color: #0a0b0e;
  width: 100%;
  height: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
thead th.app .nm {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--fg);
  letter-spacing: -0.005em;
}
thead th.app .jur {
  font-size: 11px;
  color: var(--fg-dim);
}

/* row label */
tbody th.row-label {
  position: sticky;
  left: 0;
  z-index: 10;
  background: var(--bg-row);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border-soft);
  padding: 10px 14px;
  text-align: left;
  font-weight: 500;
  color: var(--fg);
  vertical-align: top;
  min-width: 240px;
  max-width: 280px;
}
tbody th.row-label .row-num {
  display: block;
  font-size: 10.5px;
  color: var(--fg-faint);
  font-weight: 400;
  margin-bottom: 1px;
}

tbody tr:nth-child(even) th.row-label { background: var(--bg-row-alt); }
tbody tr:nth-child(even) td.cell { background-color: rgba(255,255,255,0.012); }

/* data cells */
tbody td.cell {
  vertical-align: top;
  padding: 9px 12px 9px 14px;
  border-bottom: 1px solid var(--border-soft);
  min-width: 180px;
  max-width: 220px;
  position: relative;
}

.cell-inner {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.cell-dot {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 6px;
  background: var(--na);
}
td.cell.s-yes      .cell-dot { background: var(--yes); }
td.cell.s-no       .cell-dot { background: var(--no); }
td.cell.s-partial  .cell-dot { background: var(--partial); }
td.cell.s-unknown  .cell-dot { background: var(--unknown); }
td.cell.s-na       .cell-dot { background: var(--na); }
td.cell.s-text     .cell-dot { background: var(--accent); opacity: 0.45; }

.cell-content { flex: 1; min-width: 0; }
.cell-val {
  line-height: 1.4;
  color: var(--fg);
  font-size: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
td.cell.s-no .cell-val { color: var(--fg-dim); }
td.cell.s-na .cell-val,
td.cell.s-unknown .cell-val { color: var(--fg-faint); font-style: italic; }

.cell-srcs {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 5px;
}
a.cell-src {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  font-size: 11px;
  line-height: 1;
  color: var(--fg-dim);
  text-decoration: none;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  transition: all 0.1s;
}
a.cell-src:hover {
  background: var(--accent);
  color: #0a0b0e;
  border-color: var(--accent);
}

tr.row-hidden, td.col-hidden, th.col-hidden { display: none; }

/* row group divider — every 6 rows for readability */
tbody tr.divider th.row-label,
tbody tr.divider td.cell { border-top: 1px solid var(--border); }

/* ------------ responsive ------------ */
@media (max-width: 720px) {
  header { padding: 18px 14px 12px; }
  .masthead h1 { font-size: 20px; }
  thead th.app { min-width: 150px; max-width: 170px; }
  thead th.corner, tbody th.row-label { min-width: 170px; max-width: 200px; }
  tbody td.cell { min-width: 150px; max-width: 180px; }
  dialog article { padding: 16px 18px 20px; }
}
