/* Tool pages (/inspect/, later /play/): quiet chrome so the data is the loudest thing on screen.
   Neutral greys, cobalt as the only accent, red and amber only for problems. Loaded after site.css. */

body.tool {
  --bg: #ffffff;
  --surface: #f6f7f9;
  --sunken: #f1f3f6;
  --line: #e4e7ec;
  --line-strong: #cdd3dc;
  --text: #181c25;
  --text-2: #4f5867;
  --text-3: #858e9d;
  --accent: #2b3bff;
  --accent-ink: #2230d6;
  --accent-soft: #eef0ff;
  --bad: #c43c51;
  --bad-soft: #fcf0f2;
  --warn: #9a640c;
  --warn-soft: #fbf5e7;
  --ok: #1f7a55;
  /* node categories: muted, distinguishable, never louder than the accent */
  --c-source: #5c6677;
  --c-field: #6f7889;
  --c-param: #8c6a1c;
  --c-calc: #2b3bff;
  --c-lod: #6a52c7;
  --c-tc: #0c7a83;
  --c-sheet: #2a303b;
  --t-calc: #f0f2ff;
  --t-lod: #f3f0fc;
  --t-tc: #e9f5f5;
  --t-sheet: #f1f2f4;
  background: var(--bg);
  color: var(--text);
  font: 400 14px/1.5 var(--sans);
}
body.tool :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
body.tool .nav { border-bottom: 1px solid var(--line); }
body.tool .nav .wrap { height: 60px; }
body.tool .nav .logo { font-size: 22px; }
body.tool .nav .logo img { width: 26px; height: 26px; }
body.tool .nav ul a { font-size: 14px; font-weight: 500; color: var(--text-2); }
body.tool .nav ul a:hover, body.tool .nav ul a[aria-current] { color: var(--text); }
body.tool .nav ul a[aria-current] { box-shadow: 0 2px 0 var(--accent); padding-bottom: 4px; }
body.tool footer { border-top: 1px solid var(--line); margin-top: 56px; color: var(--text-3); font-size: 12px; }
body.tool a { color: var(--accent-ink); text-decoration-thickness: 1px; text-underline-offset: 2px; }
body.tool .nav a, body.tool .logo { text-decoration: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.tool-main { padding-top: 28px; }
.tool-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; margin-bottom: 20px; }
.tool-head h1 { font: 600 26px/1.2 var(--sans); letter-spacing: -0.01em; margin: 0; }
.tool-head p { margin: 4px 0 0; color: var(--text-2); font-size: 15px; }
.local-note { display: inline-flex; align-items: center; gap: 7px; font-size: 13px !important; color: var(--text-2); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; }
.local-note svg { width: 14px; height: 14px; fill: none; stroke: var(--ok); stroke-width: 1.5; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; font: 500 13px var(--sans); color: var(--text); background: var(--bg); border: 1px solid var(--line-strong); border-radius: 6px; cursor: pointer; white-space: nowrap; box-shadow: 0 1px 0 rgba(16,24,40,.04); }
.btn:hover { background: var(--surface); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-ink); }

