/* Packets (P3): the Packets view and the packet studio. Kit tokens only; the pages themselves wear the
   clinic's brand in packet.css. At 1440 the studio's page column is ≥ 590 px wide, so the smallest page
   text (13 design px) renders at ≥ 9 px (P14.1). */

.pk-v { display: flex; flex-direction: column; gap: var(--space-6); }
.pk-v-body { display: flex; flex-direction: column; gap: var(--space-6); }
.pk-v-pills { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.pk-v-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.pk-v-step { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); color: var(--color-ink-3); font-size: var(--text-meta); line-height: var(--leading-meta); }
.pk-v-step b { font-weight: var(--weight-medium); color: var(--color-ink-2); }
.pk-v-back { align-self: flex-start; }

/* Packets inside the kit's paper: the kit's frame draws the paper, so the sheet's own edge is dropped. */
.k-paper .pk-sheet { box-shadow: none; }

/* ── This week ─────────────────────────────────────────────────────────── */
.pk-v-week__grid { display: grid; gap: var(--space-8); align-items: start; }
@media (min-width: 900px) { .pk-v-week__grid { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); } }
.pk-v-desk { min-height: 320px; gap: var(--space-12); flex-wrap: wrap; }
.pk-v-deskitem { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); border-radius: var(--radius-lg); color: var(--color-ink); text-decoration: none; }
.pk-v-deskitem .k-pstack { margin-bottom: var(--space-3); }
.pk-v-deskitem__name { font-size: var(--text-body); line-height: var(--leading-body); font-weight: var(--weight-medium); }
.pk-v-week__text { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-4); }
.pk-v-week__title { font-family: var(--font-display); font-weight: var(--weight-regular); font-size: var(--display-m); line-height: var(--display-m-leading); letter-spacing: var(--tracking-display); color: var(--color-ink); }

/* ── Coming up and Sent: one tile per packet ───────────────────────────── */
.pk-v-tiles { display: grid; gap: var(--space-5); grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }
.pk-v-tile { flex-direction: row; align-items: center; gap: var(--space-6); color: var(--color-ink); text-decoration: none; }
.pk-v-tile__paper { display: flex; flex: none; justify-content: center; width: 120px; padding: var(--space-2) 0; }
.pk-v-tile__text { display: flex; min-width: 0; flex-direction: column; gap: var(--space-1); }
.pk-v-tile__text .pk-v-pills { margin-top: var(--space-2); }
.pk-v-tile__name { font-size: var(--text-title); line-height: var(--leading-title); font-weight: var(--weight-medium); }

/* ── Doctors ───────────────────────────────────────────────────────────── */
.pk-v-doc { display: flex; min-width: 0; flex-direction: column; }
.pk-v-doc b { font-weight: var(--weight-medium); }

/* ── The studio: thumbnails · the page · who gets it ───────────────────── */
.pk-v-studio { display: grid; gap: var(--space-6); align-items: start; grid-template-columns: 112px minmax(0, 1fr) 328px; }
.pk-v-thumbs { position: static; display: flex; flex-direction: column; gap: var(--space-4); margin: 0; padding: 0; list-style: none; }
.pk-v-thumb { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-1); }
.pk-v-thumb .k-paper { --paper-w: 96px; }
.pk-v-thumb__name { font-size: var(--text-caption); line-height: var(--leading-caption); color: var(--color-ink-2); }
.pk-v-thumb__fixed { font-size: var(--text-caption); line-height: var(--leading-caption); }
.pk-v-thumbs[data-assembling] .pk-v-thumb { will-change: transform, opacity; }
.pk-v-cardthumb { width: 96px; aspect-ratio: auto; padding: 0; border: 0; cursor: pointer; }
.pk-v-cardthumb .pk-sheet { width: 96px; }

