:root {
  --text: #000000;
  --grid: #d9d9d9;
  --blue: #063cff;
  --yellow: #ffff33;
  --cyan: #62f4ff;
  --low: #00d800;
  --high: #ff0000;
  --orange: #ff8a00;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: #f2f2f2;
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}
.excel-page {
  padding: 10px;
  display: flex;
  justify-content: center;
}
.worksheet-frame {
  width: 1420px;
  min-height: 860px;
  background: #ffffff;
  border: 2px solid #000;
  padding: 14px 16px 12px;
  position: relative;
  box-shadow: 0 0 0 1px #888;
}
.main-title {
  width: 1110px; /* Align title width with the chart/graph column, not the full worksheet. */
  text-align: center;
  font-size: 29px;
  font-weight: 700;
  margin: 0 0 7px;
}
.top-strip.excel-top-layout {
  display: grid;
  grid-template-columns: 300px 205px 285px 226px;
  gap: 8px;
  align-items: center;
  margin-left: 49px;
  margin-bottom: 8px;
}
.ga-strip {
  display: grid;
  grid-template-columns: 80px 54px 48px 48px;
  gap: 8px;
  align-items: center;
  justify-content: start;
  padding: 10px 10px;
  min-height: 74px;
  border: 1px solid #999;
  background: #fff;
}
.ga-label {
  font-size: 15px;
  line-height: 1.15;
  text-align: right;
  font-weight: 700;
}
.ga-label span { font-size: 12px; font-weight: 400; }
.ga-cell {
  appearance: none;
  background: #fff;
  border: 3px solid #000;
  width: 100%;
  height: 34px;
  color: var(--blue);
  font-size: 22px;
  line-height: 1;
  text-align: center;
  text-align-last: center;
  font-weight: 700;
  padding: 0 2px;
  border-radius: 0;
}
.excel-grid.excel-grid-left-data {
  display: grid;
  grid-template-columns: 1110px 245px;
  gap: 16px;
  align-items: start;
}
.left-column {
  align-self: start;
  grid-column: 2;
  grid-row: 1;
}


.chart-wrap {
  width: 1110px;
  height: 610px;
  border-left: 0;
  border-bottom: 0;
  position: relative;
}
#chartCanvas {
  width: 100% !important;
  height: 100% !important;
}

