/*
 * PediTools data tools (bulk analysis, patient growth chart): standalone pages with their own light theme
 * (owner, 2026-10-19), full width for wide tables, and a print stylesheet (US Letter, portrait).
 */
:root {
  --pt-ink: #1f2933;
  --pt-muted: #5f6b76;
  --pt-line: #d5dbe1;
  --pt-soft: #f4f6f8;
  --pt-accent: #1f5f8b;
  --pt-accent-ink: #ffffff;
  --pt-ok: #1e6b3a;
  --pt-warn-bg: #fff6e0;
  --pt-warn-line: #e3b341;
  --pt-error-bg: #fdecec;
  --pt-error-line: #d64545;
  --pt-sent-bg: #e8f1f8;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* also where a class sets display (e.g. .pt-field) */

body.pt-tool {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--pt-ink);
  background: #ffffff;
}

.pt-tool-header {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--pt-line);
  background: var(--pt-soft);
}
.pt-brand { font-weight: 700; font-size: 1.15rem; color: var(--pt-ink); text-decoration: none; }
.pt-brand:hover { text-decoration: underline; }
.pt-tool-title { color: var(--pt-muted); }

.pt-tool-main { padding: 8px 16px 32px; max-width: 1600px; margin: 0 auto; }
.pt-tool-main h1 { font-size: 1.6rem; margin: 16px 0 4px; }
.pt-lead { color: var(--pt-muted); margin-top: 0; }

.pt-step { border-top: 1px solid var(--pt-line); padding: 12px 0 8px; }
.pt-step h2 { font-size: 1.2rem; margin: 4px 0 10px; display: flex; align-items: center; gap: 10px; }
.pt-step-number {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.7em; height: 1.7em; border-radius: 50%;
  background: var(--pt-accent); color: var(--pt-accent-ink); font-size: 0.9rem;
}

label { font-weight: 600; margin-right: 8px; }
select, textarea, input[type="text"] {
  font: inherit; color: inherit; padding: 6px 8px; border: 1px solid var(--pt-line); border-radius: 6px; background: #fff;
  max-width: 100%;
}
textarea { width: 100%; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.9rem; margin: 8px 0; }
button {
  font: inherit; padding: 6px 14px; border: 1px solid var(--pt-accent); border-radius: 6px;
  background: #fff; color: var(--pt-accent); cursor: pointer;
}
button.pt-primary { background: var(--pt-accent); color: var(--pt-accent-ink); font-weight: 600; padding: 8px 20px; }
button:disabled { opacity: 0.5; cursor: default; }
a { color: var(--pt-accent); }

