:root {
  --bg: #0d1117;
  --panel: #11161d;
  --panel2: #161c25;
  --line: #243040;
  --text: #d7dde6;
  --muted: #8a98aa;
  --accent: #f5c84b; /* Shell-ish amber */
  --accent2: #e23b3b;
  --green: #3fb950;
  --grey: #3a4452;
  --blue: #5aa9e6;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
}
body {
  background: var(--bg);
  color: var(--text);
  font:
    14px/1.45 -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    sans-serif;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* top bar */
#topbar {
  height: 52px;
  flex: 0 0 52px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  z-index: 20;
}
.brand {
  font-weight: 600;
  letter-spacing: 0.2px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}
.tag-pill {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 2px 8px;
  border-radius: 20px;
  margin-left: 6px;
}

#searchwrap {
  position: relative;
  margin-left: auto;
  width: 360px;
}
#search {
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--text);
  outline: none;
}
#search:focus {
  border-color: var(--accent);
}
#results {
  position: absolute;
  top: 40px;
  left: 0;
  right: 0;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  display: none;
  z-index: 30;
  max-height: 320px;
  overflow-y: auto;
}
#results.show {
  display: block;
}
.result {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
}
.result:last-child {
  border-bottom: 0;
}
.result:hover {
  background: #1d2530;
}
.result b {
  color: var(--accent);
  font-weight: 600;
}
.result span {
  color: var(--muted);
  font-size: 12px;
}
.result.geo b {
  color: var(--muted);
} /* tagged in the model, no ops record */
.result.geo span {
  font-style: italic;
  opacity: 0.85;
}

/* RECORDS panel (left sidebar) */
#records { position: absolute; left: 14px; top: 14px; bottom: 14px; width: 320px; z-index: 15;
  display: flex; flex-direction: column; background: rgba(17,22,29,.94);
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
#records.collapsed { width: auto; bottom: auto; }
#records.collapsed .rec-body { display: none; }
#records.collapsed .rec-title { display: none; }
.rec-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
#records.collapsed .rec-head { border-bottom: 0; }
.rec-title { flex: 1; font-size: 12px; text-transform: uppercase; letter-spacing: .9px; color: var(--muted); font-weight: 600; }
#rec-toggle { background: var(--panel2); color: var(--text); border: 1px solid var(--line);
  border-radius: 7px; width: 30px; height: 28px; cursor: pointer; font-size: 14px; }
#rec-toggle:hover { border-color: var(--accent); }
.rec-body { display: flex; flex-direction: column; min-height: 0; flex: 1; }
#rec-tabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px 6px; }
.rec-tab { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: 16px;
  border: 1px solid var(--line); background: var(--panel2); color: var(--muted); font-size: 12.5px; cursor: pointer; }
.rec-tab:hover { color: var(--text); }
.rec-tab.on { color: var(--text); border-color: currentColor; }
.rec-tab .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; box-shadow: 0 0 6px currentColor; }
.rec-tab .n { font-variant-numeric: tabular-nums; background: rgba(255,255,255,.08); border-radius: 9px; padding: 0 6px; font-size: 11px; color: var(--text); }
.rec-focus { display: flex; align-items: center; gap: 8px; padding: 4px 12px 8px; color: var(--muted); font-size: 12px; cursor: pointer; user-select: none; }
.rec-focus input { accent-color: var(--accent); margin: 0; }
#rec-list { flex: 1; overflow-y: auto; padding: 4px 12px 12px; display: flex; flex-direction: column; gap: 8px; }
.rec-card { border: 1px solid var(--line); border-left: 3px solid var(--grey); border-radius: 9px;
  padding: 9px 11px; cursor: pointer; background: var(--panel); }