.demo-note strong { font-weight: 700; }
.excel-box {
  border: 2px solid #000;
  background: #fff;
  padding: 5px 5px;
}
.light-box {
  border: 1px solid #bfbfbf;
  background: #fff;
  padding: 6px 7px;
  min-height: 52px;
}
.box-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 5px;
  color: #001a80;
}
.controls-box label, .xaxis-controls label {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 22px;
  font-size: 13px;
  white-space: nowrap;
}
.controls-box label:has(input:checked), .xaxis-controls label:has(input:checked) { font-weight: 700; }
.control-label {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 3px;
  color: #001a80;
}
input[type="radio"] {
  width: 14px;
  height: 14px;
  margin: 0;
}
.legend-line {
  margin-left: auto;
  width: 54px;
  height: 0;
  border-top-style: solid;
  border-top-width: 6px;
  display: inline-block;
  flex: 0 0 54px;
}
.legend-line.low { border-top-color: var(--low); }
.legend-line.high { border-top-color: var(--high); }
.legend-line.dashed { border-top-style: dashed; border-top-width: 3px; }
.legend-box { padding-top: 5px; }
.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  margin: 5px 0;
  line-height: 1.15;
}
.legend-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1px solid #000;
  display: inline-block;
  flex: 0 0 11px;
}
.legend-dot.tsb { background: var(--orange); }
.legend-dot.tcb { background: var(--blue); }
.data-panel { padding: 5px 5px 6px; height: 610px; }
.data-header-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 3px;
}
.data-header-row .box-title { margin: 0; font-size: 14px; white-space: nowrap; }
.button-row {
  margin-left: auto;
  display: flex;
  gap: 3px;
}
button {
  height: 21px;
  border: 1px solid #999;
  border-radius: 0;
  background: #e6e6e6;
  color: #000;
  font-weight: 700;
  padding: 0 4px;
  font-size: 9px;
  cursor: pointer;
}
button.secondary { background: #f0f0f0; color: #000; }
.data-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}
.data-table th, .data-table td {
  border: 1px solid #bfbfbf;
  padding: 0 1px;
  font-size: 10px;
  line-height: 1.0;
  height: 17.9px;
  text-align: center;
}
.data-table th {
  background: #e7e6e6;
  font-weight: 700;
  height: 25px;
}
.data-table input {
  width: 100%;
  height: 17px;
  padding: 0 1px;
  border: 0;
  border-radius: 0;
  background: #ffffff;
  font-size: 10px;
  text-align: center;
}
.data-table input:focus {
  outline: 2px solid #1c61ff;
  outline-offset: -2px;
}
.data-table th:nth-child(1), .data-table td:nth-child(1) { width: 18px; }
.data-table th:nth-child(2), .data-table td:nth-child(2) { width: 42px; }
.data-table th:nth-child(3), .data-table td:nth-child(3) { width: 27px; }
.data-table th:nth-child(4), .data-table td:nth-child(4) { width: 34px; }
.data-table th:nth-child(5), .data-table td:nth-child(5) { width: 34px; }
.row-number { color: #000; background: #f7f7f7; }
.xaxis-controls {
  margin: 8px auto 0;
  width: 820px;
  min-height: 48px;
  display: grid;
  grid-template-columns: 130px 135px 125px 1fr;
  gap: 10px;
  align-items: center;
}
.xaxis-controls .control-label { margin: 0; }
@media (max-width: 1100px) {
  .worksheet-frame { width: 100%; overflow-x: auto; }
  .excel-grid.excel-grid-left-data { grid-template-columns: 1110px 245px; }
}
.guideline-box, .risk-box, .legend-box { min-height: 52px; padding-top: 5px; padding-bottom: 4px; }
.risk-box .legend-line { width: 48px; flex-basis: 48px; }
.xaxis-controls { background: #eeeeee !important; border: 1px solid #9d9d9d; }


/* v25 patient-data refinements */

/* Remove spinner/data selector controls from patient-data numeric boxes, including TSB/TcB. */
.patient-table input[type="number"]::-webkit-outer-spin-button,
.patient-table input[type="number"]::-webkit-inner-spin-button,
.patient-data input[type="number"]::-webkit-outer-spin-button,
.patient-data input[type="number"]::-webkit-inner-spin-button,
#patientData input[type="number"]::-webkit-outer-spin-button,
#patientData input[type="number"]::-webkit-inner-spin-button,
td input[type="number"]::-webkit-outer-spin-button,
td input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.patient-table input[type="number"],
.patient-data input[type="number"],
#patientData input[type="number"],
td input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* 10-second pending-sort visual cue. */
.pending-sort-row,
.pending-sort-row td,
tr.pending-sort-row td {
  background-color: #d9ecff !important;
}

.plain-header-note {
  font-weight: 400;
  font-style: normal;
  color: inherit;
}


/* v26 patient-data workflow */
.pending-sort-row td { background-color: #d9ecff !important; }
.plain-header-note { font-weight: 400; font-style: normal; color: inherit; font-size: 12px; }
#patientTable input[type="number"]::-webkit-outer-spin-button,
#patientTable input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
#patientTable input[type="number"] { -moz-appearance: textfield; appearance: textfield; }


/* v28: Hours subnote under header, 2 points smaller than header text */



/* v34: plain subheaders under Age and Hours */


/* v34: highlight entire Patient Data row when any field in that row is active */



/* v36: header subnotes (days) and (≤168) same size and bold */
.header-subnote-bold {
  font-size: calc(1em - 0.5pt);
  font-weight: 700;
  font-style: normal;
  line-height: 1.0;
}


/* v37: blue fill for active Patient Data row data cells */




/* v38: active/delayed Patient Data row fill */





























/* v47: note lives inside chart area and is centered under the graph/X-axis area */
.chart-area .demo-note {
  width: calc(100% - 58px);
  max-width: calc(100% - 58px);
  box-sizing: border-box;
  margin: 16px 0 0 58px;
  border: none !important;
  padding: 0 4px;
  text-align: center;
  line-height: 1.25;
}

.chart-area 

.no-break {
  white-space: nowrap;
}


/* v49: blue fill for active/current Patient Data row */
#patientTable tbody tr.active-data-row > td {
  background-color: #d9ecff !important;
}
#patientTable tbody tr.active-data-row > td input {
  background-color: #d9ecff !important;
}


/* v50: Patient Data table without # column; 26 rows aligned to graph */
.data-panel {
  height: 100% !important;
}

.data-table {
  table-layout: fixed !important;
  width: 100% !important;
}

/* Four remaining columns fill the unchanged Patient Data object width */
.data-table th:nth-child(1),
.data-table td:nth-child(1) {
  width: 28% !important; /* Age */
}
.data-table th:nth-child(2),
.data-table td:nth-child(2) {
  width: 24% !important; /* Hours */
}
.data-table th:nth-child(3),
.data-table td:nth-child(3) {
  width: 24% !important; /* TSB */
}
.data-table th:nth-child(4),
.data-table td:nth-child(4) {
  width: 24% !important; /* TcB */
}

/* Slightly taller rows to balance 26 rows vertically */
.data-table th,
.data-table td {
  height: 18.6px !important;
  padding-top: 1px !important;
  padding-bottom: 1px !important;
}

/* Align Patient Data panel with graph vertically */
.left-column {
  align-self: stretch !important;
}
.excel-grid-left-data {
  align-items: stretch !important;
}








/* v53: Patient Data frame is positioned/sized by Chart.js plot area */
.data-panel {
  box-sizing: border-box !important;
  overflow: hidden !important;
  display: flex !important;
  flex-direction: column !important;
}

.data-table {
  table-layout: fixed !important;
  width: 100% !important;
  flex: 1 1 auto !important;
}

.data-table tbody {
  overflow: hidden !important;
}

.data-table th,
.data-table td {
  box-sizing: border-box !important;
  line-height: 1.05 !important;
}

/* v53: do not force Legend height; match via normal top-strip alignment */
.top-strip {
  align-items: stretch !important;
}

.top-strip .light-box,
.top-strip .controls-box,
.top-strip .legend-box,
.top-legend {
  align-self: stretch !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
}


/* v54: active Patient Data row fill support */
#patientTable tbody tr.active-data-row > td {
  background-color: #d9ecff !important;
}
#patientTable tbody tr.active-data-row > td input {
  background-color: #d9ecff !important;
}