.pt-calc-title { color: var(--pt-muted); margin: 6px 0 0; }
/* The "Apply WHO SD23 correction" checkbox under the chart's title: small and grey (rarely unticked; phase 20 C) */
.pt-sd23 { color: var(--pt-muted); font-size: 0.85em; margin: 4px 0 0; }
.pt-sd23 label { font-weight: normal; }
.pt-sd23 input { margin: 0 0.3em 0 0; vertical-align: -0.1em; }
.pt-lead p { margin: 0 0 8px; }
button.pt-link { border: 0; background: none; padding: 0; color: var(--pt-accent); text-decoration: underline; font: inherit; }
.pt-downloads { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pt-results-wrap { max-height: 75vh; overflow: auto; }
.pt-advanced { margin: 4px 0 12px; }
.pt-advanced summary { cursor: pointer; color: var(--pt-accent); }
.pt-advanced fieldset { border: 0; padding: 4px 0; margin: 0; }
.pt-advanced legend { font-weight: 600; padding: 0; }
.pt-choice input:disabled + * , .pt-choice:has(input:disabled) { color: var(--pt-muted); }

.pt-drop {
  border: 2px dashed var(--pt-line); border-radius: 10px; padding: 16px; text-align: center; background: var(--pt-soft);
}
.pt-drop p { margin: 4px 0; }
.pt-drop.pt-drag { border-color: var(--pt-accent); background: var(--pt-sent-bg); }
.pt-drop input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.pt-file-label { color: var(--pt-accent); text-decoration: underline; cursor: pointer; margin: 0; }
.pt-drop:focus-within { outline: 2px solid var(--pt-accent); outline-offset: 2px; }
.pt-hint { color: var(--pt-muted); font-size: 0.9rem; }
.pt-paste { margin: 12px 0; }
.pt-paste summary, .pt-sent summary { cursor: pointer; color: var(--pt-accent); }
.pt-status { color: var(--pt-muted); }
.pt-status.pt-error { color: var(--pt-error-line); font-weight: 600; }

.pt-table-wrap { overflow-x: auto; max-width: 100%; }
table.pt-mapping, table.pt-results, table.pt-sent-table { border-collapse: collapse; font-size: 0.92rem; }
table.pt-mapping th, table.pt-mapping td,
table.pt-results th, table.pt-results td,
table.pt-sent-table th, table.pt-sent-table td {
  border: 1px solid var(--pt-line); padding: 4px 8px; text-align: left; vertical-align: top;
}
table.pt-mapping th, table.pt-results th, table.pt-sent-table th { background: var(--pt-soft); font-weight: 600; }
table.pt-results thead th { position: sticky; top: 0; z-index: 1; }
table.pt-results td.pt-num, table.pt-results th.pt-num { text-align: right; font-variant-numeric: tabular-nums; }
table.pt-results th.pt-calc, table.pt-results td.pt-calc { background: var(--pt-sent-bg); }
table.pt-results td.pt-notes { color: var(--pt-error-line); min-width: 16em; }
.pt-samples { color: var(--pt-muted); font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.85rem; }
.pt-badge { display: inline-block; font-size: 0.8rem; padding: 1px 8px; border-radius: 10px; white-space: nowrap; }
.pt-badge-sent { background: var(--pt-sent-bg); color: var(--pt-accent); }
.pt-badge-local { background: #e9f5ec; color: var(--pt-ok); }

.pt-age-source { border: 1px solid var(--pt-line); border-radius: 8px; padding: 8px 12px; margin: 0 0 12px; }
.pt-age-source legend { font-weight: 600; padding: 0 4px; }
.pt-choice { display: block; font-weight: normal; margin: 4px 0; }
.pt-age-source .pt-hint { margin: 6px 0 0; }
.pt-messages { padding-left: 1.2em; }
.pt-messages li.pt-error { color: var(--pt-error-line); }
.pt-messages li.pt-warning { color: #7a5a00; }

.pt-more { border-top: 1px solid var(--pt-line); margin-top: 24px; color: var(--pt-muted); font-size: 0.95rem; }
.pt-more h2 { font-size: 1.1rem; color: var(--pt-ink); }
.pt-more h3 { font-size: 1rem; color: var(--pt-ink); }
.pt-alert { background: var(--pt-warn-bg); border-left: 4px solid var(--pt-warn-line); padding: 8px 12px; }

.pt-tool-footer { border-top: 1px solid var(--pt-line); padding: 12px 16px; color: var(--pt-muted); font-size: 0.9rem; }
.pt-ad { max-width: 970px; margin: 12px auto 0; }

.pt-visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- patient growth chart (phase 19 E and F): tabs, charts, the point details, the table, printed pages ---------- */
.pt-tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--pt-line); margin-bottom: 12px; }
.pt-tab {
  font: inherit; padding: 6px 14px; border: 1px solid var(--pt-line); border-bottom: 0; border-radius: 6px 6px 0 0;
  background: var(--pt-soft); color: var(--pt-ink); cursor: pointer;
}
.pt-tab[aria-selected="true"] { background: #ffffff; font-weight: 600; position: relative; top: 1px; }
.pt-screen-chart { max-width: 1100px; }
.pt-screen-chart.pt-portrait { max-width: 760px; }
.pt-screen-chart svg { width: 100%; height: auto; display: block; margin-bottom: 12px; }
.pt-point { cursor: pointer; }
.pt-point:focus { outline: none; stroke: #1f2933; stroke-width: 2.5; }
.pt-tip {
  position: absolute; z-index: 10; max-width: 280px; padding: 6px 9px; border-radius: 5px; white-space: pre-line;
  background: #1f2933; color: #ffffff; font-size: 0.85rem; line-height: 1.35; pointer-events: none;
}
table.pt-patient-table { border-collapse: collapse; width: 100%; font-size: 0.85rem; }
table.pt-patient-table th, table.pt-patient-table td { border: 1px solid var(--pt-line); padding: 3px 6px; vertical-align: top; }
table.pt-patient-table th { background: var(--pt-soft); text-align: left; font-weight: 600; }
table.pt-patient-table td.pt-num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.pt-patient-table td.pt-nowrap { white-space: nowrap; }
table.pt-patient-table td.pt-notes { color: var(--pt-error-line); min-width: 16em; }
/* the table's footnotes (owner, 2026-10-26): "outside chart" muted; each mark explained once below the table */
table.pt-patient-table td.pt-outside { color: var(--pt-muted); font-style: italic; }
.pt-table-block { width: 100%; }
.pt-table-footnotes { margin: 6px 0 0; font-size: 0.85rem; }
.pt-table-footnotes p { margin: 2px 0; }

/*
 * Printed pages: 180 x 234 mm inside half-inch margins on Letter or A4 (phase 19 E). Chrome and Firefox print them at
 * that size; Safari (WebKit: also DuckDuckGo, and every browser on iPhone and iPad) enlarges the page to the paper's
 * full printable width (on Letter 190.5 mm, so 106%). A page fits both ways while its height is at most 1.33 times its
 * width (Letter: 254 / 190.5 mm); 234 / 180 = 1.30.
 */
.pt-page {
  width: 180mm; height: 234mm; display: flex; flex-direction: column; overflow: hidden; background: #ffffff;
  margin: 0 0 16px; padding: 0; border: 1px solid var(--pt-line); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}
.pt-page-head { flex: none; display: flex; justify-content: space-between; gap: 12px; align-items: flex-start;
  border-bottom: 1.5px solid var(--pt-ink); padding: 3mm 3mm 2mm; font-size: 9.5pt; }
.pt-page-head dl { display: flex; flex-wrap: wrap; gap: 1mm 6mm; margin: 0; }
.pt-page-head dl div { display: flex; gap: 2mm; }
.pt-page-head dt { color: var(--pt-muted); }
.pt-page-head dd { margin: 0; font-weight: 600; }
.pt-page-note { margin: 1mm 0 0; font-size: 8.5pt; }
.pt-page-chart { margin: 0; text-align: right; font-weight: 600; }
.pt-page-body { flex: 1 1 auto; min-height: 0; padding: 2mm 1mm; display: flex; justify-content: center; align-items: flex-start; }
.pt-page-body svg { width: 100%; height: 100%; }
.pt-page-body table { font-size: 7.5pt; }
.pt-page-body table th, .pt-page-body table td { padding: 2px 4px; }
/* on paper the table fits the page's width: fixed columns (growthchart.js tableHtml), cells that wrap */
table.pt-patient-table.pt-paper { width: 100%; table-layout: fixed; }
table.pt-patient-table.pt-paper td.pt-nowrap, table.pt-patient-table.pt-paper td.pt-num { white-space: normal; }
table.pt-patient-table.pt-paper th, table.pt-patient-table.pt-paper td { overflow-wrap: break-word; }
table.pt-patient-table.pt-paper td.pt-notes { min-width: 0; }
.pt-page-foot { flex: none; display: flex; justify-content: space-between; gap: 6mm; border-top: 1px solid var(--pt-line);
  padding: 1.5mm 3mm; font-size: 7.5pt; color: var(--pt-muted); }
@media screen and (max-width: 820px) {
  .pt-page { width: 100%; height: auto; aspect-ratio: 180 / 234; }
}

/* the patient chart page */
.pt-tool-growthchart .pt-controls, .pt-actions { display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: center; margin: 8px 0; }
.pt-field { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pt-field .pt-choice, .pt-inline { display: inline-flex; gap: 4px; align-items: center; margin: 0; }
.pt-chart-options { display: flex; flex-wrap: wrap; gap: 6px 32px; align-items: center; margin: 0 0 8px; }
.pt-chart-options .pt-hint { flex-basis: 100%; margin: 0; }
/* "Full chart" | "Patient's age range": both in sight, the chosen one filled (owner, 2026-10-23) */
.pt-segmented { display: inline-flex; border: 1px solid var(--pt-accent); border-radius: 6px; overflow: hidden; }
.pt-segmented label { font-weight: normal; margin: 0; padding: 5px 12px; color: var(--pt-accent); background: #fff; cursor: pointer; }
.pt-segmented label + label { border-left: 1px solid var(--pt-accent); }
.pt-segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.pt-segmented label:has(input:checked) { background: var(--pt-accent); color: var(--pt-accent-ink); font-weight: 600; }
.pt-segmented label:has(input:focus-visible) { outline: 2px solid currentColor; outline-offset: -4px; }
.pt-patient-line { font-weight: 600; margin: 0 0 4px; }
.pt-entry { margin: 12px 0; }
.pt-save { border-top: 1px dashed var(--pt-line); margin-top: 12px; padding-top: 8px; }
.pt-save p { margin: 4px 0; }
.pt-entry summary { cursor: pointer; color: var(--pt-accent); }
.pt-entry fieldset { border: 1px solid var(--pt-line); border-radius: 8px; padding: 8px 12px; margin: 8px 0; }
.pt-entry legend { font-weight: 600; padding: 0 4px; }
.pt-patient-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px 16px; }
.pt-patient-fields label { display: flex; flex-direction: column; gap: 2px; margin: 0; font-weight: 600; }
.pt-patient-fields input, .pt-patient-fields select, .pt-patient-fields textarea { font: inherit; font-weight: normal; margin: 0; }
.pt-patient-fields .pt-wide { grid-column: 1 / -1; }
table.pt-grid { border-collapse: collapse; font-size: 0.92rem; }
table.pt-grid th, table.pt-grid td { border: 1px solid var(--pt-line); padding: 2px 4px; vertical-align: top; }
table.pt-grid th { background: var(--pt-soft); font-weight: 600; text-align: left; }
table.pt-grid th select { display: block; margin-top: 2px; font-size: 0.85rem; }
table.pt-grid td input { width: 9.5em; border: 0; padding: 4px; font: inherit; }
table.pt-grid td input:focus { outline: 2px solid var(--pt-accent); }
table.pt-grid .pt-unused { color: var(--pt-muted); font-weight: normal; }
.pt-print-pages { display: none; }
/* the printed table laid out off screen at the page's size, to split it into pages (growthchart.js tablePages) */
.pt-print-probe { position: absolute; left: -10000px; top: 0; visibility: hidden; }
.pt-print-probe .pt-page { width: 180mm; height: 234mm; aspect-ratio: auto; }

@media (max-width: 640px) {
  .pt-tool-header { flex-direction: column; gap: 0; }
  .pt-tool-main h1 { font-size: 1.35rem; }
}

@media print {
  @page { size: letter portrait; margin: 0.5in; }
  /* the patient chart page prints only its pages (made when Print is chosen) */
  body.pt-tool-growthchart > :not(.pt-print-pages) { display: none !important; }
  body.pt-tool-growthchart .pt-print-pages { display: block; }
  body.pt-tool-growthchart .pt-page { margin: 0; border: 0; box-shadow: none; break-after: page; page-break-after: always; }
  body.pt-tool-growthchart .pt-page:last-child { break-after: auto; page-break-after: auto; }
  body.pt-tool { font-size: 10pt; }
  .pt-tool-header, .pt-tool-footer, .pt-start, .pt-actions, .pt-privacy, .pt-more, button, details, select { display: none !important; }
  .pt-step { border: 0; }
  .pt-table-wrap { overflow: visible; }
  table.pt-results thead th { position: static; }
  a { color: inherit; text-decoration: none; }
}

/* ---------- The patient growth chart page's layout (owner, 2026-10-22, phase 19 G); the bulk page's alike (2026-10-23) ---------- */
/* Part 1: the chart choice (Brooks CP's GMFCS level) under the chart */
.pt-choice-field { margin: 8px 0 0; }
.pt-choice-field label { font-weight: 600; margin-right: 6px; }
/* Part 2: one line of privacy; three ways in as cards (stacked on a phone); once loaded, one summary box */
.pt-privacy { margin: 0 0 10px; font-size: 0.92em; }
.pt-start { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 0 0 10px; }
.pt-start-two { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); } /* the bulk page: open a file, try an example */
@media (max-width: 720px) { .pt-start, .pt-start-two { grid-template-columns: 1fr; } }
.pt-card { border: 1px solid var(--pt-line); border-radius: 8px; padding: 12px 14px; background: #fff; }
.pt-card h3 { font-size: 1rem; margin: 0 0 8px; }
.pt-card p { margin: 0 0 8px; }
.pt-card .pt-drop { padding: 12px 10px; margin: 0 0 10px; }
.pt-card-line { margin: 0 0 6px; }
.pt-card .pt-paste summary { cursor: pointer; color: var(--pt-accent); text-decoration: underline; }
.pt-card .pt-paste textarea { width: 100%; margin: 6px 0; }
.pt-loaded { border: 1px solid var(--pt-line); border-radius: 8px; background: var(--pt-soft); padding: 8px 14px; margin: 0 0 10px; }
.pt-loaded .pt-status p { margin: 4px 0; }
.pt-loaded .pt-save { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 6px 0 4px; }
.pt-loaded .pt-save #pt-change { margin-right: 14px; }
.pt-loaded .pt-sheet { margin: 6px 0; }
/* Part 3: the patient's growth chart in its own panel, set apart from the data entry; the print bar as one toolbar.
   The bulk page's results alike: the downloads as one bar, the advanced options a full row of it when opened */
.pt-chart-panel { border: 1px solid var(--pt-line); border-radius: 10px; background: var(--pt-soft); padding: 12px 16px 16px; margin-top: 24px; }
.pt-chart-panel .pt-actions { border: 1px solid var(--pt-line); border-radius: 8px; background: #fff; padding: 10px 12px; margin-top: 12px; }
.pt-actions .pt-advanced { margin: 0; }
.pt-actions .pt-advanced[open] { flex-basis: 100%; }
.pt-chart-panel table.pt-results { background: #fff; }
/* Plot options (phase 19 H): behind a disclosure, the "Full chart" switch beside it; the key or banner for the ages */
.pt-plot-options { flex-basis: 100%; }
.pt-plot-options > summary { cursor: pointer; color: var(--pt-accent); font-weight: 600; }
.pt-plot-options-body { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 8px 24px;
  background: #fff; border: 1px solid var(--pt-line); border-radius: 8px; padding: 10px 14px; margin-top: 6px; }
.pt-plot-options fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.pt-plot-options legend, .pt-plot-options legend label { font-weight: 600; padding: 0; margin: 0 0 2px; }
.pt-plot-options .pt-choice { margin: 2px 0; }
.pt-plot-options .pt-choice:has(input:disabled) { color: var(--pt-muted); }
.pt-plot-options .pt-field { margin: 2px 0 4px; }
.pt-plot-options .pt-hint { display: block; }
.pt-sample { display: inline-block; width: 26px; height: 12px; vertical-align: -1px; color: var(--pt-ink); }
/* an age's check box, its marker's sample and its list on one line (owner, 2026-10-26) */
.pt-age-choice { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pt-age-choice select { font: inherit; font-size: 0.9em; padding: 1px 4px; }
.pt-age-key { font-size: 0.92rem; margin: 0 0 6px; }
.pt-age-key span { display: inline-block; margin-right: 18px; }
.pt-age-key .pt-hint { font-size: inherit; }
.pt-age-banner { background: var(--pt-warn-bg); border-left: 4px solid var(--pt-warn-line); padding: 6px 12px; margin: 0 0 8px; max-width: 1000px; }
/* the table with both ages: two lines per date, the corrected age's lighter */
table.pt-patient-table tr.pt-line-first td { border-top: 2px solid #c3cbd3; }
table.pt-patient-table tr.pt-line-corrected td { color: #46525e; background: #f7f9fb; }
table.pt-patient-table tr.pt-line-corrected td[rowspan] { color: var(--pt-ink); background: #fff; }
/* Help: a short how-to, then the sections, closed until opened */
.pt-help details { border-top: 1px solid var(--pt-line); padding: 6px 0; }
.pt-help details:last-of-type { border-bottom: 1px solid var(--pt-line); }
.pt-help summary { cursor: pointer; font-weight: 600; }
.pt-help details > :not(summary) { margin-left: 18px; }
/* "Growth across visits" (phase 25 D): a tinted panel (owner, 2026-11-15: a pulldown was hard to notice); a button per
   tool, then the earlier visit and Open */
.pt-tool-growthchart .pt-across { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin: 10px 0 12px;
  padding: 10px 12px; border: 1px solid var(--pt-accent, #0b62a4); border-left-width: 4px; border-radius: 6px;
  background: var(--pt-info-bg, rgba(11, 90, 162, 0.07)); }
.pt-tool-growthchart .pt-across-title { font-weight: 700; }
.pt-tool-growthchart .pt-across-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.pt-tool-growthchart .pt-across-tool { padding: 4px 12px; border-radius: 999px; border: 1px solid var(--pt-accent, #0b62a4);
  background: transparent; color: inherit; font: inherit; cursor: pointer; }
.pt-tool-growthchart .pt-across-tool[aria-pressed="true"] { background: var(--pt-accent, #0b62a4); color: var(--pt-accent-text, #fff); }
.pt-tool-growthchart .pt-across-visit { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; flex-basis: 100%; }
.pt-tool-growthchart .pt-across select { max-width: 100%; }