.rec-card:hover { background: #1a212b; }
.rec-card .top { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--muted); font-family: ui-monospace, monospace; }
.rec-card .mid { margin: 5px 0 3px; display: flex; align-items: center; gap: 7px; }
.rec-card .ttl { font-size: 13.5px; color: var(--text); }
.rec-card .sub { font-size: 11.5px; color: var(--muted); font-family: ui-monospace, monospace; }
.rec-empty { color: var(--muted); font-size: 12px; padding: 8px 2px; }
.rec-note { padding: 10px 2px; font-size: 12px; color: #ff9b6b; line-height: 1.4; }

/* severity / priority pills */
.pill { font-size: 10.5px; font-weight: 600; padding: 1px 8px; border-radius: 6px; white-space: nowrap; }
.pill.Critical { color: #ff6b6b; background: #2a1620; border: 1px solid #5a2330; }
.pill.High { color: #ffb454; background: #2a2116; border: 1px solid #5a4523; }
.pill.Medium { color: var(--accent); background: #262016; border: 1px solid #4a3c18; }
.pill.Low { color: var(--green); background: #14271a; border: 1px solid #1d3a26; }
.pill.render { color: #ff6b6b; background: #2a1620; border: 1px solid #5a2330; }
.pill.overdue { color: #ff6b6b; background: transparent; border: 0; font-weight: 700; }

/* risk block in the fact sheet */
.risk-hd { padding: 14px 18px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg,#1a1420,#11161d); }
.risk-hd .score { display: flex; align-items: baseline; gap: 12px; }
.risk-hd .num { font-size: 40px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.risk-hd .renders { font-size: 11px; color: #ff6b6b; display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; letter-spacing: .5px; }
.risk-hd .renders::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #ff6b6b; box-shadow: 0 0 8px #ff6b6b; }
.drivers { padding: 12px 18px; border-bottom: 1px solid var(--line); }
.drivers h3, .rsec h3 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
.bar-row { margin: 8px 0; }
.bar-row .lab { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 4px; }
.bar-row .lab .v { color: var(--muted); font-variant-numeric: tabular-nums; }
.bar-track { height: 7px; border-radius: 5px; background: #1c2430; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 5px; }
.rsec { padding: 12px 18px; border-bottom: 1px solid var(--line); }
.rsec .rc { border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; margin-top: 8px; }
.rsec .rc .r1 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.rsec .rc .r2 { font-size: 11.5px; color: var(--muted); font-family: ui-monospace, monospace; margin-top: 4px; }
.rsec .rc .nm { font-size: 13px; color: var(--text); }

/* stage */
#stage {
  flex: 1;
  display: flex;
  position: relative;
  min-height: 0;
}
#viewer {
  flex: 1;
  position: relative;
}
#viewer canvas {
  display: block;
}
#hint {
  position: absolute;
  left: 16px;
  bottom: 14px;
  color: var(--muted);
  font-size: 12px;
  background: rgba(13, 17, 23, 0.7);
  padding: 6px 10px;
  border-radius: 6px;
}
#loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  pointer-events: none;
}

/* panel */
#panel {
  width: 380px;
  flex: 0 0 380px;
  background: var(--panel);
  border-left: 1px solid var(--line);
  overflow-y: auto;
}
#panel-empty {
  padding: 24px;
  color: var(--muted);
}
#panel-empty h2 {
  color: var(--text);
  font-size: 15px;
  margin: 0 0 8px;
}
#panel.empty #panel-content {
  display: none;
}

.ph {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #161c25, #11161d);
}
.ph .tagname {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.3px;
}
.ph .desc {
  color: var(--text);
  margin-top: 2px;
}
.ph .floc {
  color: var(--muted);
  font-size: 12px;
  margin-top: 6px;
  font-family: ui-monospace, monospace;
}
.ph .chips {
  margin-top: 10px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.chip {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.chip.crit-High {
  color: #ff6b6b;
  border-color: #5a2330;
  background: #2a1620;
}
.chip.crit-Medium {
  color: var(--accent);
  border-color: #4a3c18;
}
.chip.crit-Low {
  color: var(--green);
  border-color: #1d3a26;
}

/* provenance */
.prov {
  display: flex;
  gap: 6px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.src {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.src::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--grey);
}
.src.on {
  color: var(--text);
  border-color: #1d3a26;
}
.src.on::before {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}
.src.miss {
  color: #ff9b6b;
  border-color: #5a3a23;
}
.src.miss::before {
  background: #ff9b6b;
}

/* sections */
.sec {
  border-bottom: 1px solid var(--line);
}
.sec h3 {
  margin: 0;
  padding: 12px 18px 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
}
.sec .body {
  padding: 4px 18px 16px;
}

.kv {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
}
.kv .k {
  color: var(--muted);
}
.kv .v {
  text-align: right;
  color: var(--text);
}

/* live */
.live {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 0;
}
.live .val {
  font-size: 30px;
  font-weight: 700;
  color: var(--blue);
  font-variant-numeric: tabular-nums;
}
.live .uom {
  color: var(--muted);
}
.live .status {
  margin-left: auto;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 6px;
}
.status.Good {
  color: var(--green);
  background: #14271a;
}
.status.Bad,
.status.Questionable {
  color: #ff6b6b;
  background: #2a1620;
}
.spark {
  width: 100%;
  height: 46px;
  margin-top: 4px;
}
.rng {
  color: var(--muted);
  font-size: 11px;
  display: flex;
  justify-content: space-between;
}

/* tables */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
th,
td {
  text-align: left;
  padding: 5px 6px;
  border-bottom: 1px solid #1b232e;
  vertical-align: top;
}
th {
  color: var(--muted);
  font-weight: 500;
}
.wo-OPEN,
.wo-INPROGRESS {
  color: var(--accent);
}
.wo-CLOSED {
  color: var(--muted);
}
.docrow a {
  color: var(--blue);
  text-decoration: none;
}
.docrow a:hover {
  text-decoration: underline;
}
.catpill {
  font-size: 10px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1px 6px;
}
.count {
  color: var(--muted);
  font-weight: 400;
}
.empty-note {
  color: var(--muted);
  font-size: 12px;
  padding: 2px 0;
}
