:root {
  --bg: #0f1419;
  --panel: #1a212b;
  --panel2: #222c38;
  --ink: #e6edf3;
  --muted: #8b98a5;
  --line: #2d3845;
  --accent: #4ea1ff;
  --good: #3fb950;
  --warn: #d29922;
  --bad: #f85149;
  --logo-red: #dc2b19;
  --mono: ui-monospace, "Cascadia Code", "Consolas", monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}
header {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 12px;
  padding: 14px 22px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #16202b, #0f1419);
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo { height: 42px; width: auto; display: block; background: #fff; border-radius: 8px; padding: 5px 9px; }
.brand h1 { margin: 0; font-size: 22px; letter-spacing: .5px; color: var(--logo-red); }
.tag { margin: 2px 0 0; color: #fff; font-size: 12.5px; }
.headio { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  background: var(--panel2); color: var(--ink); border: 1px solid var(--line);
  padding: 7px 13px; border-radius: 7px; cursor: pointer; font-size: 13px;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: #2c3a49; border-color: #3a4a5a; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #06243f; font-weight: 600; }
.btn.primary:hover { background: #6fb4ff; }
.btn.sm { padding: 3px 9px; font-size: 12px; }
.btn.active { background: var(--warn); border-color: var(--warn); color: #2a1d00; font-weight: 600; }
.btn.active:hover { background: #e3b13a; border-color: #e3b13a; }

.sphere-banner {
  padding: 10px 22px; border-bottom: 1px solid #5a4a1f;
  background: linear-gradient(180deg, #2a2410, #1f1c0e);
  color: #e8d9a8; font-size: 13px; line-height: 1.5;
}
.sphere-banner b { color: #ffd86b; }
.sphere-banner[hidden] { display: none; }

main {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px; padding: 18px 22px; align-items: start;
}
@media (max-width: 920px) { main { grid-template-columns: 1fr; } }
/* Left sidebar and right content each stack their own panels with a tight, fixed
   gap. Keeping them as independent flex columns (instead of one grid spanning
   rows) means the taller column's extra height falls to the bottom — it never
   gets injected as dead space between the graph, the offset slider and M-L. */
.sidebar, .content { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.zones, .results, .roc-bar, .ml { min-width: 0; }

.roc-bar {
  position: sticky;
  top: 8px;
  z-index: 10;
  padding: 10px 16px;
  background: linear-gradient(180deg, #1f2935, #19222d);
  border-color: #38465a;
  box-shadow: 0 4px 14px rgba(0,0,0,.35);
}
.roc-bar-inner { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; min-width: 0; }
.roc-bar-label { display: flex; align-items: baseline; gap: 10px; flex: 0 0 auto; }
.roc-bar-title { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: 1px; }
.roc-bar-control { display: flex; align-items: center; gap: 8px; flex: 1 1 180px; min-width: 0; }
.roc-bar-control input[type="range"] { flex: 1; accent-color: var(--accent); }
.roc-bar-control button { background: var(--panel2); border: 1px solid var(--line); color: var(--ink);
  padding: 4px 10px; border-radius: 6px; cursor: pointer; font-family: var(--mono); }
.roc-bar-control button:hover { background: #2c3a49; }
#mRocOffsetVal { font-family: var(--mono); font-size: 14px; color: var(--accent); min-width: 8ch; text-align: right; }
.ml-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.ml-verdict { font-family: var(--mono); font-size: 13px; padding: 5px 12px; border-radius: 7px; border: 1px solid var(--line); }
.ml-verdict.pass { color: var(--good); border-color: #1f5e2b; background: #122017; }
.ml-verdict.fail { color: var(--bad); border-color: #5e1f1f; background: #201212; }
.ml-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 6px; }
@media (max-width: 720px) { .ml-charts { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 16px;
}
.panel h2 { margin: 0 0 12px; font-size: 14px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }

.grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 4px; }
input, select {
  background: #0d141b; border: 1px solid var(--line); color: var(--ink);
  padding: 7px 9px; border-radius: 6px; font-size: 14px; font-family: var(--mono);
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
.derived { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
.derived b { color: var(--ink); }

.zone-count-row { display: flex; gap: 8px; align-items: stretch; }
.zone-count-row input { flex: 1; min-width: 0; }
.zone-count-row .btn { white-space: nowrap; flex: 0 0 auto; }

/* figuring-session control */
.session-ctl { display: flex; flex-direction: column; gap: 7px; padding: 9px 10px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; }
.session-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.session-step, .session-actions { display: flex; align-items: center; gap: 6px; }
.session-pos { font-size: 12px; color: var(--muted); white-space: nowrap; }
.session-pos b { color: var(--ink); font-family: var(--mono); }
.session-ctl .btn.sm { padding: 2px 9px; }
.session-ctl .btn:disabled { opacity: .4; cursor: default; }
.session-meta { display: flex; gap: 6px; }
.session-meta input { padding: 5px 7px; font-size: 12px; }
.session-meta input[type="date"] { flex: 0 0 auto; color-scheme: dark; }
.session-meta #sessNote { flex: 1; min-width: 0; }
.session-io { display: flex; gap: 6px; }
.session-io .btn { flex: 1; text-align: center; }

/* sagitta & blank pane */
.sublabel { color: var(--muted); font-weight: 400; opacity: .8; }
.sag-results { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line);
  display: grid; grid-template-columns: 1fr auto; gap: 7px 14px; font-size: 12.5px; align-items: baseline; }
.sag-results .k { color: var(--muted); }
.sag-results .v { font-family: var(--mono); color: var(--good); text-align: right; }
.sag-results .v .dim, .weights .wval .dim { color: var(--muted); }
.sag-sub { margin: 18px 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 600; }
.weights { display: grid; grid-template-columns: 1fr auto; gap: 6px 14px; font-size: 12.5px; align-items: baseline; }
.weights .wname { color: var(--muted); }
.weights .wval { font-family: var(--mono); color: var(--good); text-align: right; white-space: nowrap; }
.sag-diagram { margin: 16px 0 0; }
#sagDiagram svg { width: 100%; height: auto; display: block; background: #0d141b; border: 1px solid var(--line); border-radius: 8px; }

.roc-off .row { display: flex; align-items: center; gap: 8px; }
.roc-off .row + .row { margin-top: 6px; }
.roc-off output { font-family: var(--mono); font-size: 13px; color: var(--accent); min-width: 8ch; text-align: right; margin-left: auto; }
.roc-off input[type="range"] { flex: 1; accent-color: var(--accent); }
.roc-off button { background: var(--panel2); border: 1px solid var(--line); color: var(--ink);
  padding: 3px 9px; border-radius: 6px; cursor: pointer; font-family: var(--mono); }
.roc-off button:hover { background: #2c3a49; }

.zones-head { display: flex; justify-content: space-between; align-items: center; }
.zbtns { display: flex; gap: 6px; align-items: center; }
.sets-ctl { flex-direction: row; align-items: center; gap: 5px; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
.sets-ctl input { width: 46px; padding: 4px 6px; font-size: 13px; text-align: right; }
.zones { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 13px; }
th, td { text-align: right; padding: 5px 8px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; font-size: 11px; text-transform: uppercase; }
th:first-child, td:first-child { text-align: center; color: var(--muted); }
td input { width: 92px; text-align: right; padding: 4px 6px; }
/* Reading inputs: wide enough for 6-digit values (e.g. 0.1685) and no spin
   arrows (knife readings are typed, not stepped — the arrows just clipped text). */
td input.r-input { width: 80px; -moz-appearance: textfield; appearance: textfield; }
td input.r-input::-webkit-outer-spin-button,
td input.r-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
td.calc { color: var(--accent); }
td.avg-cell { color: var(--ink); font-weight: 600; }
/* Inner/Outer headers sit over input boxes whose numbers are right-aligned. Left-
   align each label so its first letter sits above the left-most digit of the values
   (all boundary values render as "X.XX"), rather than hanging off to the right. */
th.io-col { text-align: left; padding-left: 63px; }

/* Zone-to-zone reading differences: small numbers nudged half a row down so each
   sits midway between the pair it relates to (and below the last reading for the
   last − first wrap). Content is absolutely positioned, so the column reserves a
   fixed width. */
.diff-col, td.diff-cell { width: 58px; min-width: 58px; }
td.diff-cell { position: relative; padding: 0; }
td.diff-cell .dv, td.diff-cell .idv {
  position: absolute; bottom: 0; left: 8px; transform: translateY(50%);
  font-family: var(--mono); font-size: 10px; line-height: 1; color: #5fb3a3;
  white-space: nowrap; pointer-events: none;
}
/* breathing room so the last row's (below-the-row) difference doesn't crowd the hint */
#zoneTable { margin-bottom: 7px; }
th.avg-col, td.avg-cell { border-left: 1px solid var(--line); border-right: 1px solid var(--line); background: rgba(78,161,255,.06); }

/* Per-test wavefront P-V footer (only shown with 2+ tests) — teal to stand out */
#zoneFoot td { border-top: 2px solid var(--line); padding-top: 7px; }
#zoneFoot .pv-label { text-align: right; color: var(--muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; }
/* font-size 14px + extra right padding makes the fraction line up under the
   reading inputs (which are 14px with 6px inner padding), so the "/" sits
   roughly under the decimal point of the column above. */
#zoneFoot .pv-col { color: #2dd4bf; font-weight: 700; font-size: 14px; padding-right: 14px; background: rgba(45,212,191,.10); }
#zoneFoot .pv-avg-cell { color: #2dd4bf; font-weight: 700; font-size: 14px; background: rgba(45,212,191,.18); border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
.hint { color: var(--muted); font-size: 11.5px; margin: 10px 0 0; }
.hint em { color: var(--ink); font-style: normal; }

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); gap: 10px; margin-bottom: 16px; }
.metric { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.metric .k { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
.metric .v { font-family: var(--mono); font-size: 19px; margin-top: 3px; }
.metric .v small { font-size: 12px; color: var(--muted); }
.metric.grade-good .v { color: var(--good); }
.metric.grade-warn .v { color: var(--warn); }
.metric.grade-bad  .v { color: var(--bad); }

.charts figure { margin: 0; min-width: 0; }
/* session-overlay compare control + legend under the wavefront chart */
.wf-caption-row { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; gap: 8px; }
.wf-caption-row figcaption { margin-top: 0; text-align: left; }
.wf-compare { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px 12px; font-size: 12px; color: var(--muted); }
.wf-compare-on { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.wf-compare-on input[type="checkbox"] { width: auto; margin: 0; padding: 0; accent-color: var(--accent); cursor: pointer; }
.wf-compare-opts { display: inline-flex; align-items: center; gap: 6px; }
.wf-compare-opts[hidden] { display: none; }
.wf-compare input[type="number"] { width: 52px; padding: 4px 6px; font-size: 12px; text-align: right; }
.wf-legend { display: flex; flex-wrap: wrap; gap: 8px 14px; justify-content: center; margin-top: 7px; font-family: var(--mono); font-size: 11px; color: var(--ink); }
.wf-legend:empty { display: none; }
.wf-leg { display: inline-flex; align-items: center; gap: 6px; }
.wf-sw { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.ml-charts figure { min-width: 0; }

/* ---------- measurement uncertainty ---------- */
.uncert-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.uncert-on { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.uncert-body { margin-top: 10px; }
.uncert-tols { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.uncert-label { font-size: 12px; color: var(--muted); }
.uncert-tol-row { display: flex; flex-wrap: wrap; gap: 8px; }
.uncert-tol { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--muted); }
.uncert-tol input { width: 13.5ch; font-family: var(--mono); font-size: 11.5px; }
/* max-content (not auto) so the columns hug their text instead of stretching to
   fill the panel; justify-content keeps the whole block left-aligned. */
.uncert-results {
  display: grid; grid-template-columns: repeat(4, max-content); justify-content: start;
  gap: 6px 18px;
  margin: 14px 0 4px; font-family: var(--mono); font-size: 13px; align-items: baseline; }
/* Metric columns sit close together; the label column keeps its wider gap so the
   case name stays visually separate from the numbers. */
.uncert-results > :nth-child(4n+1) { padding-right: 9px; }
.uncert-results .uh { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.uncert-results .ur { color: var(--muted); }
.uncert-results .uv { color: var(--fg); }
.uncert-results .row-best .uv  { color: var(--good); }
.uncert-results .row-worst .uv { color: var(--bad); }
.uncert-note { font-size: 12px; color: var(--warn); margin: 6px 0 0; }
@media (max-width: 720px) { .uncert-results { grid-template-columns: repeat(2, auto); } }

/* ---------- Ronchi test simulation ---------- */
.ronchi-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.ronchi-ctl { display: flex; align-items: center; flex-wrap: wrap; gap: 16px; font-size: 13px; color: var(--muted); }
.ronchi-ctl label { display: inline-flex; align-items: center; gap: 6px; }
.ronchi-ctl input[type="number"] { width: 8.5ch; }
.ron-offset { font-family: inherit; }
.ron-offset input[type="range"] { width: 150px; }
.ron-offset button {
  font-family: var(--mono); background: #1b2733; color: var(--fg); border: 1px solid var(--line);
  width: 26px; height: 26px; border-radius: 6px; cursor: pointer; line-height: 1; }
.ron-offset button:hover { background: #2c3a49; }
#ronOffsetVal { font-family: var(--mono); color: var(--accent); min-width: 6ch; text-align: right; }
.ron-unit { font-family: var(--mono); }
.ronchi-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 6px; }
.ronchi-charts figure { margin: 0; min-width: 0; }
.ronchi-charts canvas { max-width: 340px; margin: 0 auto; aspect-ratio: 1 / 1; }
@media (max-width: 720px) { .ronchi-charts { grid-template-columns: 1fr; } }
canvas { width: 100%; max-width: 100%; height: auto; background: #0b1118; border: 1px solid var(--line); border-radius: 8px; display: block; }
figcaption { color: var(--muted); font-size: 11.5px; margin-top: 6px; text-align: center; }
.method { color: var(--muted); font-size: 11px; margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }

.drop-overlay {
  position: fixed; inset: 0; display: none; align-items: center; justify-content: center;
  background: rgba(15,20,25,.85); z-index: 50; font-size: 26px; color: var(--accent);
  border: 3px dashed var(--accent);
}
.drop-overlay.show { display: flex; }

dialog { background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 20px; min-width: 320px; }
dialog::backdrop { background: rgba(0,0,0,.5); }
dialog h3 { margin: 0 0 12px; }
#sampleList { list-style: none; padding: 0; margin: 0 0 14px; max-height: 50vh; overflow: auto; }
#sampleList li { padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; margin-bottom: 6px; cursor: pointer; font-family: var(--mono); font-size: 13px; }
#sampleList li:hover { background: var(--panel2); border-color: var(--accent); }

#maskDialog { width: min(480px, 92vw); max-height: 92vh; overflow: auto; }
.mask-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin-bottom: 12px; }
.mask-form label { color: var(--muted); font-size: 12px; gap: 4px; }
#maskPreview { display: block; margin: 0 auto 12px; background: #0b1118; border: 1px solid var(--line); border-radius: 8px; max-width: 100%; height: auto; }
#maskZonesTable { width: 100%; font-size: 12px; margin-bottom: 12px; }
#maskZonesTable td, #maskZonesTable th { padding: 3px 8px; }
.mask-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

footer { padding: 16px 22px; color: var(--muted); font-size: 11.5px; border-top: 1px solid var(--line); }

/* ---------- photos ---------- */
.photos-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.photos-head h2 { margin: 0; }
.photos-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.photo-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.photo-grid:empty { display: none; }
.photo-thumb { position: relative; width: 150px; height: 150px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #0b1118; cursor: zoom-in; }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-thumb .photo-name { position: absolute; left: 0; right: 0; bottom: 0; padding: 3px 6px; font-size: 10.5px; background: rgba(0,0,0,.6); color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.photo-thumb .photo-rm { position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; line-height: 18px; text-align: center; border-radius: 50%; border: none; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; font-size: 14px; padding: 0; }
.photo-thumb .photo-rm:hover { background: var(--bad); }
.photo-thumb.missing { display: flex; align-items: center; justify-content: center; cursor: default; }
.photo-thumb.missing span { color: var(--bad); font-size: 11px; text-align: center; padding: 6px; }

/* image picker dialog */
#imgDialog { width: min(620px, 92vw); max-height: 92vh; overflow: auto; }
.img-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin-bottom: 14px; max-height: 60vh; overflow: auto; }
.img-picker .pick { position: relative; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; cursor: pointer; background: #0b1118; }
.img-picker .pick img { width: 100%; height: 100px; object-fit: cover; display: block; }
.img-picker .pick .nm { padding: 4px 6px; font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.img-picker .pick.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.img-picker .pick .tick { position: absolute; top: 6px; left: 6px; width: 20px; height: 20px; border-radius: 4px; background: rgba(0,0,0,.55); color: #fff; font-size: 13px; line-height: 20px; text-align: center; }
.img-picker .pick.sel .tick { background: var(--accent); color: #06243f; }
.img-empty { color: var(--muted); font-size: 12.5px; padding: 8px 0 14px; }
.img-actions { display: flex; gap: 8px; justify-content: flex-end; }

#galleryList { list-style: none; padding: 0; margin: 0 0 14px; max-height: 50vh; overflow: auto; }
#galleryList li { padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; margin-bottom: 6px; cursor: pointer; font-family: var(--mono); font-size: 13px; display: flex; justify-content: space-between; gap: 10px; }
#galleryList li:hover { background: var(--panel2); border-color: var(--accent); }
#galleryList .cam { color: var(--muted); font-size: 12px; white-space: nowrap; }

#publishDialog { width: min(560px, 92vw); }
#publishDialog ol { margin: 0 0 4px; padding-left: 20px; font-size: 13px; line-height: 1.6; }
#publishDialog code { background: #0b1118; padding: 1px 5px; border-radius: 4px; }
#publishDialog pre { background: #0b1118; border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-family: var(--mono); font-size: 12px; overflow: auto; max-height: 30vh; white-space: pre-wrap; word-break: break-word; }
.pub-copy { margin: 8px 0 0; }

/* lightbox */
.lightbox { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.88); display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 10px; padding: 24px; }
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 94vw; max-height: 84vh; object-fit: contain; border-radius: 6px; }
.lightbox-cap { color: #ddd; font-size: 13px; font-family: var(--mono); }
.lightbox-close { position: absolute; top: 16px; right: 20px; width: 40px; height: 40px; border-radius: 50%; border: none; background: rgba(255,255,255,.12); color: #fff; font-size: 24px; cursor: pointer; }
.lightbox-close:hover { background: rgba(255,255,255,.25); }

/* ---------- print / save PDF ---------- */
#printHeader  { display: none; }
#printSidebar { display: none; }
.print-canvas { display: none; }

@media print {
  @page { margin: 16mm 14mm; }

  /* ---- Print-only header ---- */
  #printHeader { display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 10pt; padding-bottom: 7pt; border-bottom: 1.5pt solid #555; gap: 12pt; }
  .ph-left { flex: 1; }
  .ph-title { font-size: 16pt; font-weight: 700; color: #000; margin-bottom: 2pt; }
  .ph-meta  { font-size: 9pt; color: #444; margin-bottom: 1pt; }
  .ph-roc   { font-size: 9pt; color: #444; }
  .ph-roc b { color: #000; }
  .ph-brand { display: flex; align-items: center; gap: 8pt; flex-shrink: 0; }
  .ph-logo  { height: 36pt; width: auto; display: block; }
  .ph-brand-text { text-align: left; }
  .ph-brand-name { font-size: 14pt; font-weight: 700; color: #c0201a; line-height: 1.2; }
  .ph-brand-sub  { font-size: 8.5pt; color: #333; }

  /* ---- Global tone ---- */
  body { background: #fff !important; color: #000 !important; font-size: 10pt; }

  /* ---- Hide all interactive chrome and the real sidebar ---- */
  header, footer, .sphere-banner, .sidebar,
  .session-nav, .session-io, .wf-compare, .wf-legend,
  .zbtns, .hint, .roc-bar-control, .photos-btns,
  .drop-overlay, dialog, .lightbox, .photo-rm { display: none !important; }

  /* ---- Layout ---- */
  main { display: block !important; padding: 0 !important; }
  .content { display: block !important; }

  /* ---- Print sidebar ---- */
  #printSidebar { display: block; margin-bottom: 10pt; }

  .ps-panel { border: 1pt solid #bbb; padding: 7pt 9pt; margin-bottom: 8pt; break-inside: avoid; }
  .ps-h2 { font-size: 8pt; font-weight: 700; text-transform: uppercase;
    letter-spacing: 1px; color: #555; margin-bottom: 5pt;
    padding-bottom: 3pt; border-bottom: 1pt solid #ddd; }
  .ps-edge { font-size: 10pt; margin-bottom: 6pt; }

  /* Param rows: items flow left-to-right with a separator dot between them */
  .ps-row { display: flex; flex-wrap: wrap; gap: 2pt 16pt; font-size: 9.5pt; margin-bottom: 3pt; }
  .ps-kv b { color: #000; }
  .ps-kv { color: #333; }

  /* Sagitta two-column layout — wider left so long labels don't wrap */
  .ps-sag-cols { display: grid; grid-template-columns: 3fr 2fr; gap: 10pt; margin-bottom: 8pt; }
  .ps-sag-left .sag-results, .ps-sag-right .weights {
    display: grid; grid-template-columns: auto auto; gap: 2pt 8pt;
    font-size: 8.5pt; margin-top: 0; padding-top: 0; border-top: none; justify-content: start; }
  .ps-sag-left .sag-results .k, .ps-sag-right .wname { color: #555; font-size: 8.5pt; white-space: nowrap; }
  .ps-sag-left .sag-results .v, .ps-sag-right .wval  { color: #000; font-size: 8.5pt; white-space: nowrap; }
  .ps-sag-sub { font-size: 8pt; font-weight: 700; text-transform: uppercase;
    letter-spacing: .5px; color: #555; margin-bottom: 4pt; }

  /* Diagram + theoretical performance side by side */
  .ps-diag-perf { display: grid; grid-template-columns: 160pt 1fr; gap: 12pt; align-items: start; margin-top: 4pt; }
  .ps-sag-diagram svg { background: #f2f7fc !important; border: 1pt solid #bbb !important; }
  .ps-sag-diagram path { fill: #c4ddf2 !important; stroke: #1f5a96 !important; }
  .ps-sag-diagram line { stroke: #444 !important; }
  .ps-sag-diagram text { fill: #000 !important; }

  /* Theoretical performance — compact, labels and values close together */
  #psPerfResults .sag-results {
    display: grid; grid-template-columns: auto auto; gap: 2pt 8pt;
    font-size: 8.5pt; margin-top: 0; padding-top: 0; border-top: none; justify-content: start; }
  #psPerfResults .sag-results .k { color: #555; white-space: nowrap; }
  #psPerfResults .sag-results .v { color: #000; white-space: nowrap; }

  /* ---- Screen panels (right-column content only) ---- */
  .panel { background: #fff !important; border: 1pt solid #bbb !important;
    border-radius: 0 !important; padding: 8pt 10pt !important;
    margin-bottom: 10pt; break-inside: avoid; }
  .panel h2 { color: #555 !important; font-size: 8pt; margin-bottom: 6pt; }
  input, select { background: transparent !important; border: none !important;
    color: #000 !important; padding: 0 !important; font-size: inherit; }

  /* ROC bar */
  .roc-bar { position: static !important; box-shadow: none !important;
    background: #fff !important; border-color: #bbb !important; }
  .roc-bar-inner { gap: 8pt; }
  .roc-bar-title { color: #555 !important; }
  #mRocOffsetVal { color: #000 !important; }

  /* Metrics */
  .metrics { grid-template-columns: repeat(3, 1fr) !important; gap: 6pt !important; margin-bottom: 8pt !important; }
  .metric { background: #f5f5f5 !important; border: 1pt solid #bbb !important; border-radius: 4pt !important; padding: 6pt 8pt !important; }
  .metric .k { color: #555 !important; }
  .metric.grade-good .v { color: #1a6b1a !important; }
  .metric.grade-warn .v { color: #7a5000 !important; }
  .metric.grade-bad  .v { color: #900 !important; }
  .metric .v { font-size: 14pt !important; }

  /* Wavefront chart */
  .wf-caption-row figcaption { color: #444 !important; }
  canvas { display: none !important; }
  .print-canvas { display: block !important; width: 100% !important; height: auto !important;
    border: 1pt solid #bbb !important; border-radius: 4pt !important; margin-bottom: 4pt; }

  /* Millies-Lacroix */
  .ml-charts { grid-template-columns: 1fr 1fr !important; gap: 10pt !important; }
  .ml-verdict { border: 1pt solid #bbb !important; }
  .ml-verdict.pass { color: #1a6b1a !important; background: #edf7ed !important; border-color: #aad4aa !important; }
  .ml-verdict.fail { color: #900 !important; background: #fdecea !important; border-color: #e9a9a9 !important; }

  /* Ronchi test simulation */
  .ronchi-ctl { display: none !important; }               /* hide live slider/inputs */
  .ron-print-note { font-size: 8.5pt !important; color: #333 !important; font-family: var(--mono); }
  .ronchi-charts { grid-template-columns: 1fr 1fr !important; gap: 12pt !important; }
  .ronchi .print-canvas { max-width: 200pt !important; margin: 0 auto 4pt !important; }
  .ronchi figcaption { color: #444 !important; }

  /* Photos */
  .photo-grid { display: flex !important; flex-wrap: wrap !important; gap: 6pt !important; }
  .photo-thumb { width: 100pt !important; height: 100pt !important; border: 1pt solid #bbb !important; border-radius: 4pt !important; }
  .photo-name  { font-size: 7pt !important; }

  /* Zone table */
  #zoneTable { table-layout: fixed; width: 100%; font-size: 8pt; }
  th, td { padding: 2pt 4pt !important; border-color: #ccc !important; }
  th { color: #555 !important; font-size: 7.5pt; }
  td.calc, td.avg-cell { color: #000 !important; }
  /* Inputs fill their fixed-width cell rather than collapsing or overflowing */
  #zoneTable input { width: 100% !important; min-width: 0 !important;
    color: #000 !important; font-size: 8pt !important; }
  th.avg-col, td.avg-cell { background: #f0f4ff !important; }
  #zoneFoot .pv-col, #zoneFoot .pv-avg-cell { color: #1a6b6b !important; background: #edf7f7 !important; }
  /* Column widths: fixed structural columns; reading columns share remaining space */
  #zoneTable th:nth-child(1), #zoneTable td:nth-child(1) { width: 14pt; }
  /* Extra left padding on Inner and Eff. radius for consistent column separation */
  #zoneTable th.io-col:first-of-type, #zoneTable tr td:nth-child(2) { padding-left: 8pt !important; }
  #zoneTable th:nth-child(4), #zoneTable td.reff-cell { padding-left: 8pt !important; }
  #zoneTable th.io-col { width: 44pt; }
  td.reff-cell { width: 44pt; }
  td.diff-cell, th.diff-col { width: 28pt; }
  td.ideal-cell { width: 40pt; }
  td.surf-cell { width: 42pt; }
  td.avg-cell, th.avg-col { width: 40pt; }
  /* In print, show diff values as regular in-cell text (absolute positioning
     between rows is unreliable in PDF renderers) */
  td.diff-cell { padding: 2pt 4pt !important; text-align: center; }
  td.diff-cell .dv, td.diff-cell .idv {
    position: static !important; transform: none !important;
    display: block !important; color: #1a7a6b !important; }

  figcaption { color: #555 !important; }
  #mlMethod { display: none !important; }
}
