:root {
  --ink: #18202c;
  --muted: #687386;
  --line: #dce2ea;
  --line-dark: #b8c1ce;
  --canvas: #f3f5f8;
  --paper: #ffffff;
  --navy: #c90018;
  --navy-soft: rgba(255,255,255,.14);
  --teal: #d90019;
  --teal-dark: #b70015;
  --teal-soft: #fff0f2;
  --violet: #d90019;
  --violet-soft: #fff0f2;
  --blue-soft: #fff5f6;
  --green: #16724d;
  --green-soft: #e9f6ef;
  --red: #c43b4b;
  --red-soft: #fff0f2;
  --amber: #a96712;
  --amber-soft: #fff5e7;
  --brand-blue: #29277e;
  --brand-blue-soft: #f0f2ff;
  --shadow: 0 18px 48px rgba(23, 34, 50, .08);
}

* { box-sizing: border-box; }
html { background: var(--canvas); -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; min-height: 100dvh; overflow-x: hidden; font-family: Inter, "Segoe UI", Arial, sans-serif; color: var(--ink); background: var(--canvas); }
button, input, select, textarea { font: inherit; }
button { border: 0; cursor: pointer; touch-action: manipulation; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(41,39,126,.28); outline-offset: 2px; }
.hidden { display: none !important; }

