:root {
  color-scheme: dark;
  --bg: #081421;
  --panel: #10243a;
  --panel-2: #142c46;
  --line: #2a4665;
  --text: #f5f8fc;
  --muted: #9fb0c4;
  --blue: #4295ff;
  --blue-dark: #126bd1;
  --green: #24b36b;
  --red: #ed4d63;
  --yellow: #f4b942;
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at top, #12304f 0, var(--bg) 38rem); color: var(--text); }
button, input, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
.app-header { position: sticky; top: 0; z-index: 20; backdrop-filter: blur(18px); background: rgba(8,20,33,.86); border-bottom: 1px solid rgba(255,255,255,.08); }
.header-inner { width: min(1100px, calc(100% - 28px)); margin: 0 auto; min-height: 78px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.app-title-group { display: flex; align-items: center; gap: 14px; min-width: 0; }
.site-return { flex: 0 0 auto; color: #eaf3ff; text-decoration: none; font-weight: 800; border: 1px solid rgba(255,255,255,.14); border-radius: 11px; padding: 10px 13px; background: rgba(33,72,111,.55); }
.site-return:hover, .site-return:focus-visible { background: #21486f; outline: none; }
.app-logo { width: 48px; height: 48px; border-radius: 12px; }
h1 { margin: 0; font-size: clamp(1.35rem, 4vw, 1.8rem); letter-spacing: -.03em; }
#saveStatus { margin: 2px 0 0; color: var(--muted); font-size: .83rem; }
.app-shell { width: min(1100px, calc(100% - 24px)); margin: 24px auto 120px; }
#inspectionForm { display: grid; gap: 18px; }
.form-card { background: linear-gradient(180deg, rgba(20,44,70,.96), rgba(13,31,51,.96)); border: 1px solid rgba(255,255,255,.09); border-radius: var(--radius); padding: clamp(18px, 4vw, 28px); box-shadow: 0 18px 50px rgba(0,0,0,.22); }
.section-heading { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.section-heading h2 { margin: 0; font-size: 1.18rem; letter-spacing: -.01em; }
.section-number { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--blue); color: #04101d; font-weight: 900; }
.form-grid { display: grid; gap: 16px; }
.three-col { grid-template-columns: repeat(3, minmax(0, 1fr)); }
label, legend { color: #dbe7f5; font-weight: 700; font-size: .92rem; }
input[type="text"], input[type="date"], input[type="time"], textarea { width: 100%; margin-top: 7px; border: 1px solid var(--line); border-radius: 12px; background: #08192b; color: var(--text); padding: 13px 14px; outline: none; transition: border-color .18s, box-shadow .18s; }
input:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(66,149,255,.14); }
input.invalid, .choice-field.invalid, .signature-wrap.invalid, .check-card.invalid { border-color: var(--red) !important; box-shadow: 0 0 0 3px rgba(237,77,99,.12); }
textarea { resize: vertical; min-height: 110px; }
.input-action { display: flex; gap: 8px; align-items: stretch; margin-top: 7px; }
.input-action input { margin: 0; }
.mini-button, .tool-button, .secondary-button, .primary-button { border: 0; border-radius: 11px; cursor: pointer; font-weight: 800; }
.mini-button { padding: 0 14px; background: #21486f; color: white; }
.choice-field { margin: 18px 0 0; padding: 0; border: 0; min-width: 0; }
.choice-field legend { margin-bottom: 9px; }
.choice-row { display: flex; flex-wrap: wrap; gap: 8px; }
.choice-chip { position: relative; cursor: pointer; }
.choice-chip input { position: absolute; opacity: 0; pointer-events: none; }
.choice-chip span { display: grid; place-items: center; min-height: 44px; min-width: 68px; padding: 9px 15px; border: 1px solid var(--line); border-radius: 11px; background: #0a1b2d; color: #dbe7f5; transition: .16s ease; }
.choice-chip input:checked + span { background: var(--blue); color: #04101d; border-color: var(--blue); box-shadow: 0 8px 24px rgba(66,149,255,.22); }
.choice-chip.green input:checked + span { background: var(--green); border-color: var(--green); }
.choice-chip.red input:checked + span { background: var(--red); border-color: var(--red); color: white; }
.choice-chip.flashing input:checked + span { background: var(--yellow); border-color: var(--yellow); }
.inspection-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.inspection-grid .choice-field { margin: 0; padding: 15px; border: 1px solid rgba(255,255,255,.08); border-radius: 14px; background: rgba(6,19,33,.36); }
.reefer-dependent.disabled { opacity: .45; }
.drawing-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.tool-button { background: #21486f; color: white; padding: 10px 13px; }
.tool-button.active { background: var(--blue); color: #04101d; }
.tool-button.danger { background: #4a2630; color: #ffdce1; }
.diagram-pad { position: relative; width: 100%; aspect-ratio: 1035 / 445; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: white; touch-action: none; }
.diagram-pad img, .diagram-pad canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.diagram-pad img { object-fit: fill; }
.diagram-pad canvas { touch-action: none; cursor: crosshair; }
.full-width { display: block; margin-top: 16px; }
.status-row .choice-chip span { min-width: 112px; }
.stop-banner { margin: 16px 0; padding: 14px; border-radius: 12px; background: rgba(237,77,99,.15); border: 1px solid rgba(237,77,99,.55); color: #ffdbe0; text-align: center; font-weight: 900; }
.dock-checks { display: grid; gap: 10px; margin-top: 18px; }
.check-card { display: flex; align-items: center; gap: 13px; padding: 14px; border-radius: 13px; border: 1px solid rgba(255,255,255,.09); background: rgba(6,19,33,.35); cursor: pointer; }
.check-card input { width: 24px; height: 24px; accent-color: var(--blue); flex: 0 0 auto; }
.check-card span { font-weight: 600; color: #dbe7f5; }
.check-card strong { color: white; margin-right: 5px; }
.check-card.disabled { opacity: .42; cursor: not-allowed; }
.signature-wrap { position: relative; margin-top: 12px; height: 190px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: #fff; touch-action: none; }
.signature-wrap canvas { width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.signature-line { position: absolute; left: 5%; right: 5%; bottom: 26px; color: #607080; border-bottom: 2px solid #8b97a3; padding-bottom: 4px; font-size: .75rem; text-align: right; pointer-events: none; }
.signature-actions { margin-top: 10px; display: flex; justify-content: flex-end; }
.form-error { padding: 14px 16px; border: 1px solid rgba(237,77,99,.7); border-radius: 13px; background: rgba(237,77,99,.13); color: #ffe2e6; font-weight: 700; }
.action-bar { position: sticky; bottom: 10px; z-index: 10; display: flex; gap: 10px; justify-content: flex-end; padding: 12px; border-radius: 16px; background: rgba(8,20,33,.9); backdrop-filter: blur(14px); border: 1px solid rgba(255,255,255,.1); box-shadow: 0 14px 40px rgba(0,0,0,.35); }
.secondary-button, .primary-button { min-height: 48px; padding: 12px 18px; }
.secondary-button { background: #21405f; color: white; }
.danger-outline { border: 1px solid #75414a; background: transparent; color: #ffdce1; }
.primary-button { background: linear-gradient(135deg, #4aa0ff, #1e77dc); color: #04101d; min-width: 230px; }
.primary-button:disabled { cursor: wait; opacity: .72; }
.print-report { display: none; }
@media (max-width: 780px) {
  .three-col, .inspection-grid { grid-template-columns: 1fr; }
  .app-shell { width: min(100% - 16px, 1100px); margin-top: 12px; }
  .form-card { padding: 17px; border-radius: 15px; }
  .action-bar { display: grid; grid-template-columns: 1fr 1fr; }
  .primary-button { grid-column: 1 / -1; min-width: 0; }
  .status-row { display: grid; grid-template-columns: 1fr; }
  .status-row .choice-chip span { width: 100%; }
}
@media print {
  @page { size: letter portrait; margin: 0; }
  html, body { margin: 0 !important; padding: 0 !important; background: white !important; }
  body > :not(.print-report) { display: none !important; }
  .print-report { display: block !important; }
  .print-page { width: 8.5in; height: 11in; margin: 0; page-break-after: always; break-after: page; overflow: hidden; background: white; }
  .print-page:last-child { page-break-after: auto; break-after: auto; }
  .print-page canvas { display: block; width: 8.5in; height: 10.96in; }
}

/* Real-time print alignment editor */
.alignment-launch { position: fixed; right: 18px; bottom: 18px; z-index: 40; border: 0; border-radius: 999px; padding: 12px 18px; background: #0c1f36; color: #fff; font-weight: 800; box-shadow: 0 10px 28px rgba(0,0,0,.25); cursor: pointer; }
.alignment-editor[hidden] { display: none !important; }
.alignment-editor { position: fixed; inset: 0; z-index: 100; background: rgba(6,18,32,.88); display: grid; grid-template-columns: minmax(290px, 370px) 1fr; gap: 14px; padding: 14px; }
.alignment-controls { background: #fff; border-radius: 14px; padding: 16px; overflow: auto; }
.alignment-controls h2 { margin: 0 0 4px; }
.alignment-controls p { margin: 0 0 14px; color: #4b5968; }
.alignment-control-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.alignment-controls label { display: grid; gap: 5px; font-weight: 700; }
.alignment-controls select, .alignment-controls input[type="number"] { width: 100%; min-height: 42px; border: 1px solid #b7c1cd; border-radius: 8px; padding: 8px; font: inherit; }
.alignment-nudges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin: 12px 0; }
.alignment-nudges button, .alignment-actions button { min-height: 40px; border: 1px solid #9ba8b6; border-radius: 8px; background: #f4f7fa; font-weight: 800; cursor: pointer; }
.alignment-nudges .blank { visibility: hidden; }
.alignment-actions { display: grid; gap: 8px; margin-top: 14px; }
.alignment-actions .primary { background: #075bb5; color: #fff; border-color: #075bb5; }
.alignment-actions .danger { color: #a3122e; }
.alignment-check { display: flex !important; grid-template-columns: none !important; align-items: center; gap: 8px !important; margin: 10px 0; }
.alignment-check input { width: 20px; height: 20px; }
.alignment-readout { padding: 10px; border-radius: 8px; background: #edf4fb; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; white-space: pre-wrap; }
.alignment-preview { overflow: auto; border-radius: 14px; background: #313b45; padding: 18px; }
.alignment-preview-page { position: relative; margin: 0 auto 18px; width: min(100%, 850px); }
.alignment-preview-page canvas { width: 100%; height: auto; display: block; background: #fff; box-shadow: 0 7px 24px rgba(0,0,0,.35); }
.alignment-page-label { color: #fff; font-weight: 800; margin: 0 0 7px; }
.alignment-tip { font-size: 12px; color: #647183; margin-top: 10px; }
@media (max-width: 850px) {
  .alignment-editor { grid-template-columns: 1fr; grid-template-rows: auto 1fr; padding: 8px; }
  .alignment-controls { max-height: 45vh; }
  .alignment-launch { right: 10px; bottom: 10px; }
}
@media print { .alignment-launch, .alignment-editor { display: none !important; } }
