:root {
  color-scheme: light;
  --ink: #202824;
  --muted: #65726b;
  --brand: #176b55;
  --brand-dark: #0d4f3e;
  --brand-soft: #eaf4f0;
  --line: #d7dfda;
  --paper: #fff;
  --ground: #f4f6f3;
  --danger: #b42318;
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--ground); color: var(--ink); }
body { margin: 0; min-width: 320px; }
.page-header { background: linear-gradient(135deg, #0d4f3e, #247c65); color: #fff; padding: 42px 20px 34px; }
.header-inner, .layout, body > footer p { width: min(100%, 840px); margin-inline: auto; }
.eyebrow { margin: 0 0 7px; color: #9ed9c7; font-size: .78rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
h1 { margin: 0; font-family: "Yu Mincho", "Hiragino Mincho ProN", serif; font-size: clamp(1.65rem, 5vw, 2.5rem); line-height: 1.35; letter-spacing: .035em; }
.lead { max-width: 680px; margin: 13px 0 20px; line-height: 1.75; color: #e4f1ed; }
.billing-note { margin: 0; padding: 10px 13px; border: 1px solid rgba(255,255,255,.25); border-radius: 6px; background: rgba(0,0,0,.12); color: #eaf4f0; font-size: .76rem; line-height: 1.65; }
.load-error { margin: 16px 0 0; padding: 12px; border-radius: 6px; background: #fff0ee; color: #8f1710; font-weight: 700; }
.layout { padding: 28px 18px 60px; }
.editor { display: grid; gap: 16px; }
.step-card { min-width: 0; margin: 0; padding: 22px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); box-shadow: 0 2px 8px rgba(24, 54, 43, .035); }
fieldset.step-card { display: block; }
fieldset.step-card:disabled { opacity: .55; }
.step-heading, legend { display: flex; align-items: flex-start; gap: 12px; width: 100%; margin: 0 0 20px; padding: 0; border: 0; }
.step-heading > span, legend > span:first-child { display: grid; flex: 0 0 30px; width: 30px; height: 30px; place-items: center; border-radius: 50%; background: var(--brand); color: #fff; font-weight: 700; }
.step-heading h2, legend b { display: block; margin: 1px 0 3px; font-size: 1.1rem; }
.step-heading p, legend small { display: block; margin: 0; color: var(--muted); font-size: .82rem; font-weight: 400; line-height: 1.55; }
label { display: block; margin: 15px 0 7px; font-size: .88rem; font-weight: 700; }
label:first-of-type { margin-top: 0; }
label strong { margin-left: 5px; color: var(--danger); font-size: .7rem; }
input, select, textarea, button { font: inherit; }
input[type="text"], input[type="search"], input[type="number"], input[type="date"], input[type="tel"], select, textarea { width: 100%; max-width: 100%; min-height: 44px; padding: 9px 11px; border: 1px solid #b9c5be; border-radius: 6px; background: #fff; color: var(--ink); }
textarea { resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 3px solid rgba(29, 124, 98, .2); border-color: var(--brand); }
input:disabled, select:disabled { background: #eef1ef; color: #7a837f; }
.two-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.suffix-input { display: flex; align-items: center; gap: 8px; }
.suffix-input input { min-width: 0; }
.choice-list { display: grid; gap: 8px; }
.drug-choice-item { min-width: 0; }
.choice-row, .check-line, .main-other { display: flex; align-items: flex-start; gap: 9px; margin: 0; padding: 11px 12px; border: 1px solid var(--line); border-radius: 6px; font-weight: 500; line-height: 1.45; cursor: pointer; }
.choice-row:hover, .check-line:hover { background: var(--brand-soft); }
.drug-check { display: flex; flex: 1; align-items: flex-start; gap: 9px; min-width: 0; margin: 0; font-weight: 500; cursor: pointer; }
.choice-row input, .check-line input, .main-other input { flex: 0 0 auto; margin: 3px 0 0; accent-color: var(--brand); }
.choice-row .primary-picker { margin: 0 0 0 auto; padding-left: 10px; color: var(--brand-dark); font-size: .75rem; font-weight: 700; white-space: nowrap; }
.choice-row .primary-picker input { margin-right: 4px; }
.choice-name { min-width: 0; overflow-wrap: anywhere; }
.drug-document-actions { display: flex; flex: 0 0 auto; align-items: center; gap: 8px; margin-left: auto; }
.drug-document-actions a, .action-with-preview a { color: var(--brand-dark); font-size: .75rem; font-weight: 700; }
.drug-document-actions a[aria-disabled="true"], .action-with-preview a[aria-disabled="true"] { color: #7b8580; cursor: not-allowed; text-decoration: none; }
.small-button { min-height: 30px; padding: 4px 9px; font-size: .75rem; }
.originals-panel { margin: 6px 0 12px; padding: 10px; border: 1px solid #b9c9c1; border-radius: 6px; background: #f7faf8; }
.originals-panel[hidden], .original-embed[hidden] { display: none; }
.original-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; padding: 10px; border-radius: 5px; background: #fff; }
.original-item + .original-item { margin-top: 8px; border-top: 1px solid var(--line); }
.original-description, .original-pages, .originals-empty { margin: 0; overflow-wrap: anywhere; }
.original-description { font-size: .82rem; line-height: 1.55; }
.original-pages { margin-top: 3px; color: var(--muted); font-size: .75rem; }
.originals-empty { color: var(--muted); font-size: .8rem; line-height: 1.6; }
.original-actions { display: flex; align-items: flex-start; gap: 6px; }
.original-embed { grid-column: 1 / -1; min-width: 0; }
.original-embed-help { margin: 2px 0 6px; color: var(--muted); font-size: .75rem; }
.original-embed iframe { width: 100%; height: 70vh; border: 1px solid var(--line); background: #fff; }
.other-drug { margin-top: 16px; padding: 16px; border: 1px dashed #aebbb4; border-radius: 8px; background: #fafbf9; }
.main-other { margin-top: 14px; color: var(--brand-dark); }
.helper, .empty-choice { color: var(--muted); font-size: .78rem; line-height: 1.55; }
.helper { margin: 12px 0 0; }
.compact .choice-row { padding: 9px 11px; }
.seal-technique-checks { margin-top: 18px; padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: #fafbf9; }
.seal-technique-checks h3 { margin: 0; font-size: .92rem; }
.seal-technique-checks > p { margin: 4px 0 12px; color: var(--muted); font-size: .75rem; }
.seal-technique-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.seal-technique-grid label { margin: 0; font-size: .73rem; }
.seal-technique-grid select { min-height: 36px; margin-top: 5px; padding: 5px 7px; font-size: .76rem; }
.preview-section { margin-top: 32px; }
.preview-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.preview-heading .eyebrow { color: var(--brand); }
.preview-heading h2 { margin: 0; font-family: "Yu Mincho", "Hiragino Mincho ProN", serif; font-size: 1.6rem; }
.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.action-with-preview { display: flex; align-items: center; gap: 6px; }
button { min-height: 42px; padding: 9px 16px; border: 1px solid var(--brand); border-radius: 6px; background: #fff; color: var(--brand-dark); font-weight: 700; cursor: pointer; }
button.primary { background: var(--brand); color: #fff; }
button:disabled { border-color: #bdc5c1; background: #e4e8e6; color: #7b8580; cursor: not-allowed; }
.missing-fields { margin: 0 0 10px; padding: 10px 12px; border-left: 4px solid var(--danger); background: #fff0ee; color: var(--danger); font-size: .86rem; font-weight: 700; }
.report-paper { min-height: 700px; padding: clamp(24px, 7vw, 64px); border: 1px solid #d3d7d4; background: #fff; box-shadow: 0 5px 20px rgba(21, 39, 31, .08); font-family: "Yu Mincho", "Hiragino Mincho ProN", serif; font-size: .95rem; line-height: 1.9; white-space: pre-wrap; overflow-wrap: anywhere; }
.copy-status { min-height: 1.5em; color: var(--brand-dark); font-size: .85rem; }
body > footer { padding: 20px; background: #e8ece9; color: var(--muted); font-size: .78rem; text-align: center; }
.mobile-break { display: none; }
.print-only { display: none; }
.document-screen-section { margin-top: 28px; scroll-margin-top: 12px; }
.document-screen-section > h3 { margin: 0 0 12px; font-size: 1.15rem; }
.leaflet-preview-stack, .seal-preview-stack { display: grid; gap: 18px; }
.leaflet-page { display: flex; flex-direction: column; min-height: 700px; padding: clamp(24px, 6vw, 54px); border: 1px solid #d3d7d4; background: #fff; box-shadow: 0 5px 20px rgba(21, 39, 31, .08); font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", sans-serif; font-size: 11pt; line-height: 1.55; }
.leaflet-page h1 { margin: 0 0 5px; font-size: 20pt; line-height: 1.35; overflow-wrap: anywhere; }
.leaflet-page h2 { margin: 0 0 14px; padding-bottom: 9px; border-bottom: 2px solid var(--brand); color: var(--brand-dark); font-size: 16pt; line-height: 1.35; }
.leaflet-page h3 { margin: 13px 0 5px; font-size: 12pt; }
.leaflet-page p { margin: 5px 0; }
.leaflet-page ol, .leaflet-page ul { margin: 4px 0; padding-left: 1.8em; }
.leaflet-page li { margin: 3px 0; }
.leaflet-gargle { margin-top: 11px !important; }
.leaflet-footer { width: 100%; margin-top: auto; padding-top: 14px; border-top: 1px solid #98a69f; background: transparent; color: var(--ink); text-align: left; }
.leaflet-footer p { width: auto; margin-inline: 0; }
.leaflet-footer-message { font-weight: 700; }
.leaflet-source { color: #6b7470; font-size: 9pt; }
.leaflet-originals { margin-top: 8px; padding-top: 7px; border-top: 1px solid #ccd4d0; break-inside: avoid; page-break-inside: avoid; }
.leaflet-originals h3 { margin: 0 0 5px; font-size: 9pt; }
.leaflet-original-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4mm; }
.leaflet-original-item { min-width: 0; break-inside: avoid; page-break-inside: avoid; }
.leaflet-original-qr svg { display: block; width: 22mm; height: 22mm; }
.leaflet-original-details p { margin: 2px 0 0; font-size: 7.5pt; line-height: 1.25; overflow-wrap: anywhere; }
.leaflet-original-title { font-weight: 700; }
.leaflet-original-url { color: #59635e; word-break: break-all; }
.seal-preview-stack { justify-items: center; padding: 20px; border: 1px solid #d3d7d4; background: #fff; box-shadow: 0 5px 20px rgba(21, 39, 31, .08); }
.seal-face { width: 90mm; height: 65mm; padding: 2.5mm; overflow: hidden; border: 1px dashed #66736c; background: #fff; color: #111; font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", sans-serif; font-size: 10.5pt; line-height: 1.15; }
.seal-face h1 { margin: 0 0 1mm; font-size: 10.5pt; line-height: 1.15; }
.seal-face p { margin: .5mm 0; overflow-wrap: anywhere; }
.seal-patient, .seal-drug { font-weight: 700; }
.seal-flu-guidance { padding-left: 3em; }

@media (max-width: 600px) {
  .page-header { padding: 28px 18px 26px; }
  .mobile-break { display: initial; }
  .layout { padding-inline: 12px; }
  .step-card { padding: 18px 15px; }
  .two-columns { grid-template-columns: 1fr; gap: 0; }
  .choice-row { flex-wrap: wrap; }
  .choice-row .primary-picker { flex-basis: 100%; margin: 0 0 0 24px; }
  .drug-document-actions { margin-left: 24px; }
  .original-item { grid-template-columns: 1fr; }
  .original-actions { justify-content: flex-start; }
  .leaflet-original-list { grid-template-columns: 1fr; }
  .seal-technique-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .preview-heading { align-items: flex-start; flex-direction: column; }
  .actions { width: 100%; justify-content: flex-start; }
  .actions > button { flex: 1; padding-inline: 8px; }
  .action-with-preview { width: 100%; }
  .action-with-preview button { flex: 1; padding-inline: 8px; }
  .report-paper { min-height: 520px; }
  .seal-preview-stack { align-items: start; justify-items: start; overflow-x: auto; }
}

@page { size: A4 portrait; margin: 20mm; }
@page leaflet { size: A4 portrait; margin: 15mm; }
@page seal { size: A4 portrait; margin: 15mm; }
@media print {
  html, body { background: #fff; }
  .page-header, .editor, .preview-heading, .missing-fields, .copy-status, .document-screen-section, body > footer { display: none !important; }
  .layout { width: auto; margin: 0; padding: 0; }
  .preview-section { margin: 0; }
  .report-paper { min-height: 0; padding: 0; border: 0; box-shadow: none; font-family: "Yu Mincho", "Hiragino Mincho ProN", serif; font-size: 10.5pt; line-height: 1.8; }
  body.print-report .document-screen-section,
  body.print-report > .print-only { display: none !important; }
  body.print-leaflet > .page-header,
  body.print-leaflet > .layout,
  body.print-leaflet > footer,
  body.print-leaflet > #seal-print-container,
  body.print-seal > .page-header,
  body.print-seal > .layout,
  body.print-seal > footer,
  body.print-seal > #leaflet-print-container { display: none !important; }
  body.print-leaflet > #leaflet-print-container { display: block !important; }
  body.print-seal > #seal-print-container { display: flex !important; }
  body.print-leaflet .leaflet-page { page: leaflet; width: auto; height: 267mm; min-height: 0; padding: 0; border: 0; box-shadow: none; }
  body.print-leaflet .leaflet-page:not(:last-child) { break-after: page; page-break-after: always; }
  body.print-seal #seal-print-container { page: seal; flex-direction: column; align-items: center; justify-content: space-around; height: 267mm; }
  body.print-seal .seal-face { flex: 0 0 65mm; break-inside: avoid; }
}