.pk-v-center { min-width: 0; min-height: 640px; }
.pk-v-preview { display: flex; flex-direction: column; gap: var(--space-4); }
.pk-v-preview__bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); }
.pk-v-stage { display: flex; flex-direction: column; gap: var(--space-3); }
.pk-v-tools { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); min-height: 36px; }
.pk-v-tools__name { font-weight: var(--weight-medium); }
.pk-v-tools__end { display: flex; align-items: center; gap: var(--space-1); margin-left: auto; }
.pk-v-pagedesk { padding: var(--space-4); align-items: flex-start; }
.pk-v-pagedesk > .k-paper { width: 100%; }
.pk-v-pagedesk--card > .pk-sheet, .pk-v-chdesk > * { width: 100%; }
.pk-v-chdesk { padding: var(--space-6); align-items: flex-start; }
.pk-v-env { display: flex; width: 100%; flex-direction: column; gap: var(--space-5); }
.pk-v-faxdesk { max-height: 78vh; overflow-y: auto; }
.pk-v-faxdesk .pk-fax { flex-direction: column; flex-wrap: nowrap; gap: var(--space-4); }
.pk-v-chline { max-width: 60ch; }

.pk-v-side { min-width: 0; }
.pk-v-recips { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
.pk-v-recip { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-2); padding: var(--space-3); margin: 0 calc(-1 * var(--space-3)); border-radius: var(--radius-lg); }
.pk-v-recip + .pk-v-recip { border-top: 1px solid var(--color-hairline); border-top-left-radius: 0; border-top-right-radius: 0; }
.pk-v-recip[aria-current] { background: var(--color-brand-tint); }
.pk-v-recip__row { display: flex; width: 100%; min-width: 0; align-items: flex-start; gap: var(--space-3); }
.pk-v-recip__box { flex-shrink: 0; margin-top: 2px; }
.pk-v-recip[data-left] .pk-v-recip__who { opacity: 0.55; }
.pk-v-recip:has(.pk-v-recip__box) > :not(.pk-v-recip__row) { margin-left: calc(20px + var(--space-3)); }
.pk-v-recip__who { display: flex; width: 100%; min-width: 0; flex-direction: column; align-items: flex-start; padding: 0; border: 0; background: none; color: var(--color-ink); text-align: left; cursor: pointer; font: inherit; }
.pk-v-recip__who b { font-weight: var(--weight-medium); }
.pk-v-recip__who:focus-visible { outline: 2px solid var(--color-brand); outline-offset: 2px; border-radius: var(--radius-sm); }

/* The thumbnails stay beside the page while it scrolls only when the recipients have their own column, so
   nothing ever slides over the note or the list below (P6.4). */
@media (min-width: 1100px) { .pk-v-thumbs { position: sticky; top: calc(var(--topbar) + var(--space-4)); } }

/* Below 1100: the page and who gets it share the width; below 768 everything is one column. */
@media (max-width: 1099px) {
  .pk-v-studio { grid-template-columns: 112px minmax(0, 1fr); }
  .pk-v-side { grid-column: 1 / -1; }
}
@media (max-width: 767px) {
  .pk-v-studio { grid-template-columns: minmax(0, 1fr); }
  .pk-v-thumbs { position: static; flex-direction: row; overflow-x: auto; padding-bottom: var(--space-2); order: 2; }
  .pk-v-center { order: 1; min-height: 0; }
  .pk-v-side { order: 3; }
  .pk-v-thumb { flex: none; }
  .pk-v-desk { min-height: 0; gap: var(--space-6); padding: var(--space-6) var(--space-4); }
  .pk-v-deskitem .k-pstack { width: 112px !important; }   /* two stacks side by side on a phone */
  .pk-v-tile { gap: var(--space-4); }
  .pk-v-tile__paper { width: 96px; }
  .pk-v-pagedesk, .pk-v-chdesk { padding: var(--space-3); }
}

/* Just sent: tracking per channel, on top of This week. */
.pk-v-tracks { display: flex; flex-direction: column; gap: var(--space-5); }
.pk-v-track { display: grid; gap: var(--space-3) var(--space-5); align-items: center; grid-template-columns: 220px minmax(0, 1fr); }
.pk-v-track > .k-pill { justify-self: start; }
@media (max-width: 767px) { .pk-v-track { grid-template-columns: minmax(0, 1fr); } }