/* remove grey borders from top boxes */
.light-box, .controls-box, .legend-box {
  border: none !important;
}

/* unified top strip border */


/* tighten risk line spacing */
.risk-line {
  margin-left: 6px !important;
}


/* v56: borders */
.data-panel {
  border: 2px solid #999 !important;
}

/* Top control strip is one bordered group sized by JS to chart X-axis width */
.top-strip {
  border: 2px solid #999 !important;
  padding: 6px !important;
  box-sizing: border-box !important;
  align-items: stretch !important;
}

/* Remove individual grey borders including GA Weeks/Days */
.top-strip .light-box,
.top-strip .controls-box,
.top-strip .legend-box,
.top-strip .ga-box,
.ga-box,
.ga-control,
.ga-panel {
  border: none !important;
  box-shadow: none !important;
}

/* Pull risk legend lines closer to text */
.risk-box label {
  display: flex !important;
  align-items: center !important;
  gap: 4px !important;
}

.risk-box .legend-line,
#riskLowLine,
#riskHighLine {
  margin-left: 4px !important;
}




/* v58: remove GA Weeks/Days frame completely */
.top-strip > :first-child,
.top-strip > :first-child.light-box,
.top-strip > :first-child.controls-box,
.ga-box,
.ga-panel,
.ga-control,
.ga-section,
.ga-input-box {
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  background-clip: padding-box !important;
}

/* v58: remove visual gridlines below Patient Data row 22'; v156: changed to n+18 */
#patientTable tbody tr:nth-child(n+18) td {
  border-left: none !important;
  border-right: none !important;
  border-top: none !important;
  border-bottom: none !important;
  background: transparent !important;
}
#patientTable tbody tr:nth-child(n+18) input {
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  background: transparent !important;
  color: transparent !important;
  pointer-events: none !important;
}

/* v58: lighter added borders */
.data-panel {
  border: 2px solid #999 !important;
}
.top-strip {
  border: 2px solid #999 !important;
  padding: 6px !important;
  box-sizing: border-box !important;
}

/* v58: exact two-line bottom note */
/* v59: bottom note lines fit within chart width */
/* v60: slightly larger bottom text */

