/* Enhanced Access Planner.
 *
 * Phase E2. Written for this service on the shell's own tokens (`--hs-*`). The monolith's page styled itself with
 * a 79-line sheet plus 120 `style` attributes, none of which this service's Content Security Policy admits; the
 * look (summary strip, requirement box, session table, compliance chips, the floating action panel, the print
 * layout) is the source's, and every width, colour and state is a class here. Show/hide is the `hidden`
 * attribute, kept authoritative below.
 */
:root {
  --ea-border: var(--hs-border, #dfe4ec);
  --ea-ink: var(--hs-ink, #1f2937);
  --ea-mut: var(--hs-ink-muted, #55637a);
  --ea-surface: var(--hs-surface, #fff);
  --ea-accent: var(--hs-aqua, #0d5bb8);
  /* Chart.js draws on a canvas and cannot read a class; the script reads this one value so the chart colour is
     declared here, once, and is the source's own theme colour. */
  --ea-chart-accent: #0ea5e9;
  --ea-tint: #f0f4ff;
  --ea-good: #166534;
  --ea-bad: #b91c1c;
  --ea-radius: 10px;
}

.ea-wrap { max-width: 1520px; margin: 0 auto; padding: 0 0 48px; }
.ea-wrap [hidden] { display: none !important; }
.ea-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.ea-offscreen { position: fixed; opacity: 0; }
.ea-eyebrow { font-size: 11px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: var(--ea-accent); margin: 0 0 3px; }
.ea-title { font-size: 1.75rem; font-weight: 800; color: var(--ea-ink); margin: 0 0 14px; line-height: 1.2; }

.ea-attribution { background: var(--ea-tint); border-left: 4px solid var(--ea-accent); border-radius: 0 6px 6px 0; padding: 14px 18px; font-size: 13px; color: #4b5563; margin-bottom: 18px; }
.ea-hint { background: var(--ea-tint); border-left: 4px solid var(--ea-accent); border-radius: 0 6px 6px 0; padding: 12px 16px; margin-bottom: 20px; font-size: 13px; color: #4b5563; line-height: 1.6; }
.ea-warn { background: #fef3c7; color: #5c3a05; border: 1px solid #e6c34a; border-radius: 8px; padding: 10px 14px; font-size: 13px; margin: 0 0 14px; }
.ea-error { background: #fff3f3; border: 1px solid #e74c3c; border-radius: 4px; padding: 12px 16px; font-size: 13px; color: #c0392b; margin-top: 12px; text-align: left; }
.ea-note { font-size: 13px; color: #666; margin: 0 0 16px; }
.ea-hint-small { font-size: 11px; color: #596273; margin: 4px 0 0; }
.ea-status { font-size: 12px; color: #596273; margin: 8px 0 0; min-height: 1em; }
.ea-opt { font-weight: 400; color: #596273; }
.ea-faint { color: #596273; }
.ea-muted { color: #555; }
.ea-strong { font-weight: 600; }
.ea-center { text-align: center; margin-bottom: 16px; }
/* Positioned, so the visually hidden header inside the table is contained by this scroll box: an absolutely positioned child with no positioned ancestor escapes it and gives the whole document a horizontal scrollbar. */
.ea-scroll { overflow-x: auto; position: relative; }
.ea-label { display: block; font-size: 13px; font-weight: 600; color: #444; margin-bottom: 6px; }
.ea-prefill { margin-bottom: 20px; padding-bottom: 20px; border-bottom: 1px solid #f0f0f0; }
.ea-chipwrap { display: block; max-width: 460px; }
.ea-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px 24px; align-items: start; }
.ea-field { min-width: 0; }
.ea-input { width: 100%; padding: 8px 12px; font-size: 14px; border: 1px solid #ced4da; border-radius: 4px; background: #fff; color: var(--ea-ink); box-sizing: border-box; }
.ea-input-mins { width: 110px; padding: 4px 8px; font-size: 13px; }

.haresign-tool-card { background: var(--ea-surface); border: 1px solid var(--ea-border); border-radius: var(--ea-radius); box-shadow: 0 1px 6px rgba(0,0,0,0.06); padding: 22px 24px; margin-bottom: 22px; }
.ea-fill { height: 100%; margin-bottom: 0; }
.ea-section-head { font-size: 16px; font-weight: 700; color: #111827; margin: 0 0 16px; padding-bottom: 12px; border-bottom: 1px solid #e8edf2; }
.ea-mobile-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.ea-small-btn { background: none; border: 1px solid #ccc; color: #555; padding: 6px 14px; border-radius: 4px; font-size: 12px; cursor: pointer; min-height: 32px; }

.ea-table th, .results-table th, .practice-req-table th, .session-head th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; color: #4f5d6b; background: #f8fafc; white-space: nowrap; }
.ea-table td, .results-table td, .practice-req-table td { font-size: 13px; vertical-align: middle; }
.session-row td { vertical-align: middle; font-size: 13px; padding: 6px; }
.session-row .ea-input { padding: 5px 8px; font-size: 13px; border-color: #d1d9e0; border-radius: 6px; }
.ea-row-hrs { color: var(--ea-accent); font-weight: 700; }
.ea-col-name { min-width: 160px; }
.ea-col-num { min-width: 100px; }
.ea-col-buf { min-width: 90px; }
.ea-col-x { width: 40px; }
.results-table .total-row, .practice-req-table .total-row { background: var(--ea-tint); font-weight: 700; }
.add-row-btn { background: none; border: 1px dashed var(--ea-accent); color: var(--ea-accent); border-radius: 6px; padding: 6px 16px; font-size: 13px; cursor: pointer; margin-top: 8px; min-height: 32px; }
.add-row-btn:hover { background: var(--ea-tint); }
.remove-btn { background: none; border: none; color: #94a3b8; cursor: pointer; font-size: 18px; padding: 0 8px; min-width: 32px; min-height: 32px; }
.remove-btn:hover { color: #dc2626; }
.ea-calc { text-align: center; margin-bottom: 28px; }
.btn-calc { background: var(--ea-accent); color: #fff; border: none; padding: 10px 32px; border-radius: 6px; font-weight: 700; font-size: 14px; cursor: pointer; min-height: 40px; }
.btn-calc:hover { opacity: .9; }
.btn-export { background: #fff; color: #111827; border: 1px solid #d1d9e0; padding: 6px 14px; border-radius: 6px; font-size: 12px; font-weight: 600; cursor: pointer; min-height: 32px; }
.btn-export:hover { background: #f8fafc; border-color: #9ca3af; }
#results-export-toolbar { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }

.summary-strip { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 24px; }
.summary-box { flex: 1; min-width: 130px; background: #f8fafc; border-radius: 8px; padding: 16px; text-align: center; border: 1px solid #e8edf2; }
.summary-box .s-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; color: #4f5d6b; margin-bottom: 6px; }
.summary-box .s-value { font-size: 1.4rem; font-weight: 700; color: #111827; }
.summary-box.surplus .s-value { color: var(--ea-good); }
.summary-box.deficit .s-value { color: var(--ea-bad); }
.compliance-badge { display: inline-block; padding: 6px 16px; border-radius: 20px; font-size: 13px; font-weight: 700; }
.compliance-badge.met { background: #d4edda; color: #155724; }
.compliance-badge.not-met { background: #f8d7da; color: #721c24; }
.req-box { background: var(--ea-tint); border: 1px solid #c7d8f5; border-radius: 8px; padding: 20px 24px; }
.req-box .req-number { font-size: 2rem; font-weight: 800; color: var(--ea-accent); line-height: 1; }
.req-box .req-label { font-size: 13px; color: #4b5563; margin-top: 4px; }

#shortfall-advisor { background: #fff8f0; border: 1px solid #f5c07a; border-radius: 6px; padding: 14px 20px; margin-bottom: 24px; font-size: 13px; color: #7a4a00; }
.ea-balance { margin-top: 10px; font-size: 13px; padding: 10px 14px; border-radius: 4px; }
.ea-balance-ok { background: #d4edda; color: #155724; }
.ea-balance-warn { background: #fff3cd; color: #856404; }
.ea-gap { font-weight: 600; }
.ea-gap-ok { color: #1e7e4a; }
.ea-gap-bad { color: #c0392b; }
.ea-gap-none { color: #596273; }
.ea-chip { padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 700; display: inline-block; }
.ea-chip-met { background: #d4edda; color: #155724; }
.ea-chip-short { background: #f8d7da; color: #721c24; }
.ea-chip-none { background: #f0f0f0; color: #555; font-weight: 400; }

.ea-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; margin-bottom: 22px; }
.ea-chart-box { position: relative; }
.ea-chart-220 { height: 220px; }
.chart-sub-title { font-size: 12px; font-weight: 700; color: #4b5563; text-transform: uppercase; letter-spacing: 0.6px; margin: 0 0 4px; }
.chart-desc { font-size: 12px; color: #596273; line-height: 1.6; margin: 0 0 14px; }
.chart-desc-green { color: var(--ea-good); font-weight: 600; }
.chart-desc-red { color: var(--ea-bad); font-weight: 600; }
.chart-block { border-top: 1px solid #e8edf2; padding-top: 24px; margin-bottom: 32px; }
.chart-block:first-child { border-top: none; padding-top: 0; }
.chart-block-header { margin-bottom: 12px; }
.ea-charts-area { margin-top: 28px; }

.ea-annual { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; text-align: center; }
.ea-annual-value { font-size: 1.6rem; font-weight: 800; color: var(--ea-accent); }
.ea-annual-label { font-size: 12px; color: #596273; text-transform: uppercase; letter-spacing: 0.8px; }

#print-header { display: none; margin-bottom: 20px; border-bottom: 2px solid var(--ea-accent); padding-bottom: 12px; }
.ea-print-row { display: flex; justify-content: space-between; align-items: flex-end; }
.ea-print-brand { font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--ea-accent); font-weight: 700; margin-bottom: 4px; }
.ea-print-title { font-size: 18px; font-weight: 800; color: #111827; }
.ea-print-meta { font-size: 11px; color: #555; text-align: right; }

/* Floating action panel: desktop only */
.ea-action-panel { position: fixed; right: 18px; top: 50%; transform: translateY(-50%); background: #fff; border: 1px solid #e8edf2; border-radius: 8px; box-shadow: 0 4px 18px rgba(0,0,0,0.13); padding: 12px 10px; display: flex; flex-direction: column; gap: 6px; z-index: 20; min-width: 108px; }
.ea-ap-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.8px; color: #596273; text-align: center; margin-bottom: 2px; }
.ea-ap-btn { background: none; border: 1px solid #e8edf2; border-radius: 4px; padding: 7px 10px; font-size: 12px; color: #374151; cursor: pointer; text-align: left; white-space: nowrap; min-height: 32px; }
.ea-ap-btn:hover { background: #f8fafc; border-color: #9ca3af; }
.ea-ap-divider { border-top: 1px solid #e8edf2; margin: 2px 0; }
.ea-ap-status { font-size: 11px; color: var(--ea-good); text-align: center; min-height: 14px; }
.ea-ap-status.is-ok { color: #16a34a; }
.ea-ap-status.is-bad { color: #c0392b; }

@media (max-width: 991px) {
  .ea-action-panel { display: none; }
}
@media (min-width: 992px) {
  .ea-mobile-actions { display: none; }
  #results-export-toolbar { display: none; }
}
@media (max-width: 767px) {
  .ea-grid-2 { grid-template-columns: minmax(0, 1fr); }
  .haresign-tool-card { padding: 18px 16px; }
  .summary-box { min-width: 120px; }
}

@media print {
  body * { visibility: hidden !important; }
  #print-region, #print-region * { visibility: visible !important; }
  #print-region { position: absolute; top: 0; left: 0; width: 100%; padding: 20px; }
  .haresign-tool-card { box-shadow: none !important; border: 1px solid #e8edf2 !important; page-break-inside: avoid; }
  .ea-section-head { border-bottom: 2px solid var(--ea-accent) !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .compliance-badge { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .summary-box { border: 1px solid #e8edf2 !important; }
  .results-table th { -webkit-print-color-adjust: exact; print-color-adjust: exact; background: #f8fafc !important; }
  .total-row { -webkit-print-color-adjust: exact; print-color-adjust: exact; background: var(--ea-tint) !important; }
  #results-export-toolbar, #shortfall-advisor, .ea-action-panel { display: none !important; }
  #print-header { display: block !important; }
  #practice-charts-area { display: none !important; }
}

/* Phase E3: validation, the assessment wording and the population summary. */
.ea-field-error { display: block; margin: 4px 0 0; font-size: 12px; color: var(--ea-bad); font-weight: 600; line-height: 1.35; }
.ea-wrap [aria-invalid="true"] { border-color: var(--ea-bad); outline: 2px solid #fecaca; }
.ea-sub { font-size: 11px; font-weight: 400; }
.ea-notice { background: #eef5ff; color: #12365f; border: 1px solid #b9d3f5; border-radius: 8px; padding: 10px 14px; font-size: 13px; margin: 14px 0 0; }
.ea-pop { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px 24px; margin: 18px 0 0; padding-top: 16px; border-top: 1px solid #f0f0f0; }
.ea-pop dt { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #4f5d6b; font-weight: 700; margin: 0 0 3px; }
.ea-pop dd { margin: 0; font-size: 14px; color: var(--ea-ink); font-weight: 600; }
.req-box .req-detail { font-size: 12px; color: #4b5563; margin-top: 8px; line-height: 1.45; }
.summary-box .s-note { font-size: 11px; color: #596273; margin-top: 6px; line-height: 1.35; }
.compliance-badge.indicative { background: #e0ecff; color: #12365f; }
.compliance-badge.undetermined { background: #fef3c7; color: #5c3a05; }
.ea-assess { font-size: 13px; color: var(--ea-ink); margin: 10px auto 0; max-width: 760px; }
.ea-scope { font-size: 12px; color: #596273; margin: 6px auto 0; max-width: 760px; }
.ea-basis { background: var(--ea-surface); border: 1px solid var(--ea-border); border-radius: var(--ea-radius); padding: 12px 18px; margin-bottom: 20px; font-size: 13px; }
.ea-basis summary { cursor: pointer; font-weight: 700; color: var(--ea-ink); min-height: 24px; padding: 4px 0; }
.ea-basis-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 28px; margin-top: 8px; }
.ea-basis-head { font-size: 13px; font-weight: 800; color: var(--ea-accent); margin: 0 0 6px; }
.ea-basis ul { margin: 0; padding-left: 18px; color: #374151; line-height: 1.5; }
.ea-basis li { margin-bottom: 6px; }
@media (max-width: 767px) {
  .ea-basis-cols { grid-template-columns: minmax(0, 1fr); }
}

/* Phase E4: chart and table views, the export row. */
.ea-chart-headrow { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ea-chart-headrow .ea-section-head { flex: 1 1 auto; min-width: 0; }
.chart-block-header .ea-chart-headrow { margin-bottom: 4px; }
.ea-viewtoggle { display: inline-flex; border: 1px solid #c9d3de; border-radius: 6px; overflow: hidden; flex: 0 0 auto; }
.ea-toggle { background: #fff; color: #374151; border: 0; padding: 6px 14px; font-size: 12px; font-weight: 600; cursor: pointer; min-height: 32px; min-width: 64px; }
.ea-toggle + .ea-toggle { border-left: 1px solid #c9d3de; }
.ea-toggle.is-on { background: var(--ea-accent); color: #fff; }
.ea-toggle:disabled { opacity: .45; cursor: default; }
.ea-toggle:focus-visible, .ea-small-btn:focus-visible, .btn-export:focus-visible, .btn-calc:focus-visible, .add-row-btn:focus-visible, .ea-ap-btn:focus-visible { outline: 3px solid #1d4ed8; outline-offset: 2px; }
.ea-chart-table { overflow-x: auto; position: relative; }
.ea-alt-table caption { caption-side: top; text-align: left; font-size: 12px; font-weight: 700; color: #4b5563; padding: 0 0 8px; }
.ea-alt-table th[scope="row"] { font-weight: 600; text-align: left; font-size: 13px; text-transform: none; letter-spacing: 0; color: var(--ea-ink); background: transparent; }
.ea-chart-note { font-size: 13px; color: #374151; background: #f8fafc; border: 1px dashed #c9d3de; border-radius: 8px; padding: 14px 16px; margin: 4px 0 0; }
.ea-export-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 0 0 18px; }
.ea-export-note { font-size: 12px; color: #596273; }
.ea-export-hint { flex-basis: 100%; margin: 0; font-size: 12px; color: #92400e; font-weight: 600; }
.ea-export-status { flex-basis: 100%; margin: 0; font-size: 12px; color: var(--ea-good); font-weight: 600; }
.ea-export-status.is-bad { color: var(--ea-bad); }
@media print {
  .ea-viewtoggle, .ea-export-row, .ea-chart-table { display: none !important; }
}

/* Phase E5: a scrollable table box is a labelled region the keyboard can reach and scroll. */
.ea-scroll:focus-visible, .ea-chart-table:focus-visible { outline: 3px solid #1d4ed8; outline-offset: 2px; }