/* The fax preview scrolls, so it takes focus (keyboard reaches it) and shows it. */
.pk-v-faxdesk:focus-visible { outline: 2px solid var(--color-brand); outline-offset: 2px; }

/* Write to one doctor: the pick list in the sheet. */
.pk-v-pick { display: flex; flex-direction: column; margin: var(--space-4) 0 0; padding: 0; list-style: none; }
.pk-v-pick__row { display: flex; width: 100%; min-height: 56px; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-2) var(--space-3); border: 0; border-radius: var(--radius-lg); background: none; color: var(--color-ink); font: inherit; text-align: left; cursor: pointer; transition: background-color var(--duration-ui) var(--ease-standard); }
.pk-v-pick__row:hover { background: var(--color-ground); }
.pk-v-pick__row:focus-visible { outline: 2px solid var(--color-brand); outline-offset: 2px; }

/* The facts a physician needs, asked for inline before anything goes out. */
.pk-v-facts { display: flex; width: 100%; flex-direction: column; align-items: flex-start; gap: var(--space-4); padding: var(--space-5); border-radius: var(--radius-lg); background: var(--color-surface-2); box-shadow: inset 0 0 0 1px var(--color-hairline); }
.pk-v-facts__why { display: flex; align-items: flex-start; gap: var(--space-2); color: var(--color-ink-2); }
.pk-v-facts__why .k-icon { flex: none; margin-top: 2px; }
.pk-v-facts__grid { display: grid; width: 100%; gap: var(--space-3) var(--space-4); grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); }

/* The send, shown: a scene over the stack for ≤ 900 ms, one lane per channel. The sprites carry the real first
   page, drawn small; the envelope, fax machine and mail window are drawn to match. */
.pk-v-sending { position: relative; }
.pk-v-sending > :not(.pk-v-sendfx) { visibility: hidden; }   /* the card keeps its height; the scene takes its place */
.pk-v-sendfx { position: absolute; z-index: 1; inset: 0; display: flex; align-items: center; justify-content: center; gap: var(--space-8); border-radius: inherit; background: var(--color-surface); pointer-events: none; overflow: hidden; }
.pk-v-fx__box { position: relative; display: block; width: calc(132px * var(--fx-k, 1)); height: calc(140px * var(--fx-k, 1)); }
.pk-v-fx__box > .pk-v-fx__stage { position: absolute; left: 0; top: 0; transform: scale(var(--fx-k, 1)); transform-origin: 0 0; }
.pk-v-fx__group { position: absolute; inset: 0; display: block; }
.pk-v-fx__lane { display: flex; flex-direction: column; align-items: center; gap: var(--space-3); }
.pk-v-fx__stage { position: relative; display: block; width: 132px; height: 140px; perspective: 400px; }
.pk-v-fx__page { position: absolute; left: 34px; bottom: 22px; z-index: 1; display: block; width: 64px; border-radius: 2px; box-shadow: var(--shadow-paper); overflow: hidden; }
.pk-v-fx__page .pk-sheet { box-shadow: none; }

/* Mail: a #10 envelope seen from the back, its flap open; the page slides in and the flap folds shut. */
.pk-v-fx__env { position: absolute; left: 6px; right: 6px; bottom: 6px; height: 64px; border-radius: 3px; background: var(--color-surface-2); box-shadow: var(--shadow-paper); }
.pk-v-fx__flap { position: absolute; z-index: 3; left: 6px; right: 6px; bottom: 70px; height: 36px; background: var(--color-surface-2); clip-path: polygon(0 100%, 50% 6%, 100% 100%); transform-origin: 50% 100%; backface-visibility: visible; }
.pk-v-fx__front { position: absolute; z-index: 2; left: 6px; right: 6px; bottom: 6px; height: 64px; border-radius: 3px; background: var(--color-surface); clip-path: polygon(0 0, 50% 52%, 100% 0, 100% 100%, 0 100%); box-shadow: inset 0 0 0 1px var(--color-hairline-strong); }
.pk-v-fx__seam { position: absolute; inset: 0; border-radius: 3px; box-shadow: inset 0 0 0 1px var(--color-hairline-strong); }
.pk-v-fx__mark { position: absolute; right: var(--space-2); bottom: var(--space-2); font-family: var(--font-display); font-size: var(--text-caption); line-height: 1; color: var(--color-ink-3); }

