:root {
  --bg: #04060d; --panel: rgba(9, 12, 20, 0.88); --border: rgba(77, 97, 140, 0.35); --text: #dfe5f0; --dim: #8b95a8;
  --accent: #6c9cff; --button: #2754c0; --button-hover: #3a6be6; --rep: #f26666; --dem: #739eff; --warn: #ffd866; --bad: #ff7259; --cyan: #73e0ff;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text);
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, sans-serif; }
canvas#gl { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; }
.panel { position: fixed; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px;
  backdrop-filter: blur(6px); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); }
.hidden { display: none !important; }
body.noui .panel { display: none !important; }

#control { left: 16px; top: 16px; width: 380px; max-height: calc(100vh - 230px); overflow-y: auto; }
#anomalies { right: 16px; top: 16px; width: 540px; height: 380px; display: flex; flex-direction: column; }
#donor { right: 16px; top: 412px; width: 600px; bottom: 16px; overflow-y: auto; }
#legend { left: 16px; bottom: 16px; max-width: 640px; font-size: 12.5px; }

h1 { font-size: 22px; margin: 0 0 2px; font-weight: 700; }
h2 { font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); margin: 14px 0 6px;
  border-bottom: 1px solid var(--border); padding-bottom: 3px; font-weight: 600; }
h3 { font-size: 16px; margin: 12px 0 4px; }
.title { font-weight: 600; margin-bottom: 6px; }
.sub, .dim { color: var(--dim); font-size: 12.5px; }
.err { color: var(--bad); font-size: 12.5px; }
.warn { color: var(--warn); }
.r { color: var(--rep); } .d { color: var(--dem); } .cyan { color: var(--cyan); } .orange { color: #ff9e40; }
.row { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin: 4px 0; }
select, input[type=text], input:not([type]), button { font: inherit; color: var(--text); background: rgba(25, 33, 52, 0.9);
  border: 1px solid transparent; border-radius: 6px; padding: 5px 9px; }
select { width: 100%; margin: 4px 0; }
input:not([type]) { flex: 1; min-width: 0; }
button { background: var(--button); cursor: pointer; font-weight: 600; }
button:hover { background: var(--button-hover); }
button.small { padding: 1px 7px; font-size: 12px; font-weight: 500; }
.slider { display: grid; grid-template-columns: 120px 1fr 54px; align-items: center; gap: 8px; margin: 3px 0; font-size: 13px; color: var(--dim); }
.slider span { text-align: right; color: var(--text); font-variant-numeric: tabular-nums; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.progress { position: relative; height: 22px; border-radius: 6px; background: rgba(25, 33, 52, 0.9); overflow: hidden; margin: 4px 0; }
.progress div { position: absolute; inset: 0 auto 0 0; background: #e8892c; }
.progress span { position: relative; display: block; text-align: center; font-size: 12.5px; line-height: 22px; }
.list { max-height: 150px; overflow-y: auto; background: rgba(25, 33, 52, 0.6); border-radius: 6px; margin: 4px 0; }
.list div { padding: 3px 8px; cursor: pointer; font-size: 13px; }
.list div:hover, .list div.on { background: rgba(58, 107, 230, 0.55); }
details summary { cursor: pointer; margin-top: 10px; padding: 4px 8px; background: rgba(39, 84, 192, 0.55); border-radius: 6px; }
.keys { line-height: 1.7; padding: 6px 4px; }

.tabs { display: flex; gap: 4px; margin: 4px 0 6px; border-bottom: 1px solid var(--accent); }
.tabs button { background: rgba(25, 37, 61, 0.9); font-weight: 500; border-radius: 6px 6px 0 0; padding: 4px 10px; }
.tabs button.on { background: var(--button); }
.scroll { overflow-y: auto; flex: 1; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { position: sticky; top: 0; background: #121a2b; text-align: left; font-weight: 600; padding: 4px 6px; cursor: default; white-space: nowrap; }
th.sort { cursor: pointer; }
th.sort:hover { color: var(--accent); }
td { padding: 3px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
tbody tr:nth-child(even) { background: rgba(255, 255, 255, 0.03); }
tbody tr.pick { cursor: pointer; }
tbody tr.pick:hover, tbody tr.on { background: rgba(58, 107, 230, 0.45); }
.plus { color: var(--cyan); margin-left: 6px; }
.tablebox { max-height: 300px; overflow-y: auto; margin: 4px 0 8px; }

#donor .name { font-size: 20px; font-weight: 600; }
#donor .close { position: sticky; top: 0; float: right; background: none; font-size: 18px; padding: 0 4px; }
#donor .big { font-size: 16px; font-weight: 600; }
#donor canvas { width: 100%; display: block; margin: 6px 0; }
.bars { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.bars canvas { height: 70px; background: rgba(25, 33, 52, 0.6); border-radius: 6px; }
.badge { color: var(--warn); font-size: 11.5px; margin-left: 4px; }

#tooltip { position: fixed; pointer-events: none; background: rgba(9, 12, 20, 0.95); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font-size: 13px; z-index: 10; max-width: 340px; }
#tooltip .name { font-weight: 600; font-size: 15px; }
#fatal { position: fixed; inset: 30% 20%; background: #300; color: #fcc; padding: 20px; border-radius: 10px; white-space: pre-wrap; z-index: 20; }
.swatch { display: inline-block; width: 11px; height: 11px; border-radius: 2px; margin: 0 5px 0 12px; vertical-align: -1px; }
.gradient { height: 12px; border-radius: 3px; margin: 6px 0 2px; width: 420px;
  background: linear-gradient(90deg, #7d2785 0%, #ad3179 20%, #d6394e 40%, #ed5a36 58%, #f08e29 76%, #f4c41a 100%); }
.ticks { display: flex; justify-content: space-between; width: 420px; color: var(--dim); }

/* ---------------------------------------------------------------- lifetime presentation */
canvas#overlay { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; }
.pres { position: fixed; }
body.lifetime .panel { display: none !important; }
body:not(.lifetime) #presHeader, body:not(.lifetime) #presFooter, body:not(.lifetime) #presCommittee,
body:not(.lifetime) #presCycle, body:not(.lifetime) #presPlay, body:not(.lifetime) #presStatus, body:not(.lifetime) canvas#overlay { display: none !important; }
body.noui .pres { display: none !important; }
#presHeader { left: 0; right: 0; top: 0; padding: 6px 14px 8px; background: linear-gradient(rgba(9, 12, 20, 0.92), rgba(9, 12, 20, 0.75));
  border-bottom: 1px solid rgba(77, 97, 140, 0.25); font-size: 14px; color: #c4cbd8; }
.presTitle { font-size: 24px; font-weight: 700; color: #fff; line-height: 1.1; }
#presBar { right: 14px; top: 10px; display: flex; gap: 6px; z-index: 5; }
#presBar select { width: auto; margin: 0; }
body:not(.lifetime) #presBar { top: auto; bottom: 16px; right: 50%; transform: translateX(50%); }
#presStatus { left: 50%; top: 45%; transform: translate(-50%, -50%); background: rgba(9, 12, 20, 0.9); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px 18px; max-width: 640px; text-align: center; }
#presFooter { left: 0; right: 0; bottom: 0; padding: 6px 14px; background: linear-gradient(rgba(9, 12, 20, 0.6), rgba(9, 12, 20, 0.92));
  border-top: 1px solid rgba(77, 97, 140, 0.25); font-size: 13.5px; color: #c4cbd8; }
#presLegend span.sw { display: inline-block; width: 12px; height: 12px; border-radius: 2px; margin: 0 5px 0 14px; vertical-align: -1px; }
#presLegend span.sw:first-child { margin-left: 0; }
#presMethod { font-size: 12.5px; color: #8b95a8; margin-top: 2px; }
#presCustom { right: 14px; top: 52px; width: 460px; max-width: calc(100vw - 32px); z-index: 6; background: rgba(9, 12, 20, 0.95);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px; }
#presCustom .row { display: flex; gap: 6px; }
#presCustom input { flex: 1; margin: 0; }
#presHits { max-height: 340px; overflow-y: auto; }
#presHits div { padding: 4px 6px; cursor: pointer; border-radius: 4px; }
#presHits div:hover { background: rgba(77, 128, 255, 0.18); }
body:not(.lifetime) #presCustom { display: none !important; }

/* ---------------------------------------------------------------- X links / support */
.siteLinks { display: flex; gap: 14px; align-items: center; font-size: 13.5px; }
.siteLinks a { color: var(--text); text-decoration: none; display: inline-flex; align-items: center; gap: 5px; opacity: 0.85; }
.siteLinks a:hover { opacity: 1; color: #fff; text-decoration: underline; }
.siteLinks .xlogo { width: 13px; height: 13px; fill: currentColor; }
.siteLinks a.support { border: 1px solid var(--border); border-radius: 6px; padding: 1px 9px; }
#siteLinks { position: absolute; right: 14px; top: 52px; }
.siteLinks.inPanel { margin: 6px 0 8px; flex-wrap: wrap; gap: 12px; }
@media (max-width: 1100px) { #siteLinks { position: static; margin-top: 4px; } }
.siteLinks .visitCount { color: #fff; font-size: 13.5px; font-weight: 600; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px;
  background: rgba(108, 156, 255, 0.16); border: 1px solid rgba(108, 156, 255, 0.45); border-radius: 999px; padding: 1px 10px 1px 8px; }
.siteLinks .visitCount::before { content: ""; width: 15px; height: 15px; flex: none; background: var(--accent);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 5C6.5 5 2.7 9.4 1.5 12c1.2 2.6 5 7 10.5 7s9.3-4.4 10.5-7C21.3 9.4 17.5 5 12 5zm0 11.5A4.5 4.5 0 1 1 12 7.5a4.5 4.5 0 0 1 0 9zm0-2.5a2 2 0 1 0 0-4 2 2 0 0 0 0 4z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 5C6.5 5 2.7 9.4 1.5 12c1.2 2.6 5 7 10.5 7s9.3-4.4 10.5-7C21.3 9.4 17.5 5 12 5zm0 11.5A4.5 4.5 0 1 1 12 7.5a4.5 4.5 0 0 1 0 9zm0-2.5a2 2 0 1 0 0-4 2 2 0 0 0 0 4z'/%3E%3C/svg%3E") center / contain no-repeat; }
#presLine1, #presLine2 { max-width: calc(100% - 660px); }
@media (max-width: 1100px) { #presLine1, #presLine2 { max-width: none; } }
.siteLinks .visitCount:empty { display: none; }
