:root {
  --navy-950: #041332;
  --navy-900: #061f56;
  --navy-800: #0a2c6b;
  --navy-700: #17417f;
  --gold-600: #bf8400;
  --gold-500: #d49a13;
  --gold-100: #fff2d1;
  --blue-100: #e8f1ff;
  --ink: #13213c;
  --muted: #64708a;
  --line: #d9deea;
  --paper: #ffffff;
  --bg: #f2f5fa;
  --success: #087b55;
  --danger: #b42318;
  --surface-soft: #f8faff;
  --surface-blue: #eef5ff;
  --surface-gold: #fff8e8;
  --shadow: 0 18px 45px rgba(11, 31, 68, 0.12);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: "Roboto", Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 0%, rgba(212,154,19,.13), transparent 30%),
    linear-gradient(180deg, #edf3fb 0%, var(--bg) 42%, #edf0f7 100%);
}
button, input { font: inherit; }
button { cursor: pointer; }

.app-header {
  position: relative;
  overflow: hidden;
  padding: calc(20px + env(safe-area-inset-top)) 18px 22px;
  color: white;
  background:
    linear-gradient(135deg, rgba(255,255,255,.08), transparent 55%),
    linear-gradient(135deg, var(--navy-950), var(--navy-800));
}
.app-header::after {
  content: "";
  position: absolute;
  width: 170px;
  height: 170px;
  border: 24px solid rgba(255,255,255,.04);
  border-radius: 50%;
  right: -85px;
  top: -75px;
}
.app-header h1 {
  margin: 3px 0 6px;
  font-family: "Roboto Condensed", sans-serif;
  font-size: clamp(29px, 8vw, 40px);
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: .02em;
}
.eyebrow, .section-kicker {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
}
.eyebrow { color: #ffd76e; }
.subhead {
  max-width: 520px;
  margin: 0;
  color: rgba(255,255,255,.76);
  font-size: 13px;
  line-height: 1.5;
}
.date-chip {
  display: inline-flex;
  margin-top: 14px;
  padding: 8px 11px;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  color: #fff;
  font-family: "Roboto Condensed", sans-serif;
  font-weight: 700;
  letter-spacing: .06em;
}
.page-shell { width: min(760px, 100%); margin: 0 auto; padding: 18px 14px 0; }
#reportForm { display: grid; gap: 14px; }
.form-card {
  background: rgba(255,255,255,.97);
  border: 1px solid rgba(7,33,85,.09);
  border-radius: var(--radius-xl);
  padding: 19px;
  box-shadow: 0 14px 34px rgba(18, 43, 86, .085);
}
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}
.section-heading h2 {
  margin: 3px 0 0;
  font-family: "Roboto Condensed", sans-serif;
  font-size: 24px;
  line-height: 1;
  color: var(--navy-900);
}
.section-kicker { color: var(--gold-600); }
.section-note { margin: -4px 0 14px; color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.section-help {
  margin: -4px 0 15px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.55;
}
.section-number {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 14px;
  background: var(--blue-100);
  color: var(--navy-800);
  font-family: "Roboto Condensed", sans-serif;
  font-size: 16px;
  font-weight: 700;
}
.field { display: grid; gap: 7px; }
.field > span { color: #3d4b67; font-size: 12.5px; font-weight: 800; }
.field input {
  width: 100%;
  min-height: 50px;
  border: 1px solid #d5dceb;
  border-radius: 13px;
  padding: 12px 13px;
  background: var(--surface-soft);
  color: var(--ink);
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.field input:focus {
  border-color: var(--navy-700);
  box-shadow: 0 0 0 4px rgba(23,65,127,.11);
  background: #fff;
}
.two-col { display: grid; gap: 12px; grid-template-columns: 1fr; }
.unit-stack { display: grid; gap: 13px; }
.unit-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}
.unit-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 13px;
  background: linear-gradient(90deg, var(--navy-900), var(--navy-800));
  color: #fff;
}
.unit-title strong {
  font-family: "Roboto Condensed", sans-serif;
  font-size: 20px;
  letter-spacing: .03em;
}
.unit-title span { font-size: 10px; letter-spacing: .14em; opacity: .72; }
.unit-inputs { display: grid; grid-template-columns: 1fr; gap: 10px; padding: 12px; }
.param-field { display: grid; grid-template-columns: minmax(98px, .9fr) minmax(0, 1.4fr) auto; align-items: center; gap: 9px; }
.param-field label { font-size: 12px; font-weight: 700; color: #313f5d; }
.param-field input {
  min-width: 0;
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 8px 10px;
  background: #fbfcff;
  outline: none;
}
.param-field input:focus { border-color: var(--navy-700); box-shadow: 0 0 0 3px rgba(23,65,127,.1); }
.param-unit { min-width: 42px; color: var(--muted); font-size: 10px; font-weight: 700; }
/* Hydrogen & Fuel Gas distribution matrix */
.matrix-card {
  overflow: hidden;
  border: 1px solid #d2daea;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(16, 39, 78, .06), inset 0 1px 0 rgba(255,255,255,.7);
}
.matrix-head {
  padding: 14px 14px 12px;
  border-bottom: 1px solid #e3e9f4;
  background: linear-gradient(180deg, #fbfdff, #f4f8ff);
}
.matrix-title {
  color: var(--navy-900);
  font-family: "Roboto Condensed", sans-serif;
  font-size: 21px;
  font-weight: 700;
}
.matrix-caption { margin-top: 4px; color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.matrix-wrap { overflow-x: auto; }
.matrix-table { width: 100%; border-collapse: collapse; table-layout: fixed; min-width: 320px; }
.matrix-table thead th {
  padding: 12px 10px;
  background: linear-gradient(135deg, var(--navy-900), var(--navy-700));
  color: #fff;
  border-right: 1px solid rgba(255,255,255,.14);
  font-family: "Roboto Condensed", sans-serif;
  font-size: 12px;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.matrix-table thead th:first-child { text-align: left; width: 52%; }
.matrix-table thead th:nth-child(2) { width: 24%; }
.matrix-table thead th:last-child { width: 24%; border-right: 0; }
.matrix-table tbody td { border-top: 1px solid #e3e9f4; border-right: 1px solid #e3e9f4; }
.matrix-table tbody td:last-child { border-right: 0; }
.matrix-label {
  padding: 13px 14px;
  font-size: 13px;
  font-weight: 700;
  color: #24324e;
  background: #fff;
}
.matrix-alt .matrix-label,
.matrix-alt .matrix-pick { background: #fbfcfe; }
.matrix-pick {
  padding: 7px 8px;
  text-align: center;
  background: #fff;
}
.matrix-pick.blue-col { box-shadow: inset 4px 0 0 rgba(10,44,107,.08); }
.matrix-pick.gold-col { box-shadow: inset 4px 0 0 rgba(212,154,19,.15); }
.table-check { display: inline-grid; place-items: center; width: 40px; height: 40px; cursor: pointer; position: relative; }
.table-check input { position: absolute; opacity: 0; pointer-events: none; }
.check-box {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 2px solid #b3bfd2;
  border-radius: 9px;
  color: transparent;
  background: #fff;
  font-size: 16px;
  font-weight: 900;
  transition: .16s ease;
}
.table-check input:checked + .check-box {
  border-color: var(--navy-800);
  color: #fff;
  background: linear-gradient(135deg, var(--navy-900), var(--navy-700));
  box-shadow: 0 6px 14px rgba(10,44,107,.2);
}
.table-check input:focus-visible + .check-box { outline: 3px solid rgba(23,65,127,.18); outline-offset: 2px; }
.mobile-action-spacer { height: 118px; }
.sticky-actions {
  position: fixed;
  z-index: 20;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  gap: 9px;
  padding: 11px 12px calc(11px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(8,31,77,.1);
  background: rgba(247,249,253,.92);
  backdrop-filter: blur(16px);
  box-shadow: 0 -14px 32px rgba(12,35,75,.1);
}
.btn {
  min-height: 52px;
  border: 0;
  border-radius: 15px;
  padding: 11px 15px;
  font-weight: 800;
  transition: transform .16s ease, opacity .16s ease, box-shadow .16s ease;
}
.btn:active { transform: translateY(1px) scale(.995); }
.btn:disabled { cursor: not-allowed; opacity: .45; }
.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--navy-900), var(--navy-700));
  box-shadow: 0 10px 22px rgba(7,35,88,.24);
}
.btn-secondary { color: var(--navy-900); background: #fff; border: 1px solid rgba(7,35,88,.17); }
.btn-icon { margin-right: 5px; }
.toast {
  position: fixed;
  z-index: 60;
  left: 50%;
  bottom: calc(86px + env(safe-area-inset-bottom));
  transform: translate(-50%, 16px);
  width: min(420px, calc(100% - 28px));
  padding: 12px 14px;
  border-radius: 14px;
  background: #12234a;
  color: white;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.modal[hidden] { display: none; }
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: end center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(3,12,31,.72); backdrop-filter: blur(8px); }
.modal-panel {
  position: relative;
  width: min(760px, 100%);
  max-height: 94vh;
  overflow: auto;
  border-radius: 28px 28px 0 0;
  padding: 18px 14px calc(18px + env(safe-area-inset-bottom));
  background: #f5f7fb;
  box-shadow: 0 -18px 70px rgba(0,0,0,.25);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.modal-head h2 { margin: 3px 0 0; color: var(--navy-900); font-family: "Roboto Condensed", sans-serif; }
.icon-btn { width: 42px; height: 42px; border: 0; border-radius: 50%; background: #e6ebf4; color: var(--navy-900); font-size: 27px; }
.preview-stage {
  overflow: auto;
  display: grid;
  place-items: center;
  min-height: 65vh;
  border-radius: 20px;
  padding: 14px;
  background: #dfe5ef;
}
#previewMount { width: min(100%, 420px); }
#previewMount canvas { display: block; width: 100%; height: auto; border-radius: 13px; box-shadow: 0 16px 40px rgba(3,19,54,.22); }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 12px; }
.export-host { position: fixed; left: -10000px; top: 0; width: 560px; pointer-events: none; }

/* Export report */
.report-poster {
  width: 560px;
  min-height: 980px;
  padding: 18px;
  background:
    radial-gradient(circle at 100% 0%, rgba(212,154,19,.18), transparent 28%),
    linear-gradient(180deg, #f8fbff 0%, #eef3f9 100%);
  color: #12213e;
  font-family: "Roboto Condensed", Arial, sans-serif;
}
.poster-topbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
  padding: 16px 18px;
  border-radius: 20px;
  color: white;
  background: linear-gradient(135deg, #031433, #0b2a63 55%, #123e85 100%);
  box-shadow: 0 14px 28px rgba(3,28,74,.18);
}
.poster-topbar h1 { margin: 0; font-size: 30px; letter-spacing: .04em; line-height: 1; text-transform: uppercase; }
.poster-topbar p { margin: 6px 0 0; color: #f5cf72; font-size: 10px; font-weight: 700; letter-spacing: .2em; }
.poster-date {
  min-width: 118px;
  padding: 10px 12px;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 14px;
  background: rgba(255,255,255,.09);
  text-align: center;
  font-size: 15px;
  font-weight: 700;
}
.poster-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; align-items: start; }
.poster-card,
.poster-side-section {
  overflow: hidden;
  border: 1px solid #a6b2c5;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 8px 18px rgba(17,41,78,.07);
}
.poster-card-title {
  padding: 10px 12px;
  color: #fff;
  background: linear-gradient(135deg, #061f56, #103b82);
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.poster-table { width: 100%; border-collapse: collapse; table-layout: fixed; background: #fff; }
.poster-table th {
  padding: 8px 6px;
  border-right: 1px solid rgba(255,255,255,.24);
  color: #fff;
  background: linear-gradient(180deg, #d7a227, #bb8409);
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.poster-table td { border-top: 1px solid #cbd2de; border-right: 1px solid #d8dde6; padding: 6px 6px; font-size: 11.6px; }
.poster-table td:last-child, .poster-table th:last-child { border-right: 0; }
.poster-table .unit-row.unit-start td { border-top: 3px solid #08285f; }
.poster-table .unit-row.unit-group-start td:not(.unit-cell) { border-top-width: 3px; }
.poster-table .unit-row.unit-end td { border-bottom: 3px solid #c79313; }
.poster-table .unit-row.unit-group-end td:not(.unit-cell) { border-bottom-width: 3px; }
.poster-table .unit-row.unit-normal td:not(.unit-cell) { background: #ffffff; }
.poster-table .unit-row.unit-alt td:not(.unit-cell) { background: #fffaf0; }
.poster-table .group-divider td { height: 8px; padding: 0; border: 0 !important; background: transparent !important; }
.poster-table .unit-cell {
  position: relative;
  width: 28%;
  color: #08285f;
  background: linear-gradient(180deg, #e8f2ff, #dbeaff);
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  border-top: 3px solid #08285f;
  border-bottom: 3px solid #c79313;
  border-right: 2px solid #8998b0;
  box-shadow: inset 6px 0 0 #08285f, 0 1px 0 rgba(8,40,95,.08);
}
.poster-table .unit-row.unit-alt .unit-cell {
  background: linear-gradient(180deg, #fff2d1, #ffe8aa);
  box-shadow: inset 6px 0 0 #c79313, 0 1px 0 rgba(199,147,19,.08);
}
.unit-badge {
  display: inline-grid;
  place-items: center;
  min-width: 80px;
  padding: 7px 8px;
  border-radius: 12px;
  background: rgba(255,255,255,.72);
  box-shadow: inset 0 0 0 1px rgba(8,40,95,.08);
}
.poster-table .param-cell { width: 45%; text-align: center; font-weight: 800; color: #16284a; }
.poster-table .value-cell { width: 27%; text-align: center; white-space: nowrap; color: #14233f; font-weight: 700; }
.poster-side-section + .poster-side-section { margin-top: 10px; }
.side-title {
  padding: 10px 9px;
  color: white;
  background: linear-gradient(135deg, #061f56, #0f3a7f);
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.poster-side-hero .side-title { font-size: 12px; }
.poster-matrix-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.poster-matrix-table th {
  padding: 7px 4px;
  color: #425271;
  background: #eef4fb;
  border-right: 1px solid #d5deec;
  font-size: 10px;
  text-transform: uppercase;
}
.poster-matrix-table th:first-child { width: 52%; }
.poster-matrix-table th:last-child { border-right: 0; }
.poster-matrix-table td {
  padding: 6px 5px;
  border-top: 1px solid #dde5f1;
  border-right: 1px solid #dde5f1;
  font-size: 10px;
  font-weight: 700;
  color: #1c2c48;
}
.poster-matrix-table td:last-child { border-right: 0; }
.poster-matrix-alt td { background: #fbfcfe; }
.poster-check { text-align: center; color: #7f8ca5; }
.poster-check.active { color: #0b2f72; }
.poster-check.gold.active { color: #9b6500; }
.water-row { display: grid; grid-template-columns: 1fr 1fr; min-height: 44px; border-top: 1px solid #cbd2de; }
.water-row:first-of-type { border-top: 0; }
.water-label { display: flex; align-items: center; gap: 7px; padding: 7px 8px; border-right: 1px solid #cbd2de; font-size: 11px; font-weight: 700; }
.water-icon { display: grid; place-items: center; width: 25px; height: 25px; border-radius: 50%; color: white; background: #08285f; font-size: 13px; }
.water-value { display: grid; place-items: center; padding: 5px; text-align: center; font-size: 11px; font-weight: 700; }
.mini-table { width: 100%; border-collapse: collapse; }
.mini-table td { padding: 7px 6px; border-top: 1px solid #d4dae4; border-right: 1px solid #d4dae4; text-align: center; font-size: 11px; }
.mini-table tr:first-child td { border-top: 0; }
.mini-table td:last-child { border-right: 0; }
.mini-table td:first-child { width: 55%; background: #fff7e5; font-weight: 700; }
.lpg-value { padding: 18px 10px; text-align: center; font-size: 22px; font-weight: 700; }
.poster-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 9px 12px;
  border-radius: 12px;
  color: #57657f;
  background: rgba(255,255,255,.82);
  font-size: 9px;
}

@media (min-width: 640px) {
  .app-header { padding-left: 28px; padding-right: 28px; }
  .page-shell { padding: 24px 20px 0; }
  .two-col { grid-template-columns: 1fr 1fr; }
  .unit-inputs { grid-template-columns: 1fr 1fr; }
  .sticky-actions { position: sticky; bottom: 0; width: min(760px, 100%); margin: 18px auto 0; border: 1px solid rgba(8,31,77,.1); border-radius: 20px 20px 0 0; }
  .mobile-action-spacer { height: 14px; }
}

@media (max-width: 420px) {
  .form-card { padding: 16px 14px; }
  .section-heading h2 { font-size: 22px; }
  .matrix-head { padding: 13px 12px 11px; }
  .matrix-title { font-size: 19px; }
  .matrix-table thead th { padding: 11px 7px; font-size: 10px; }
  .matrix-label { padding: 11px 10px; font-size: 12px; }
  .check-box { width: 26px; height: 26px; }
}