/* empty state */
.dropcard { margin-bottom: 8px; }
.drop { display: flex; align-items: center; gap: 20px; padding: 22px 26px; border: 1.5px dashed var(--line-strong); border-radius: 10px; background: var(--surface); cursor: pointer; transition: border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop img { width: 84px; height: 84px; flex: none; margin: -8px 0; }
.drop-text { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.drop-text b { font-weight: 600; font-size: 16px; }
.drop-text span { color: var(--text-2); }
.drop-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.drop-status { min-height: 20px; margin: 8px 2px 0; font-size: 13px; color: var(--text-2); }
.drop-status.bad { color: var(--bad); }
body.has-report .dropcard { display: none; }
body.has-report .tool-head { margin-bottom: 14px; }

/* toolbar + stats */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 0; border-top: 1px solid var(--line); }
.file-id { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-width: 0; }
.file-name { margin: 0; font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 8px; overflow-wrap: anywhere; }
.tag { font: 500 11.5px var(--sans); color: var(--text-2); background: var(--sunken); border-radius: 4px; padding: 1px 6px; white-space: nowrap; }
.wb-tabs:empty { display: none; }
.wb-tabs { display: inline-flex; background: var(--sunken); border-radius: 7px; padding: 2px; gap: 2px; flex-wrap: wrap; }
.wb-tabs button, .seg button { font: 500 12.5px var(--sans); color: var(--text-2); background: transparent; border: 0; border-radius: 5px; padding: 4px 10px; cursor: pointer; }
.wb-tabs button[aria-selected="true"], .seg button[aria-pressed="true"] { background: var(--bg); color: var(--text); box-shadow: 0 1px 2px rgba(16,24,40,.12); }
.wb-tabs:not(:empty) + .file-name { display: none; }
.toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.stats { display: flex; margin: 0 0 18px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.stats div { flex: 1; padding: 10px 16px; border-left: 1px solid var(--line); min-width: 0; }
.stats div:first-child { border-left: 0; }
.stats dt { font-size: 12px; color: var(--text-3); }
.stats dd { margin: 0; font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* layout + cards */
.stack { display: grid; gap: 16px; margin-bottom: 16px; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.col-main { display: grid; gap: 16px; min-width: 0; }
.col-side { position: sticky; top: 16px; }
.tcard { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; min-width: 0; }
.tcard-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.tcard-head h2 { font: 600 14px var(--sans); margin: 0; }
.count { font-size: 12px; color: var(--text-3); }
.tcard-foot { margin: 0; padding: 8px 14px; font-size: 12px; color: var(--text-3); border-top: 1px solid var(--line); }
.swipe { display: none; }

/* issues */
.issues { list-style: none; margin: 0; padding: 4px 0; }
.issues li { display: flex; align-items: flex-start; gap: 10px; padding: 7px 14px; }
.issues li + li { border-top: 1px solid var(--line); }
.issues .ico { width: 16px; height: 16px; flex: none; margin-top: 2px; }
.issues .txt { flex: 1; min-width: 0; }
.issues code { font: 12.5px var(--mono); background: var(--sunken); border-radius: 4px; padding: 0 4px; }
.issues .show { font: 500 12.5px var(--sans); color: var(--accent-ink); background: none; border: 0; padding: 0; cursor: pointer; white-space: nowrap; }
.issues .show:hover { text-decoration: underline; }
.i-bad .ico { color: var(--bad); } .i-warn .ico { color: var(--warn); } .i-note .ico { color: var(--text-3); } .i-ok .ico { color: var(--ok); }

/* lineage */
.glegend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); }
.glegend span { display: inline-flex; align-items: center; gap: 5px; }
.glegend svg { width: 14px; height: 14px; }
.toggle { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); }
.toggle input { accent-color: var(--accent); margin: 0; }
.graph-scroll { overflow-x: auto; padding: 14px 14px 10px; background-color: #fcfcfd; background-image: radial-gradient(#e2e5ea 1px, transparent 1px); background-size: 16px 16px; }
#graph { display: block; margin: 0 auto; font: 500 12px var(--sans); }
#graph .edge { fill: none; stroke: #c9cfd8; stroke-width: 1.1; }
#graph .edge.on { stroke: var(--accent); stroke-width: 1.6; }
#graph .dim { opacity: .22; }
#graph .node { cursor: pointer; }
#graph .node .box { fill: var(--bg); stroke: var(--line-strong); stroke-width: 1; }
#graph .node text { fill: var(--text); pointer-events: none; }
#graph .node .glyph { font: 600 10.5px var(--mono); }
#graph .k-source .box { fill: var(--surface); }
#graph .k-calc .box { fill: var(--t-calc); stroke: #c9cff9; }
#graph .k-lod .box { fill: var(--t-lod); stroke: #d6cdf3; }
#graph .k-tc .box { fill: var(--t-tc); stroke: #bcdfe1; }
#graph .k-sheet .box, #graph .k-dash .box { fill: var(--t-sheet); stroke: #b9c0cb; }
#graph .k-bad .box { fill: var(--bad-soft); stroke: #e7a9b3; }
#graph .k-bad text { fill: var(--bad); }
#graph .node.unused .box { fill: var(--bg); stroke-dasharray: 3 3; }
#graph .node.unused text:not(.glyph) { fill: var(--text-3); }
#graph .node:hover .box { stroke: var(--text-3); }
#graph .node.sel .box { stroke: var(--accent); stroke-width: 1.6; }
#graph .node.sel .halo { stroke: var(--accent-soft); stroke-width: 4; fill: none; }
#graph .node:focus { outline: none; }
#graph .node:focus-visible .box { stroke: var(--accent); stroke-width: 2; }
.ic { fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }

/* calculations table */
.seg { display: inline-flex; background: var(--sunken); border-radius: 7px; padding: 2px; gap: 2px; margin-left: auto; flex-wrap: wrap; }
.seg button span { color: var(--text-3); margin-left: 3px; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
.calc-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.calc-table th { text-align: left; font: 500 12px var(--sans); color: var(--text-3); padding: 8px 14px; border-bottom: 1px solid var(--line); }
.calc-table th:nth-child(1) { width: 32%; } .calc-table th:nth-child(3) { width: 24%; }
.calc-table td { padding: 8px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.calc-table tr:last-child td { border-bottom: 0; }
.calc-table tbody tr { cursor: pointer; }
.calc-table tbody tr:hover { background: var(--surface); }
.calc-table tbody tr.on { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.calc-table .nm { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.calc-table .nm svg { width: 15px; height: 15px; flex: none; }
.calc-table code { display: block; font: 12.5px/1.5 var(--mono); color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.calc-table .use { color: var(--text-2); font-size: 13px; }
.calc-table .none { color: var(--text-3); }
.flag { font: 500 11px var(--sans); border-radius: 4px; padding: 0 5px; white-space: nowrap; }
.flag.bad { color: var(--bad); background: var(--bad-soft); }
.flag.unused { color: var(--text-2); border: 1px dashed var(--line-strong); }
.flag.dup { color: var(--warn); background: var(--warn-soft); }

/* detail panel */
.detail { padding: 14px; }
.detail .empty { color: var(--text-3); margin: 0; }
.detail .kind { display: inline-flex; align-items: center; gap: 5px; font: 500 12px var(--sans); color: var(--text-2); }
.detail .kind svg { width: 14px; height: 14px; }
.detail h2 { font: 600 18px/1.3 var(--sans); margin: 4px 0 10px; overflow-wrap: anywhere; }
.detail pre { margin: 0 0 12px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; font: 12.5px/1.6 var(--mono); white-space: pre-wrap; word-break: break-word; color: var(--text); }
.callout { font-size: 13px; border-radius: 6px; padding: 8px 10px; margin: 0 0 12px; }
.callout.bad { color: var(--bad); background: var(--bad-soft); }
.callout.warn { color: var(--warn); background: var(--warn-soft); }
.detail h3 { font: 500 12px var(--sans); color: var(--text-3); margin: 14px 0 4px; }
.links { list-style: none; margin: 0; padding: 0; }
.links button { all: unset; box-sizing: border-box; width: 100%; display: flex; align-items: center; gap: 8px; padding: 5px 6px; margin: 0 -6px; border-radius: 5px; cursor: pointer; font-size: 13px; }
.links button:hover, .links button:focus-visible { background: var(--surface); }
.links svg { width: 14px; height: 14px; flex: none; }

/* estate, notes, about */
.estate table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.estate th { text-align: left; font: 500 12px var(--sans); color: var(--text-3); padding: 8px 14px; border-bottom: 1px solid var(--line); }
.estate td { padding: 7px 14px; border-bottom: 1px solid var(--line); }
.estate .n { text-align: right; }
.estate .sub { padding: 10px 14px; margin: 0; color: var(--text-2); font-size: 13px; }
.notes { font-size: 12.5px; color: var(--text-3); }
.notes summary { cursor: pointer; }
.notes ul { margin: 6px 0 0; padding-left: 18px; }
.tool-about { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--line); }
.tool-about h2 { font: 600 15px var(--sans); margin: 0 0 6px; }
.tool-about p { color: var(--text-2); margin: 0 0 10px; max-width: 60ch; }

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .col-side { position: static; order: -1; }
}
@media (max-width: 640px) {
  .drop { flex-direction: column; align-items: flex-start; gap: 12px; padding: 18px; }
  .drop img { width: 64px; height: 64px; margin: 0; }
  .stats { flex-wrap: wrap; }
  .stats div { flex: 1 1 33%; border-top: 1px solid var(--line); }
  .toggle { margin-left: 0; }
  .swipe { display: inline; }
  .tool-about { grid-template-columns: 1fr; gap: 8px; }
  .calc-table th:nth-child(3), .calc-table td:nth-child(3) { display: none; }
  .calc-table th:nth-child(1) { width: 44%; }
}

/* report / article pages (census) */
.article { max-width: 860px; }
.article-head { padding: 12px 0 8px; }
.article-head .kicker { font-size: 13px; color: var(--text-3); margin: 0 0 6px; }
.article-head h1 { font: 600 clamp(30px, 4.4vw, 44px)/1.12 var(--sans); letter-spacing: -0.02em; margin: 0 0 14px; max-width: 20ch; }
.article-head .dek { font-size: 18px; line-height: 1.55; color: var(--text-2); max-width: 62ch; margin: 0 0 22px; }
.article section { margin: 40px 0; }
.article h2 { font: 600 21px/1.3 var(--sans); margin: 0 0 8px; }
.article section > p { font-size: 15.5px; line-height: 1.65; color: var(--text-2); max-width: 66ch; margin: 0 0 16px; }
.bars { display: grid; gap: 7px; }
.bar { display: grid; grid-template-columns: minmax(150px, 30%) 1fr 120px; align-items: center; gap: 12px; font-size: 13.5px; }
.bl { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bt { height: 14px; background: var(--sunken); border-radius: 3px; overflow: hidden; }
.bf { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.bv { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.bv small { display: block; font-weight: 400; color: var(--text-3); font-size: 11.5px; }
.method { border-top: 1px solid var(--line); padding-top: 28px; }
.downloads { font-size: 14px !important; }
.next { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; }
.next p { margin: 0 !important; }
@media (max-width: 640px) {
  .bar { grid-template-columns: 1fr 76px; }
  .bar .bt { grid-column: 1 / -1; grid-row: 2; }
  .article-head .dek { font-size: 16px; }
}
