/* See how nico works, from referral to remittance — the faxed documents: a letter-size page (612 by 792 at 72 dpi) with a printed form and handwriting, the
   thumbnails in the inspector, the viewer layer, and the extraction overlay. Demo content, not the design system: a fax
   is a photocopy of someone else's paper, so it uses office faces, not the Chart faces. */
:root { --font-hand: "Caveat", "Segoe Print", "Bradley Hand", "Comic Sans MS", cursive; --font-form: Arial, Helvetica, sans-serif; --font-letter: "Times New Roman", Times, serif; --font-print: "Courier New", Courier, monospace; --paper: #fbfbf9; --paper-ink: #171717; --paper-rule: #8a8a8a; --paper-faint: #5c5c5c; --hand-ink: #1c1c1c; }

/* the page */
.doc-page { position: relative; width: 612px; height: 792px; background: var(--paper); color: var(--paper-ink); font-family: var(--font-form); font-size: 9.5px; line-height: 12px; overflow: hidden; box-shadow: 0 1px 2px #0003, 0 6px 18px -8px #0006; }
.doc-page::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .08; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E"); mix-blend-mode: multiply; }
.doc-page.is-skew-a .doc-body { transform: rotate(-.35deg); }
.doc-page.is-skew-b .doc-body { transform: rotate(.25deg); }
.doc-body { position: absolute; inset: 14px 34px 22px 34px; }
.fax-hdr { position: absolute; top: 3px; left: 24px; right: 24px; font-family: var(--font-print); font-size: 7.5px; line-height: 10px; color: #333; letter-spacing: .02em; white-space: nowrap; overflow: hidden; display: flex; justify-content: space-between; filter: blur(.15px); }
.doc-foot { position: absolute; left: 34px; right: 34px; bottom: 10px; font-size: 7px; line-height: 10px; color: var(--paper-faint); display: flex; justify-content: space-between; }

/* the printed form */
.form-head { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 2px solid var(--paper-ink); padding-bottom: 2px; margin-bottom: 4px; }
.form-head h1 { margin: 0; font-size: 15px; line-height: 18px; letter-spacing: .06em; font-weight: 700; }
.form-head h1 small { display: block; font-size: 9px; letter-spacing: .02em; font-weight: 400; margin-top: 2px; }
.form-head .addr { text-align: right; font-size: 7.5px; line-height: 10px; color: var(--paper-faint); }
.form-sec { border: 1px solid var(--paper-ink); margin-bottom: 3px; }
.form-sec > h2 { margin: 0; font-size: 8px; line-height: 12px; letter-spacing: .08em; text-transform: uppercase; font-weight: 700; padding: 0 5px; background: #e6e6e3; border-bottom: 1px solid var(--paper-ink); display: flex; justify-content: space-between; }
.form-sec > h2 span { font-weight: 400; text-transform: none; letter-spacing: 0; }
.form-row { display: flex; gap: 8px; padding: 3px 5px 0; }
.form-row:last-child { padding-bottom: 4px; }
.f { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.f.w2 { flex: 2; } .f.w3 { flex: 3; } .f.w05 { flex: .6; }
.f > label { font-size: 6.5px; line-height: 8px; letter-spacing: .04em; text-transform: uppercase; color: var(--paper-faint); }
.f > .line { min-height: 14px; border-bottom: 1px solid var(--paper-rule); padding: 0 2px; display: flex; align-items: flex-end; gap: 4px; }
.f > .line.tall { min-height: 46px; align-items: flex-start; }
.f > .line.typed { font-size: 9px; align-items: flex-end; flex-wrap: wrap; row-gap: 2px; }
.cb { display: inline-flex; align-items: center; gap: 3px; margin-right: 6px; font-size: 8px; white-space: nowrap; }
.cb i { position: relative; width: 8px; height: 8px; border: 1px solid var(--paper-ink); display: inline-block; flex: none; }
.cb i svg { position: absolute; left: -3px; top: -6px; width: 15px; height: 14px; fill: none; stroke: var(--hand-ink); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* handwriting: one family on a variable, so a different hand is one line */
.hw { font-family: var(--font-hand); font-size: 14px; line-height: 15px; font-weight: 600; color: var(--hand-ink); display: inline-block; transform: rotate(var(--r, 0deg)) translateY(var(--y, 0px)); transform-origin: left bottom; white-space: nowrap; letter-spacing: .01em; }
.hw.sm { font-size: 12px; }
.hw.lg { font-size: 16px; }
.hw.note { white-space: normal; line-height: 16px; font-weight: 500; }
.hw.light { opacity: .82; }
.sig { display: block; height: 22px; width: auto; fill: none; stroke: var(--hand-ink); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.sig.lg { height: 34px; }
/* the hand itself: crops of the scanned template in place of the font; the span keeps its jitter and its extraction label */
.hw.has-img { line-height: 0; }
.hw-img { display: block; width: auto; max-width: 100%; }
.hw.note.has-img { max-width: 100%; }
.hw.sm.has-img { margin-left: 8px; }
.sig-img { height: 24px; width: auto; display: block; margin-top: -8px; stroke: none; }
.sig-img.lg { height: 38px; margin-top: 0; }
/* the overlay follows the ink: the label clears the crop's top */
.show-x .x.has-img::before { bottom: calc(100% + 3px); }
.cb i img.tick-img { position: absolute; left: -2px; top: -8px; height: 15px; width: auto; }
.stamp { position: absolute; right: 40px; top: 70px; transform: rotate(-9deg); border: 2px solid #8b1d1d; color: #8b1d1d; font-size: 8px; line-height: 10px; letter-spacing: .12em; text-transform: uppercase; padding: 4px 8px; opacity: .55; text-align: center; font-weight: 700; }

/* the EMR printout and the letters */
.print { font-family: var(--font-print); font-size: 8.5px; line-height: 11px; }
.print h1 { font-size: 11px; line-height: 14px; margin: 0 0 2px; letter-spacing: .04em; }
.print table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.print th, .print td { text-align: left; padding: 2px 3px; border-bottom: 1px solid #bbb; font-weight: 400; vertical-align: top; }
.print th { border-bottom: 1px solid var(--paper-ink); text-transform: uppercase; font-size: 7px; letter-spacing: .04em; }
.print .rule { border-top: 1px solid var(--paper-ink); margin: 4px 0; }
.letter { font-family: var(--font-letter); font-size: 9.5px; line-height: 13px; }
.letter .lh { display: flex; justify-content: space-between; border-bottom: 1px solid var(--paper-ink); padding-bottom: 6px; margin-bottom: 10px; }
.letter .lh b { font-family: var(--font-form); font-size: 12px; letter-spacing: .08em; }
.letter .lh span { font-family: var(--font-form); font-size: 7.5px; line-height: 10px; color: var(--paper-faint); text-align: right; }
.letter p { margin: 0 0 7px; }
.letter h2 { font-size: 10.5px; margin: 8px 0 4px; }
.letter table { width: 100%; border-collapse: collapse; font-family: var(--font-form); font-size: 8.5px; margin: 4px 0 8px; }
.letter th, .letter td { text-align: left; padding: 3px 4px; border: 1px solid #999; }
.letter th { background: #ececea; font-weight: 700; }
.letter .ref { font-family: var(--font-print); }
.card { width: 230px; height: 160px; border: 1px solid #777; border-radius: 8px; background: #fff; padding: 10px 12px; font-family: var(--font-form); position: relative; margin: 10px auto 0; box-shadow: inset 0 0 0 1px #ddd; }
.card b { display: block; font-size: 11px; letter-spacing: .1em; }
.card small { display: block; font-size: 7px; color: var(--paper-faint); }
.card .row { display: flex; justify-content: space-between; gap: 8px; font-size: 8px; margin-top: 5px; }
.card .row span { display: flex; flex-direction: column; }
.card .row span small { font-size: 6px; }
.card .mono { font-family: var(--font-print); font-size: 9px; }
.card .tiny { position: absolute; left: 12px; right: 12px; bottom: 8px; font-size: 6.5px; line-height: 9px; color: var(--paper-faint); }

/* the extraction overlay: what the agent read, with its confidence; the only color on the page */
.x { position: relative; }
.show-x .x { outline: 1.5px dashed var(--provenance-extracted); outline-offset: 2px; border-radius: 2px; }
.show-x .x::before { content: attr(data-x); position: absolute; left: -2px; bottom: calc(100% + 4px); font-family: var(--font-mono); font-size: 7.5px; line-height: 10px; font-weight: 400; letter-spacing: 0; color: var(--on-accent); background: var(--provenance-extracted); padding: 0 4px; border-radius: 3px; white-space: nowrap; transform: none; z-index: 2; }
.show-x .x.is-low { outline-color: var(--state-needs-you); }
.show-x .x.is-low::before { background: var(--state-needs-you); }

/* thumbnails in the inspector: the page scaled to the card, a button each */
.doc-thumbs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.doc-thumb { position: relative; display: flex; flex-direction: column; gap: var(--space-1); padding: 0; border: 0; background: none; cursor: pointer; text-align: left; font: inherit; color: inherit; }
.doc-thumb:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-sm); }
.doc-thumb-page { width: 100%; aspect-ratio: 612 / 792; overflow: hidden; border: 1px solid var(--line-control); border-radius: 2px; background: var(--paper); position: relative; }
.doc-thumb-page .doc-page { position: absolute; left: 0; top: 0; transform-origin: top left; box-shadow: none; }
.doc-thumb small { font-size: 12px; line-height: 16px; color: var(--ink-faint); }
.doc-thumb:hover .doc-thumb-page { border-color: var(--accent); }

/* the viewer: a layer over everything, the page at readable size */
.doc-viewer { display: flex; flex-direction: column; gap: var(--space-3); width: min(100%, 720px); max-height: calc(100vh - 24vh); }
.doc-viewer-bar { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); padding: var(--space-2) var(--space-3); color: var(--ink); font-size: 13px; line-height: 18px; }
.doc-viewer-bar b { font-weight: 600; }
.doc-viewer-bar .nc-issue-key { margin-left: var(--space-1); }
.doc-viewer-bar .spacer { flex: 1; }
.doc-viewer-stage { flex: 1; min-height: 0; overflow: auto; display: flex; justify-content: center; padding: var(--space-2) 0 var(--space-4); }
.doc-viewer-stage > div { width: calc(612px * var(--doc-scale, 1)); height: calc(792px * var(--doc-scale, 1)); flex: none; position: relative; }
.doc-viewer-stage .doc-page { transform: scale(var(--doc-scale, 1)); transform-origin: top left; }
.doc-viewer .nc-btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
@media (max-width: 760px) { .doc-viewer-bar .doc-viewer-title { width: 100%; } }