/* v63: preserve v61 bottom note font size */
.demo-line {
  display: block;
  text-align: center !important;
  white-space: nowrap;
  font-size: 13.2px !important;
  line-height: 1.2 !important;
}


/* v65: fixed left anchor for Risk legend lines; radio/text layout unchanged */
.risk-box {
  position: relative !important;
}

.risk-box label {
  display: block !important;
  position: relative !important;
  padding-left: 0 !important;
  white-space: nowrap !important;
}

.risk-box .legend-line,
#riskLowLine,
#riskHighLine {
  position: absolute !important;
  left: 183px !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}


/* v73: draw top-strip frame inside the object to prevent right-edge clipping */
.top-strip {
  border: none !important;
  box-shadow: inset 0 0 0 2px #999 !important;
  overflow: visible !important;
  box-sizing: border-box !important;
}

.current-axis-option {
  white-space: nowrap;
}

.current-axis-combo {
  position: relative;
  display: inline-flex;
  align-items: stretch;
  margin: 0 3px;
  vertical-align: middle;
}

.current-axis-days-input {
  width: 5.8em;
  height: 2.45em;
  min-height: 2.45em;
  font: inherit;
  font-weight: inherit;
  text-align: center;
  padding: 4px 8px;
  box-sizing: border-box;
  border: 1px solid #777;
  border-right: 0;
  border-radius: 3px 0 0 3px;
}

.current-axis-dropdown-button {
  width: 2.4em;
  height: 2.45em;
  min-height: 2.45em;
  font: inherit;
  font-weight: 700;
  line-height: 1;
  padding: 0;
  border: 1px solid #777;
  border-radius: 0 3px 3px 0;
  background: #f7f7f7;
  cursor: pointer;
}

.current-axis-dropdown {
  position: absolute;
  left: 0;
  top: auto;
  bottom: calc(100% + 2px);
  width: 8.2em;
  max-height: 18em;
  overflow-y: auto;
  z-index: 10000;
  background: #ffffff;
  border: 1px solid #777;
  box-shadow: 0 3px 8px rgba(0,0,0,0.25);
}

.current-axis-dropdown-item {
  display: block;
  width: 100%;
  padding: 5px 8px;
  text-align: center;
  font: inherit;
  border: 0;
  background: #ffffff;
  cursor: pointer;
}

.current-axis-dropdown-item:hover,
.current-axis-dropdown-item.selected {
  background: #dfefff;
}


/* v81: open the current-age day selector upward and center a wider X-axis panel under the graph's active area. */
.current-axis-dropdown {
  top: auto !important;
  bottom: calc(100% + 2px) !important;
}
.xaxis-controls {
  width: 820px !important;
  min-height: 48px !important;
  grid-template-columns: 130px 135px 125px 1fr !important;
  gap: 10px !important;
}

/* v82: center the X-axis control contents within a panel that is aligned to the chart X-axis. */
.xaxis-controls {
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  gap: 38px !important;
  width: auto !important;
  min-height: 48px !important;
  padding-left: 10px !important;
  padding-right: 10px !important;
}
.xaxis-controls .control-label,
.xaxis-controls label {
  flex: 0 0 auto !important;
}


/* v98: bottom demonstration note link styling */
.about-info-link,
.about-info-link:visited {
  color: #0057ff;
  text-decoration: underline;
  font-weight: 400;
}

.about-info-link:hover,
.about-info-link:active {
  color: #003cc0;
  text-decoration: underline;
}

/* v103: restore Patient Data header button proportions while allowing browser wrapping. */
.data-header-row .button-row {
  flex: 1 1 auto;
  min-width: 0;
  justify-content: flex-end;
}
.data-header-row .button-row button {
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
  flex: 0 0 auto;
  height: 22px;
  line-height: 1.05;
  font-size: 9px;
  padding: 0 1px;
  letter-spacing: 0;
}
#loadDemoButton { width: 84px; }
#clearButton { width: 58px; }


/* v103/v8: scale the fixed Excel-like GUI as one unit for narrow desktop windows and phones. */
html, body {
  min-width: 0 !important;
  overflow: auto;
}
.excel-page {
  min-width: 0 !important;
  align-items: flex-start;
}
.autoscale-shell {
  position: relative;
  flex: 0 0 auto;
}
@media (max-width: 1100px) {
  .worksheet-frame {
    width: 1420px !important;
    overflow: visible !important;
  }
}