/* Fax: a desk machine with a paper guide; the page feeds into its slot while the light blinks. */
.pk-v-fx__tray { position: absolute; left: 30px; right: 30px; bottom: 50px; height: 40px; border-radius: 4px 4px 0 0; background: var(--color-surface-2); box-shadow: inset 0 0 0 1px var(--color-hairline-strong); transform: perspective(200px) rotateX(28deg); transform-origin: 50% 100%; }
.pk-v-fx__feed { position: absolute; left: 0; right: 0; top: 0; bottom: 52px; overflow: hidden; }
.pk-v-fx__feed .pk-v-fx__page { bottom: auto; top: 18px; }
.pk-v-fx__machine { position: absolute; z-index: 2; left: 8px; right: 8px; bottom: 6px; height: 52px; border-radius: var(--radius-md) var(--radius-md) var(--radius-sm) var(--radius-sm); background: var(--color-surface); box-shadow: var(--shadow-2), inset 0 0 0 1px var(--color-hairline-strong); }
.pk-v-fx__slot { position: absolute; left: 22px; right: 22px; top: 6px; height: 3px; border-radius: var(--radius-full); background: var(--color-ink-2); }
.pk-v-fx__lcd { position: absolute; left: 10px; bottom: 10px; width: 30px; height: 12px; padding: 4px 5px; border-radius: 3px; background: var(--color-brand-tint); }
.pk-v-fx__lcd::after { content: ""; display: block; width: 60%; height: 4px; border-radius: var(--radius-full); background: var(--color-brand-mark); }
.pk-v-fx__keys { position: absolute; right: 22px; bottom: 9px; display: grid; grid-template-columns: repeat(3, 5px); gap: 3px; }
.pk-v-fx__keys i { display: block; width: 5px; height: 5px; border-radius: var(--radius-full); background: var(--color-hairline-strong); }
.pk-v-fx__light { position: absolute; right: 9px; bottom: 11px; width: 6px; height: 6px; border-radius: var(--radius-full); background: var(--color-success); }

/* Email: a small mail window; the PDF attachment lifts off and goes; "Sent". */
.pk-v-fx__mail { position: absolute; left: 6px; right: 6px; bottom: 6px; height: 92px; padding: var(--space-3); border-radius: var(--radius-md); background: var(--color-surface); box-shadow: var(--shadow-2); }
.pk-v-fx__bar { display: block; width: 70%; height: 5px; margin-bottom: 6px; border-radius: var(--radius-full); background: var(--color-ink-4); }
.pk-v-fx__bar--short { width: 45%; background: var(--color-hairline-strong); }
.pk-v-fx__bar--line { width: 88%; height: 3px; background: var(--color-hairline); }
.pk-v-fx__chip { position: absolute; z-index: 2; left: 14px; bottom: 14px; display: inline-flex; max-width: 104px; align-items: center; gap: 6px; padding: 4px 8px 4px 4px; border-radius: var(--radius-sm); background: var(--color-surface-2); box-shadow: var(--shadow-1), inset 0 0 0 1px var(--color-hairline); }
.pk-v-fx__thumb { display: block; flex: none; width: 22px; overflow: hidden; border-radius: 1px; }
.pk-v-fx__thumb .pk-sheet { box-shadow: none; }
.pk-v-fx__file { display: flex; min-width: 0; flex-direction: column; font-size: var(--text-caption); line-height: 14px; }
.pk-v-fx__file b { font-weight: var(--weight-medium); }
.pk-v-fx__file span { overflow: hidden; color: var(--color-ink-3); text-overflow: ellipsis; white-space: nowrap; }
.pk-v-fx__sent { position: absolute; z-index: 3; right: 12px; bottom: 16px; display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: var(--radius-full); background: var(--color-success-tint); color: var(--color-success); font-size: var(--text-caption); line-height: 16px; font-weight: var(--weight-medium); }
.pk-v-center > .pk-v-sendfx { align-items: flex-start; padding-top: var(--space-16); }   /* the studio's tall column: the scene sits at its top, in view */
.pk-v-center > .pk-v-sendfx--col { padding-top: var(--space-8); }
.pk-v-sendfx--col { flex-direction: column; gap: var(--space-4); }
.pk-v-sendfx--col .pk-v-fx__lane { flex-direction: row; gap: var(--space-4); }