.portal-shell { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 28px 20px; color: var(--ink); border-right: 1px solid var(--line); background: #fff; box-shadow: 8px 0 28px rgba(28,34,45,.04); }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 26px; border-bottom: 1px solid var(--line); }
.brand-logo { width: 44px; height: 44px; flex: 0 0 auto; border: 2px solid #edc6cb; border-radius: 10px; object-fit: cover; }
.calibration-context .brand-logo { width: 174px; height: 36px; border: 0; border-radius: 0; object-fit: contain; }
.calibration-context .brand > div { display: none; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 16px; letter-spacing: .01em; }
.brand strong { color: var(--ink); }
.brand small { margin-top: 3px; color: var(--teal); font-size: 11px; }
.portal-nav { display: grid; gap: 7px; margin-top: 26px; }
.nav-btn { width: 100%; min-height: 46px; display: flex; align-items: center; gap: 12px; border-radius: 9px; padding: 0 13px; color: #596477; background: transparent; text-align: left; font-size: 13px; font-weight: 700; }
.nav-btn span { color: #a3acb9; font-size: 10px; letter-spacing: .08em; }
.nav-btn:hover { color: var(--brand-blue); background: var(--brand-blue-soft); }
.nav-btn.active { color: #fff; background: var(--teal); box-shadow: 0 8px 22px rgba(187,0,20,.15); }
.nav-group-toggle { justify-content: flex-start; }
.nav-group-toggle b { margin-left: auto; font-size: 16px; transition: transform .15s ease; }
.nav-btn.active span { color: rgba(255,255,255,.72); }
.nav-group.active > .nav-group-toggle, .nav-group.open > .nav-group-toggle { color: var(--brand-blue); background: var(--brand-blue-soft); }
.nav-group.open .nav-group-toggle b { transform: rotate(180deg); }
.nav-submenu { display: none; gap: 5px; margin: 5px 0 0 34px; }
.nav-group.open .nav-submenu { display: grid; }
.nav-subsection-title { padding: 8px 12px 2px; color: #929cad; font-size: 9px; font-weight: 900; letter-spacing: .09em; text-transform: uppercase; }
.nav-subsection-title:not(:first-child) { margin-top: 5px; border-top: 1px solid var(--line); }
.nav-subbtn { min-height: 36px; padding: 0 12px; border-radius: 7px; color: #687386; background: transparent; text-align: left; font-size: 12px; font-weight: 700; }
.nav-subbtn:hover { color: var(--brand-blue); background: var(--brand-blue-soft); }
.nav-subbtn.active { color: #fff; background: var(--brand-blue); }
.sidebar-note { margin-top: auto; display: grid; gap: 7px; border: 1px solid #f0cbd0; border-radius: 10px; padding: 14px; background: var(--teal-soft); }
.sidebar-note strong { font-size: 12px; }
.sidebar-note span { color: #7d5960; font-size: 11px; line-height: 1.5; }
.mobile-menu-button, .sidebar-close, .sidebar-overlay { display: none; }

.portal-main { min-width: 0; }
.topbar { min-height: 94px; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 20px 34px; border-bottom: 2px solid var(--brand-blue); background: rgba(255,255,255,.94); }
.topbar-title { min-width: 0; }
.topbar-title h1 { overflow: hidden; text-overflow: ellipsis; }
.eyebrow, .section-kicker { margin: 0 0 6px; color: var(--teal); font-size: 10px; font-weight: 900; letter-spacing: .14em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 24px; line-height: 1.15; }
h2 { margin-bottom: 8px; font-size: 25px; line-height: 1.22; }
h3 { margin-bottom: 7px; }
.topbar-actions, .toolbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.topbar-actions { flex-wrap: nowrap; }
.system-status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 700; }
.system-status i { width: 8px; height: 8px; border-radius: 999px; background: #36a36e; box-shadow: 0 0 0 4px var(--green-soft); }
.install-app-button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 14px; border: 1px solid transparent; border-radius: 9px; color: #fff; background: var(--brand-blue); box-shadow: 0 7px 18px rgba(41,39,126,.18); font-size: 13px; font-weight: 850; white-space: nowrap; transition: transform .15s ease, background .15s ease, box-shadow .15s ease; }
.install-app-button:hover { background: #201e69; box-shadow: 0 9px 22px rgba(41,39,126,.24); transform: translateY(-1px); }
.install-app-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.install-label-short { display: none; }

.workspace { padding: 30px 34px 52px; }
.app-view, .panel, #reportBuilder { animation: viewIn .18s ease; }
@keyframes viewIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.panel { border: 1px solid var(--line); border-radius: 12px; padding: 24px; background: var(--paper); box-shadow: var(--shadow); }

.primary-action, .ghost-btn, .back-btn, .secondary-action, .small-action, .text-action { min-height: 42px; border-radius: 8px; padding: 0 16px; font-weight: 800; transition: .15s ease; }
.primary-action { color: #fff; background: var(--teal); }
.primary-action:hover { background: var(--teal-dark); transform: translateY(-1px); }
.ghost-btn, .back-btn, .secondary-action { color: var(--ink); border: 1px solid var(--line); background: #fff; }
.ghost-btn:hover, .back-btn:hover, .secondary-action:hover { border-color: var(--line-dark); background: #f7f9fb; }
.text-action { width: max-content; min-height: 34px; padding: 0; color: var(--brand-blue); background: transparent; }
.small-action { min-height: 36px; margin-top: 10px; color: var(--teal); border: 1px dashed #82beb8; background: var(--teal-soft); }
button:disabled { opacity: .55; cursor: not-allowed; transform: none !important; }

.hero-card { min-height: 214px; display: flex; align-items: flex-end; justify-content: space-between; gap: 32px; overflow: hidden; position: relative; padding: 34px; border-radius: 14px; color: #fff; background: linear-gradient(128deg, #16263b, #1f4850); box-shadow: var(--shadow); }
.hero-card::after { content: ""; position: absolute; width: 300px; height: 300px; right: -70px; top: -120px; border: 58px solid rgba(91, 204, 191, .12); border-radius: 50%; }
.hero-card > * { position: relative; z-index: 1; }
.hero-card h2 { max-width: 620px; font-size: clamp(27px, 3vw, 39px); }
.hero-card p { max-width: 700px; margin-bottom: 0; color: #c9d4df; line-height: 1.6; }
.hero-card .primary-action { flex: 0 0 auto; background: #fff; color: var(--navy); }
.overview-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.overview-heading h2 { margin-bottom: 0; }
.overview-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 18px 0; }
.metric-card { display: grid; grid-template-columns: 1fr auto; gap: 3px 14px; padding: 18px 20px; border: 1px solid var(--line); border-radius: 11px; background: #fff; }
.metric-card span { color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; }
.metric-card strong { grid-row: span 2; color: var(--teal); font-size: 27px; }
.metric-card:nth-child(even) strong { color: var(--brand-blue); }
.metric-card small { color: var(--muted); }
.module-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.module-card { min-height: 250px; display: flex; flex-direction: column; align-items: flex-start; gap: 16px; padding: 25px; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: 0 9px 30px rgba(23,34,50,.05); }
.module-card p { color: var(--muted); line-height: 1.55; }
.module-card .text-action { margin-top: auto; }
.module-icon { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 11px; font-size: 13px; font-weight: 900; }
.module-card--teal .module-icon { color: var(--teal); background: var(--teal-soft); }
.module-card--violet .module-icon { color: var(--violet); background: var(--violet-soft); }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(260px, .7fr); gap: 18px; }
.recent-card, .quick-card { border: 1px solid var(--line); border-radius: 12px; padding: 20px; background: #fff; box-shadow: 0 9px 30px rgba(23,34,50,.05); }
.card-heading { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 12px; }
.card-heading h3, .quick-card h3 { margin: 0 0 3px; font-size: 15px; }
.card-heading small { color: var(--muted); }
.recent-list { display: grid; }
.recent-report { min-height: 57px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border-top: 1px solid var(--line); padding: 8px 3px; color: var(--ink); background: transparent; text-align: left; }
.recent-report:hover { color: var(--brand-blue); }
.recent-report > span { display: grid; gap: 3px; }
.recent-report > span:last-child { grid-template-columns: auto 8px; align-items: center; text-align: right; }
.recent-report strong { font-size: 12px; }.recent-report small { color: var(--muted); font-size: 11px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; }.status-dot.pass { background: #36a36e; }.status-dot.review { background: var(--amber); }
.dashboard-empty { display: grid; place-items: center; min-height: 150px; color: var(--muted); font-size: 12px; }
.quick-card { position: relative; overflow: hidden; }
.quick-card > img { position: absolute; width: 90px; height: 90px; right: -20px; top: -20px; border-radius: 18px; opacity: .08; }
.quick-card > button { width: 100%; min-height: 45px; display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); color: var(--ink); background: transparent; text-align: left; font-size: 12px; font-weight: 800; }
.quick-card > button:hover { color: var(--brand-blue); }.quick-card > button span { color: var(--brand-blue); }

.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.section-heading.compact { margin-bottom: 16px; }
.section-heading p, .report-toolbar p, .records-header p { margin-bottom: 0; color: var(--muted); line-height: 1.5; }
.choice-grid { display: grid; grid-template-columns: repeat(2, minmax(180px, 1fr)); gap: 14px; }
.choice-btn { min-height: 100px; display: grid; justify-items: start; align-content: center; gap: 7px; padding: 20px; color: var(--ink); border: 1px solid var(--line); border-radius: 10px; background: #fff; text-align: left; }
.choice-btn:hover { color: var(--brand-blue); border-color: var(--brand-blue); background: var(--brand-blue-soft); }
.choice-btn strong { font-size: 17px; }
.choice-btn span { color: var(--muted); font-size: 12px; }
.material-bar { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 18px; }
#materialLabel, #materialLabelCalc, #dbTitle { color: var(--brand-blue); font-weight: 900; }

.form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.form-field { min-width: 0; }
.form-field--wide { grid-column: span 2; }
.form-field--full { grid-column: 1 / -1; }
label { display: block; margin-bottom: 6px; color: #566276; font-size: 11px; font-weight: 850; letter-spacing: .015em; }
input, select, textarea { width: 100%; min-height: 42px; border: 1px solid var(--line); border-radius: 7px; padding: 9px 11px; color: var(--ink); background: #fff; outline: none; }
textarea { resize: vertical; line-height: 1.4; }
input:focus, select:focus, textarea:focus { border-color: var(--brand-blue); box-shadow: 0 0 0 3px rgba(41,39,126,.12); }
input:disabled { color: var(--muted); background: #f5f7f9; }
.auto-field input { border-color: #bbc1e8; background: var(--brand-blue-soft); }
.field-inline { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; align-items: center; }
.switch { min-height: 42px; display: inline-flex; align-items: center; gap: 6px; margin: 0; padding: 0 10px; border: 1px solid var(--line); border-radius: 7px; background: #f7f9fb; color: var(--ink); white-space: nowrap; }
.switch input { width: 16px; min-height: 16px; accent-color: var(--brand-blue); }

#result { margin-top: 20px; }
.result-stack { display: grid; gap: 14px; }
.result-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.info-grid { overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.info-grid-header { padding: 11px 14px; color: var(--brand-blue); border-bottom: 1px solid #d9dcf0; background: var(--brand-blue-soft); font-size: 11px; font-weight: 900; }
.info-row { display: grid; grid-template-columns: minmax(120px,.9fr) minmax(0,1.1fr); gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.info-row:last-child { border-bottom: 0; }
.info-label { color: var(--muted); font-size: 12px; font-weight: 700; }
.info-value { color: var(--ink); font-size: 13px; font-weight: 850; overflow-wrap: anywhere; }
.info-tag { display: inline-flex; align-items: center; min-height: 21px; padding: 0 7px; border-radius: 999px; color: var(--brand-blue); background: var(--brand-blue-soft); font-size: 10px; font-weight: 900; }
.info-tag--warn { color: var(--amber); background: var(--amber-soft); }
.alert { padding: 12px 14px; color: var(--red); border: 1px solid #efabb4; border-radius: 8px; background: var(--red-soft); font-weight: 750; }
.status-pill { display: inline-flex; justify-content: center; min-width: 62px; padding: 4px 8px; border-radius: 999px; font-size: 10px; font-weight: 900; }
.status-pill--ok { color: var(--green); background: var(--green-soft); }
.status-pill--fail { color: var(--red); background: var(--red-soft); }
.status-pill--warn { color: var(--amber); background: var(--amber-soft); }
.core-od-status { display: grid; gap: 5px; margin-top: 7px; }
.cs-row { display: grid; grid-template-columns: minmax(110px,auto) 1fr; gap: 8px; color: var(--muted); font-size: 11px; line-height: 1.35; }
.cs-key { font-weight: 700; }.cs-val { color: var(--ink); font-weight: 850; }
.cs-ok,.cs-err,.cs-warn,.cs-note { display: block; padding: 7px 9px; border-radius: 7px; }
.cs-ok { color: var(--green); background: var(--green-soft); }.cs-err { color: var(--red); background: var(--red-soft); }.cs-warn { color: var(--amber); background: var(--amber-soft); }.cs-note { background: #f3f5f8; }

.table-wrapper, .reading-table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.table-wrapper { margin-top: 16px; }
table { width: 100%; border-collapse: collapse; }
.table-wrapper table { min-width: 820px; }
th, td { padding: 10px; border-bottom: 1px solid var(--line); text-align: center; font-size: 12px; }
th { color: var(--brand-blue); background: var(--brand-blue-soft); font-size: 10px; font-weight: 900; text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: 0; }
tr.primary { background: var(--green-soft); font-weight: 850; } tr.secondary { background: var(--blue-soft); } tr.fail { color: var(--muted); }
#dbTable input { min-height: 36px; text-align: center; }.table-save { margin-top: 15px; }

.report-toolbar, .records-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 18px; }
.report-toolbar p, .records-header p, .section-heading p { display: none; }
.report-workspace { display: grid; grid-template-columns: minmax(550px, 1.03fr) minmax(480px, .97fr); gap: 20px; align-items: start; }
.report-form { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 15px; }
.form-section { min-width: 0; border: 1px solid var(--line); border-radius: 11px; padding: 19px; background: #fff; }
.form-section-title { display: flex; align-items: flex-start; gap: 11px; margin-bottom: 17px; }
.form-section-title > span { width: 29px; height: 29px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 8px; color: var(--teal); background: var(--teal-soft); font-size: 10px; font-weight: 900; }
.form-section-title h3 { margin: 0; font-size: 15px; }.form-section-title p { display: none; }
.report-field-grid { display: grid; gap: 12px; }.report-field-grid.two { grid-template-columns: repeat(2, minmax(0,1fr)); }.report-field-grid.four { grid-template-columns: repeat(4, minmax(0,1fr)); }
.reading-meta-grid { display: grid; grid-template-columns: 1fr .8fr .65fr; gap: 12px; margin-bottom: 12px; }
.reading-input-table { min-width: 610px; }
.reading-input-table input { min-height: 35px; padding: 6px 8px; text-align: center; }
.reading-input-table td { padding: 6px; }.reading-input-table td:first-child { width: 44px; color: var(--muted); font-weight: 800; }
.calculated-value { min-width: 70px; font-weight: 850; }.calculated-value.pass { color: var(--green); }.calculated-value.fail { color: var(--red); }
.remove-reading { min-width: 56px; height: 29px; padding: 0 9px; border-radius: 6px; color: var(--red); background: var(--red-soft); font-size: 10px; font-weight: 900; }

.preview-panel { min-width: 0; position: sticky; top: 18px; }
.preview-label { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; color: var(--muted); font-size: 10px; font-weight: 900; letter-spacing: .08em; }.preview-label small { font-weight: 600; letter-spacing: 0; }
.calibration-sheet,.performance-sheet { width: 100%; min-height: 680px; padding: 26px 24px; border: 1px solid #c9ced5; background: #fff; box-shadow: 0 15px 40px rgba(26,34,45,.1); color: #111; font-family: "Times New Roman", serif; font-size: clamp(8px, .72vw, 11px); }
.certificate-letterhead-space { height: 35mm; }
.certificate-title { width: max-content; margin: 0 auto 12px; padding: 4px 16px 3px; border: 1px solid #222; color: var(--brand-blue); font-size: 1.5em; font-weight: 800; letter-spacing: .02em; }
.certificate-customer { margin-bottom: 8px; }.certificate-customer strong { display: block; font-size: 1.18em; text-decoration: underline; }.certificate-address { margin-top: 5px; white-space: pre-line; font-size: 1.08em; font-weight: 700; line-height: 1.22; }
.certificate-control, .certificate-readings { width: 100%; border: 1px solid #222; table-layout: fixed; }
.certificate-control th,.certificate-control td,.certificate-readings th,.certificate-readings td { border: 1px solid #333; color: #111; background: #fff; font-family: inherit; text-transform: none; letter-spacing: 0; }
.certificate-control th { padding: 5px 3px; font-size: 1em; }.certificate-control td { padding: 5px 3px; font-size: 1.04em; }
.certificate-equipment { display: grid; gap: 5px; margin: 9px 0; font-weight: 700; }.certificate-equipment .line { display: grid; grid-template-columns: 1.35fr .9fr .9fr; gap: 9px; }.certificate-equipment b { font-weight: 800; }
.certificate-readings { margin-top: 9px; }.certificate-readings th { padding: 5px 3px; font-size: .9em; }.certificate-readings td { padding: 6px 3px; font-size: .94em; }.certificate-readings th:nth-child(1) { width: 8%; }.certificate-readings th:nth-child(2) { width: 23%; }
.certificate-standard { display: grid; grid-template-columns: 1fr 1.7fr; gap: 12px; margin-top: 14px; line-height: 1.35; }.certificate-standard strong { font-size: 1.02em; }.standard-details { display: grid; gap: 2px; font-weight: 700; }
.certificate-notes { display: grid; gap: 6px; margin-top: 9px; line-height: 1.35; }.certificate-note { display: grid; grid-template-columns: 95px 10px 1fr; }.certificate-note b { font-style: italic; }
.certificate-signatures { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-top: 18px; text-align: center; }.signature-block { min-height: 65px; display: flex; flex-direction: column; justify-content: space-between; }.signature-block strong { font-size: .94em; }.signature-name { font-size: 1.05em; }.signature-role { font-size: .88em; }
.calibration-sheet .certificate-equipment .line { grid-template-columns: repeat(var(--certificate-columns,3),minmax(0,1fr)); }
.calibration-sheet .certificate-readings--conditional th { width: auto; }
.calibration-sheet .certificate-signatures { grid-template-columns: repeat(var(--signature-columns,3),minmax(0,1fr)); }

.performance-title { color: var(--teal); }
.performance-link { margin: 8px 0; padding: 5px 7px; border: 1px solid #333; font-weight: 700; }
.performance-equipment { display: grid; gap: 4px; margin: 9px 0 12px; font-weight: 700; }
.performance-table-wrap { width: 100%; overflow-x: auto; }
.performance-readings { width: 100%; min-width: 500px; border: 1px solid #222; table-layout: fixed; }
.performance-readings th,.performance-readings td { border: 1px solid #333; color: #111; background: #fff; font-family: inherit; text-transform: none; letter-spacing: 0; }
.performance-readings th { width: 24%; padding: 6px 4px; font-size: .95em; }
.performance-readings td { padding: 7px 4px; font-size: .98em; font-weight: 700; }
.performance-notes .certificate-note { grid-template-columns: 9.5em .8em minmax(0,1fr); }
.performance-notes .certificate-note > b,.performance-notes .certificate-note > strong { white-space: nowrap; }
.performance-signatures { grid-template-columns: repeat(2,minmax(0,1fr)); }

.offer-sheet { width: 100%; min-height: 900px; position: relative; overflow: hidden; padding: 28px 34px 72px; border: 1px solid #c9ced5; background: #fff; box-shadow: 0 15px 40px rgba(26,34,45,.1); color: #242424; font-family: Arial, "Segoe UI", sans-serif; font-size: clamp(10px, .83vw, 13px); line-height: 1.35; }
.offer-top-rule,.offer-bottom-rule { height: 5px; border-top: 3px solid #29277e; border-bottom: 1px solid #ed1c24; }
.offer-bottom-rule { position: absolute; right: 34px; bottom: 24px; left: 34px; }
.offer-letterhead { display: grid; justify-items: center; gap: 8px; padding: 17px 0 14px; border-bottom: 1px solid #d6d8df; color: #555; text-align: center; }
.offer-letterhead img { width: min(420px, 68%); height: 72px; object-fit: contain; }
.offer-title { margin: 10px 0 18px; padding: 9px 12px; color: #fff; border-bottom: 3px solid #ed1c24; background: #302f88; text-align: center; font-size: 1.55em; font-weight: 800; }
.offer-date { display: flex; justify-content: flex-end; gap: 20px; margin: 0 9% 24px 0; }
.offer-sheet p { margin: 0 0 14px; }
.offer-section-title { margin: 15px 0 9px; padding-bottom: 5px; color: #302f88; border-bottom: 1px solid #ed1c24; font-size: 1.12em; }
.offer-appointment { width: 100%; margin-bottom: 10px; table-layout: fixed; border: 1px solid #bcc5e7; }
.offer-appointment th,.offer-appointment td { width: 50%; border: 1px solid #bcc5e7; text-align: left; }
.offer-appointment th { padding: 8px 12px; color: #302f88; background: #eff1fb; font-size: .92em; }
.offer-appointment td { padding: 13px 16px; color: #242424; background: #fff; font-size: .98em; font-weight: 750; }
.offer-sheet ul { margin: 0 0 13px; padding-left: 28px; }
.offer-sheet li { margin: 3px 0; padding-left: 2px; }
.offer-sheet li::marker { color: #ed1c24; }
.offer-signature { width: 43%; display: grid; gap: 18px; margin: 36px 3% 0 auto; color: #302f88; }
.offer-signature span { color: #242424; }

.appointment-preview { display: grid; gap: 20px; }
.appointment-page { width: 100%; min-height: 900px; position: relative; overflow: hidden; padding: 32px 38px 60px; border: 1px solid #c9ced5; background: #fff; box-shadow: 0 15px 40px rgba(26,34,45,.1); color: #202124; font-family: Arial, "Segoe UI", sans-serif; font-size: clamp(9px, .72vw, 11.5px); line-height: 1.42; }
.appointment-letterhead { display: grid; grid-template-columns: minmax(180px,1fr) minmax(180px,1fr); align-items: center; gap: 18px; padding-bottom: 12px; border-bottom: 3px solid #29277e; }
.appointment-letterhead img { width: min(340px,100%); height: 58px; object-fit: contain; object-position: left center; }
.appointment-letterhead-meta { display: grid; gap: 3px; color: #555d6c; text-align: right; font-size: .9em; }
.appointment-top-rule { height: 3px; margin-bottom: 16px; background: #ed1c24; }
.appointment-control { display: flex; justify-content: space-between; gap: 20px; margin: 16px 0 13px; }
.appointment-control strong { color: #29277e; text-decoration: underline; }
.appointment-recipient { margin-bottom: 14px; font-style: normal; white-space: pre-line; }
.appointment-recipient strong { display: block; font-size: 1.05em; }
.appointment-title { width: max-content; margin: 14px auto 17px; padding-bottom: 3px; border-bottom: 2px solid #202124; font-size: 1.55em; letter-spacing: .02em; }
.appointment-page p { margin: 0 0 11px; text-align: justify; }
.appointment-clause { margin: 15px 0 0; }
.appointment-clause h3 { display: flex; gap: 8px; margin: 0 0 8px; color: #29277e; font-size: 1.04em; line-height: 1.35; }
.appointment-clause h3 span { color: #ed1c24; }
.appointment-subclause { margin-left: 22px !important; }
.appointment-subclause b { color: #25246f; }
.appointment-page-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 22px; padding-bottom: 8px; border-bottom: 2px solid #29277e; color: #29277e; }
.appointment-page-header img { width: 190px; height: 38px; object-fit: contain; object-position: left center; }
.appointment-page-header strong { font-size: .9em; }
.appointment-signatures { display: grid; grid-template-columns: 1fr 1fr; gap: 38px; margin-top: 34px; }
.appointment-signature { min-height: 118px; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; }
.appointment-signature-line { width: 190px; margin-bottom: 5px; border-top: 1px solid #202124; }
.appointment-signature:last-child { align-items: flex-end; text-align: left; }
.appointment-signature:last-child > * { width: 190px; }
.appointment-annexure-title { margin: 4px 0 18px; text-align: center; }
.appointment-annexure-title h2 { margin: 0; color: #29277e; font-size: 1.45em; }
.appointment-annexure-title p { margin: 2px 0 0; text-align: center; font-size: 1.15em; }
.appointment-comp-table { width: 100%; margin: 16px 0 18px; table-layout: fixed; border: 1px solid #73798a; }
.appointment-comp-table th,.appointment-comp-table td { padding: 7px 9px; border: 1px solid #73798a; color: #202124; background: #fff; font-family: inherit; text-transform: none; letter-spacing: 0; }
.appointment-comp-table th { color: #fff; background: #29277e; font-size: .95em; }
.appointment-comp-table th:first-child { width: 56%; }
.appointment-comp-table td:first-child { text-align: left; }
.appointment-comp-table .appointment-total td { color: #29277e; background: #f0f1fb; font-weight: 900; }
.appointment-note { padding: 10px 12px; border-left: 3px solid #ed1c24; background: #f8f8fb; }
.appointment-page-footer { position: absolute; right: 38px; bottom: 25px; left: 38px; display: flex; justify-content: space-between; gap: 18px; padding-top: 8px; border-top: 1px solid #cfd3df; color: #73798a; font-size: .85em; }

.records-controls { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 14px; border: 1px solid var(--line); border-radius: 9px; background: #f8fafb; }
.records-controls input { max-width: 440px; background: #fff; }.records-controls span { color: var(--muted); font-size: 12px; font-weight: 800; }
.records-table td { text-align: left; }.records-table td:first-child { font-weight: 850; color: var(--teal); }.record-actions { display: flex; gap: 6px; }
.record-actions button { min-height: 30px; padding: 0 10px; border-radius: 6px; color: var(--ink); border: 1px solid var(--line); background: #fff; font-size: 10px; font-weight: 850; }
.empty-state { padding: 35px !important; color: var(--muted); text-align: center !important; }

.modal { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 18px; background: rgba(18,30,45,.58); }
.modal-box { width: min(370px,100%); padding: 22px; border-radius: 11px; background: #fff; box-shadow: var(--shadow); text-align: center; }.modal-box h3 { margin-bottom: 14px; }.modal-box input { margin-bottom: 10px; }.modal-box .primary-action,.modal-box .secondary-action { width: 100%; }.modal-box .secondary-action { margin-top: 8px; } #passError { color: var(--red); font-weight: 750; }
.install-modal-box { width: min(430px,100%); padding: 28px; }
.install-modal-box > img { width: 66px; height: 66px; margin-bottom: 15px; border-radius: 15px; box-shadow: 0 10px 24px rgba(201,0,24,.17); }
.install-modal-box > p { margin-bottom: 16px; color: var(--muted); line-height: 1.55; }
.install-instructions { margin-bottom: 18px; padding: 14px 16px; border: 1px solid #d9dcf0; border-radius: 9px; color: #39386e; background: var(--brand-blue-soft); text-align: left; font-size: 14px; line-height: 1.55; }
.install-instructions ol { margin: 0; padding-left: 20px; }
.install-instructions li + li { margin-top: 6px; }

@media (max-width: 1380px) { .report-workspace { grid-template-columns: 1fr; }.preview-panel { position: static; }.calibration-sheet,.performance-sheet,.offer-sheet,.appointment-page { max-width: 760px; margin-right: auto; margin-left: auto; font-size: 10px; } }
@media (max-width: 900px) {
  .portal-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 1200; inset: 0 auto 0 0; width: min(300px,86vw); height: 100vh; height: 100dvh; padding: calc(22px + env(safe-area-inset-top)) 18px calc(22px + env(safe-area-inset-bottom)); overflow-y: auto; overscroll-behavior: contain; transform: translateX(-105%); transition: transform .22s ease; box-shadow: 18px 0 48px rgba(18,30,45,.2); }
  .sidebar.mobile-open { transform: translateX(0); }
  .sidebar-overlay { display: block; position: fixed; z-index: 1100; inset: 0; opacity: 0; pointer-events: none; background: rgba(21,26,36,.48); transition: opacity .2s ease; }
  .sidebar-overlay.visible { opacity: 1; pointer-events: auto; }
  body.menu-open { overflow: hidden; }
  .sidebar-close { width: 44px; height: 44px; display: grid; place-items: center; flex: 0 0 auto; margin-left: auto; border-radius: 8px; color: var(--ink); background: #f3f5f8; font-size: 23px; line-height: 1; }
  .mobile-menu-button { width: 44px; height: 44px; display: grid; align-content: center; gap: 4px; padding: 10px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
  .mobile-menu-button span { width: 100%; height: 2px; border-radius: 2px; background: var(--ink); }
  .brand { padding-bottom: 18px; }
  .portal-nav { grid-template-columns: 1fr; margin-top: 18px; }
  .nav-btn { justify-content: flex-start; padding: 0 13px; text-align: left; }
  .nav-btn span { display: inline; }
  .nav-submenu { margin-left: 34px; }
  .nav-group.open .nav-submenu { grid-template-columns: 1fr; }
  .sidebar-note { display: grid; }
  .topbar { position: sticky; z-index: 900; top: 0; min-height: 74px; display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 12px; padding: calc(12px + env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 12px max(18px, env(safe-area-inset-left)); box-shadow: 0 5px 18px rgba(23,34,50,.06); }
  .topbar h1 { font-size: 18px; }
  .topbar .eyebrow { margin-bottom: 4px; font-size: 8px; }
  .topbar-actions .system-status { display: none; }
  .install-label-full { display: none; }
  .install-label-short { display: inline; }
  .workspace { padding: 22px 18px 42px; }
  .metric-grid { grid-template-columns: repeat(2,1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .form { grid-template-columns: repeat(2,1fr); }
  .report-field-grid.four { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 650px) {
  .overview-heading,.report-toolbar,.records-header,.hero-card { align-items: flex-start; flex-direction: column; }
  .overview-actions { width: 100%; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); }
  .overview-actions button { width: 100%; padding: 0 10px; }
  .workspace { padding: 16px max(12px, env(safe-area-inset-right)) calc(35px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
  h2 { font-size: 22px; }
  .metric-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .module-grid,.choice-grid,.form,.report-field-grid.two,.report-field-grid.four,.reading-meta-grid { grid-template-columns: 1fr; }
  .metric-card { display: block; padding: 15px; }
  .metric-card strong,.metric-card span,.metric-card small { display: block; }
  .metric-card strong { margin: 5px 0 2px; }
  .form-field--wide { grid-column: auto; }
  .panel,.form-section { padding: 16px; }
  .toolbar-actions { width: 100%; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); }
  .toolbar-actions button { width: 100%; min-height: 46px; padding-inline: 10px; }
  .hero-card { padding: 24px; }
  .hero-card .primary-action { width: 100%; }
  .records-controls { align-items: stretch; flex-direction: column; }
  .calibration-sheet,.performance-sheet { min-width: 590px; }
  .offer-sheet,.appointment-page { min-width: 590px; }
  .preview-panel { overflow-x: auto; }
  .result-grid { grid-template-columns: 1fr; }
  .field-inline { grid-template-columns: 1fr; }
  .switch { justify-content: center; }
  .certificate-equipment .line { grid-template-columns: 1fr; gap: 2px; }
  input, select, textarea { min-height: 46px; font-size: 16px; }
  label { font-size: 14px; line-height: 1.35; }
  .primary-action, .ghost-btn, .back-btn, .secondary-action, .small-action, .text-action, .choice-btn, .quick-card > button { min-height: 46px; font-size: 14px; }
  .record-actions button, .remove-reading { min-height: 44px; }
  .nav-btn, .nav-subbtn { min-height: 46px; font-size: 14px; }
  .recent-report { min-width: 0; min-height: 62px; }
  .recent-report > span { min-width: 0; }
  .recent-report strong, .recent-report small { overflow-wrap: anywhere; }
  .modal { align-items: end; padding: 12px max(12px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
  .modal-box { width: 100%; max-height: min(88vh, 720px); overflow-y: auto; border-radius: 16px; }
}
@media (max-width: 420px) {
  .topbar { padding-inline: 12px; }
  .topbar .eyebrow { display: none; }
  .topbar h1 { font-size: 16px; white-space: nowrap; }
  .install-app-button { min-height: 44px; padding-inline: 10px; }
  .overview-actions { grid-template-columns: 1fr; }
  .toolbar-actions { grid-template-columns: 1fr; }
  .metric-card { padding: 13px; }
  .metric-card strong { font-size: 24px; }
}

@media print {
  body { background: #fff; }
  .sidebar,.topbar,.report-toolbar,.report-form,.preview-label,.modal,.workspace > * { display: none !important; }
  .portal-shell,.portal-main,.workspace,.report-workspace,.preview-panel { display: block !important; width: 100% !important; padding: 0 !important; margin: 0 !important; }
  body.print-calibration #reportBuilder, body.print-performance #performanceReportBuilder, body.print-offer #offerBuilder, body.print-appointment #appointmentBuilder { display: block !important; }
  .calibration-sheet,.performance-sheet { width: 100%; min-height: 0; border: 0; box-shadow: none; padding: 8mm 9mm; font-size: 10.5pt; }
  .offer-sheet { width: 100%; min-height: 277mm; border: 0; box-shadow: none; padding: 8mm 9mm 20mm; font-size: 10.5pt; }
  .offer-bottom-rule { right: 9mm; bottom: 7mm; left: 9mm; }
  .appointment-preview { display: block !important; }
  .appointment-page { width: 100%; min-height: 277mm; margin: 0 !important; padding: 8mm 10mm 17mm; border: 0; box-shadow: none; font-size: 9.3pt; break-after: page; page-break-after: always; }
  .appointment-page:last-child { break-after: auto; page-break-after: auto; }
  .appointment-page-footer { right: 10mm; bottom: 6mm; left: 10mm; }
  @page { size: A4 portrait; margin: 7mm; }
}