/* v103/v9: in-page About/Information panel for mobile-safe display. */
.about-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: none;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 14px;
  background: rgba(0, 0, 0, 0.28);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.about-modal-panel {
  width: min(760px, 96vw);
  max-height: 92vh;
  box-sizing: border-box;
  padding: 30px 42px 18px;
  background: #fff;
  color: #000;
  border: 1px solid #777;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.30);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  font-family: "Times New Roman", Times, serif;
}
.about-modal-content {
  font-size: 18px;
  line-height: 1.35;
}
.about-modal-content p {
  margin: 0 0 24px;
}
.about-modal-content .about-title {
  margin-bottom: 18px;
  font-size: 19px;
}
.about-modal-content ul {
  margin: -16px 0 24px 26px;
  padding-left: 22px;
}
.about-modal-content li {
  margin: 0 0 10px;
  padding-left: 8px;
}
.about-modal-button-row {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #ddd;
  text-align: right;
  font-family: Arial, Helvetica, sans-serif;
}
.about-modal-button-row button {
  min-width: 82px;
  height: 28px;
  font-size: 13px;
  font-weight: 700;
  border: 1px solid #999;
  background: #e6e6e6;
  cursor: pointer;
}
@media (max-width: 700px), (max-height: 520px) {
  .about-modal-overlay {
    align-items: flex-start;
    justify-content: center;
    padding: 8px;
  }
  .about-modal-panel {
    width: 98vw;
    max-height: 96vh;
    padding: 16px 18px 12px;
  }
  .about-modal-content {
    font-size: 15px;
    line-height: 1.28;
  }
  .about-modal-content .about-title {
    font-size: 16px;
    margin-bottom: 12px;
  }
  .about-modal-content p {
    margin-bottom: 14px;
  }
  .about-modal-content ul {
    margin: -8px 0 14px 18px;
    padding-left: 18px;
  }
  .about-modal-content li {
    margin-bottom: 7px;
    padding-left: 4px;
  }
}


/* v103/v10: make the Information panel open already fit-to-phone. */
.about-modal-panel {
  transform-origin: top center;
}
@media (max-width: 700px), (max-height: 520px) {
  .about-modal-overlay {
    align-items: flex-start !important;
    justify-content: center !important;
    padding: 4px !important;
  }
  .about-modal-panel {
    width: 96vw !important;
    max-width: 96vw !important;
    max-height: none !important;
    padding: 10px 12px 8px !important;
    overflow: visible !important;
  }
  .about-modal-content {
    font-size: 11.5px !important;
    line-height: 1.16 !important;
  }
  .about-modal-content .about-title {
    font-size: 12.5px !important;
    margin-bottom: 7px !important;
  }
  .about-modal-content p {
    margin-bottom: 8px !important;
  }
  .about-modal-content ul {
    margin: -4px 0 8px 12px !important;
    padding-left: 12px !important;
  }
  .about-modal-content li {
    margin-bottom: 4px !important;
    padding-left: 2px !important;
  }
  .about-modal-button-row {
    position: relative !important;
    margin-top: 4px !important;
    padding-top: 5px !important;
    text-align: right !important;
  }
  .about-copyright {
    position: absolute !important;
    left: 0;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    text-align: center;
    font-size: 10px;
    color: #777;
    pointer-events: none;
  }
  .about-modal-button-row button {
    height: 22px !important;
    min-width: 62px !important;
    font-size: 10.5px !important;
  }
}


/* v84: top control frame aligns with the chart box below. */
.top-strip.excel-top-layout {
  margin-left: 49px !important;
  width: 1052px !important;
  max-width: 1052px !important;
}




/* v156: stable 18 visible Patient Data rows; rows 19+ are hidden. */
#patientTable tbody tr:nth-child(-n+18) {
  display: table-row !important;
}
#patientTable tbody tr:nth-child(-n+18) td {
  border: 1px solid #bfbfbf !important;
  background: #fff;
}
#patientTable tbody tr:nth-child(-n+18) input {
  color: #000 !important;
  pointer-events: auto !important;
  background: #fff !important;
}
#patientTable tbody tr:nth-child(n+18) {
  display: none !important;
}
#patientTable tbody tr:nth-child(n+18) td,
#patientTable tbody tr:nth-child(n+18) input {
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  background: transparent !important;
  color: transparent !important;
  pointer-events: none !important;
}