/* The studio's compact head: back · phase · plan step on one line (the page is the hero). */
.pk-v-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-4); margin-bottom: calc(-1 * var(--space-3)); }
.pk-v-crumbs .pk-v-step { margin: 0; }
.pk-v-side { display: flex; flex-direction: column; gap: var(--space-4); }
.pk-v-sample { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }

/* At 390 the preview's four choices fit without clipping: words only. */
@media (max-width: 479px) {
  .pk-v-preview .k-tabs__item .k-icon { display: none; }
  .pk-v-preview .k-tabs { max-width: 100%; }
}

/* At 390 the studio's head stays to two short lines, so the page is in the first viewport. */
@media (max-width: 767px) {
  .pk-v-crumbs { flex-wrap: nowrap; gap: var(--space-3); }
  .pk-v-crumbs .pk-v-step { min-width: 0; flex-wrap: nowrap; }
  .pk-v-crumbs .pk-v-step > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .pk-v-crumbs .pk-v-step > .k-icon, .pk-v-crumbs .pk-v-step > .k-btn { display: none; }
  .pk-v-tools__hint, .pk-v-who { display: none; }
  .pk-v-preview { gap: var(--space-3); }
}
.pk-v-sentline { color: var(--color-ink-2); font-size: var(--text-meta); line-height: var(--leading-meta); }

/* What sending costs, billed at cost (P18.7): prices under the channel choice, then the batch total */
.pk-v-cost { display: flex; flex-direction: column; gap: var(--space-1); padding-top: var(--space-4); box-shadow: 0 -1px 0 var(--color-hairline); }
.pk-v-week__text .pk-v-cost { padding-top: 0; box-shadow: none; }
.pk-v-cost__prices { font-size: var(--text-meta); line-height: var(--leading-meta); color: var(--color-ink-3); }
.pk-v-cost__dot { color: var(--color-ink-3); }
/* the studio's cost block lays its lines in the card itself, so the total can stick to the card's foot */
.pk-v-cost--own { display: contents; }
.pk-v-cost--own > .pk-v-cost__prices { padding-top: var(--space-4); box-shadow: 0 -1px 0 var(--color-hairline); }
/* the studio's total stays in view at the foot of Who gets it while its channels change (round 04) */
.pk-v-cost--pin { position: sticky; bottom: 0; z-index: 1; box-shadow: 0 -1px 0 var(--color-hairline); margin: 0 calc(-1 * var(--space-6)) calc(-1 * var(--space-6)); padding: var(--space-4) var(--space-6); border-radius: 0 0 var(--radius-xl) var(--radius-xl); background: var(--color-surface); }
@media (max-width: 767px) { .pk-v-cost--pin { bottom: var(--tabbar); margin: 0 calc(-1 * var(--space-5)) calc(-1 * var(--space-5)); padding: var(--space-4) var(--space-5); border-radius: 0 0 var(--radius-lg) var(--radius-lg); } }
.pk-v-cost__total { font-size: var(--text-body); line-height: var(--leading-body); font-weight: var(--weight-medium); color: var(--color-ink); }
