/* Pack 08 components: schedule calendar, encounter line editor, daily entry grid,
   Part of picker, program progress, sticky action bar. Tokens only.
   Breakpoints: 1279, 1023, 767 (R5). */

/* ---------- Part of picker (R4 S01, S02) ---------- */
.p8-po { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 4px 10px 4px 8px; border-radius: var(--r-pill);
      border: 1px solid color-mix(in srgb, var(--c, var(--m-general)) 35%, #fff); background: color-mix(in srgb, var(--c, var(--m-general)) 9%, #fff);
      color: var(--ci, var(--text-2)); font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.p8-po i { width: 7px; height: 7px; border-radius: 50%; background: var(--c, var(--m-general)); flex-shrink: 0; }
.p8-po .icon { color: var(--muted); }
.p8-po.own { --c: var(--m-general); --ci: var(--text-2); background: #fff; border-style: dashed; }
.p8-po small { font-weight: 500; color: var(--muted); }
@media (max-width: 1023px) { .p8-po { min-height: var(--tap); } }

/* ---------- Encounter line editor ---------- */
.p8-le { display: grid; gap: 0; border: 1px solid var(--border); border-radius: var(--r-card); overflow: hidden; background: var(--surface); }
.p8-le-h, .p8-le-row { display: grid; grid-template-columns: minmax(150px, 1.7fr) minmax(140px, 1.5fr) 72px 60px minmax(120px, 1.1fr) minmax(170px, 1.7fr) 40px; gap: 10px; align-items: center; padding: 10px 14px; }
.p8-le-h { background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: 11px; letter-spacing: .5px; text-transform: uppercase; color: var(--muted-2); font-weight: 600; }
.p8-le-row { border-bottom: 1px solid var(--line); }
.p8-le-row:last-child { border-bottom: 0; }
.p8-le-row .input, .p8-le-row .select { min-height: 36px; padding: 6px 10px; font-size: 13px; }
.p8-le-row .lbl { display: none; font-size: 11px; color: var(--muted-2); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.p8-le-row .cell { display: grid; gap: 3px; min-width: 0; }
.p8-le-row .val { font-weight: 700; font-variant-numeric: tabular-nums; }
.p8-le-row .note { font-size: 12px; color: var(--muted); }
.p8-le-row.warn { background: var(--warn-tint); }
.p8-le-row.bad { background: var(--bad-tint); }
.p8-le-f { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px; background: var(--surface-2); border-top: 1px solid var(--border); flex-wrap: wrap; }
.p8-le { container-type: inline-size; }
@container (max-width: 1000px) {
  .p8-le-h { display: none; }
  .p8-le-row { grid-template-columns: repeat(6, minmax(0, 1fr)); row-gap: 10px; }
  .p8-le-row .lbl { display: block; }
  .p8-le-row .c-svc { grid-column: span 3; } .p8-le-row .c-by { grid-column: span 3; }
  .p8-le-row .c-min, .p8-le-row .c-units { grid-column: span 1; } .p8-le-row .c-val { grid-column: span 2; } .p8-le-row .c-po { grid-column: span 2; }
  .p8-le-row .c-x { grid-column: span 6; justify-self: end; }
}
@container (max-width: 560px) {
  .p8-le-row { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 12px; }
  .p8-le-row .c-svc, .p8-le-row .c-by, .p8-le-row .c-val, .p8-le-row .c-po { grid-column: span 2; }
  .p8-le-row .c-min, .p8-le-row .c-units { grid-column: span 1; }
  .p8-le-row .c-x { grid-column: span 2; justify-self: stretch; }
}
@media (max-width: 767px) { .p8-le-row .input, .p8-le-row .select { min-height: var(--tap); font-size: 16px; } }

/* ---------- Two-column form with summary rail ---------- */
.p8-with-rail { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--s4); align-items: start; }
.p8-with-rail > * { min-width: 0; }
.p8-rail { position: sticky; top: calc(var(--topbar-h) + 16px); display: grid; gap: var(--s4); }
@media (max-width: 1279px) { .p8-with-rail { grid-template-columns: minmax(0, 1fr); } .p8-rail { position: static; } }

/* ---------- Sticky action bar (forms, phone flows) ---------- */
.p8-actbar { position: sticky; bottom: 0; z-index: 15; display: flex; gap: 8px; justify-content: flex-end; align-items: center; flex-wrap: wrap;
          padding: 12px 16px; margin-top: var(--s4); background: rgba(255,255,255,.96); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow-card); }
.p8-actbar .grow { font-size: 13px; color: var(--muted); }
@media (max-width: 767px) {
  .p8-actbar { bottom: calc(var(--bottombar-h) + env(safe-area-inset-bottom)); border-radius: 0; margin-left: calc(-1 * var(--s4)); margin-right: calc(-1 * var(--s4)); padding-bottom: 12px; }
  .p8-actbar .btn { flex: 1 1 auto; }
  .p8-actbar .grow { flex-basis: 100%; }
}

/* ---------- Patient strip (selected patient in forms) ---------- */
.p8-pstrip { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--primary-tint-2); background: var(--primary-tint); border-radius: var(--r-card); flex-wrap: wrap; }
.p8-pstrip .t { min-width: 0; flex: 1 1 200px; }
.p8-pstrip strong { display: block; font-size: 15px; }
.p8-pstrip small { display: block; color: var(--muted); font-size: 12.5px; }

/* ---------- Progress (credits, program pace) ---------- */
.p8-prog { display: grid; gap: 5px; min-width: 120px; }
.p8-prog .bar { height: 7px; }
.p8-prog .t { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.p8-prog .t b { color: var(--text); font-variant-numeric: tabular-nums; }
.p8-plan-row { display: grid; grid-template-columns: minmax(140px, 1.4fr) minmax(120px, 2fr) 90px 90px; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.p8-plan-row:last-child { border-bottom: 0; }
.p8-plan-row .num { text-align: right; }
@media (max-width: 767px) { .p8-plan-row { grid-template-columns: 1fr auto; } .p8-plan-row .bar-c { grid-column: 1 / -1; order: 3; } .p8-plan-row .n2 { display: none; } }

/* ---------- Schedule calendar (day by provider, room or chair) ---------- */
.p8-cal-tools { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; margin-bottom: var(--s4); }
.p8-cal-tools .day { font-weight: 700; font-size: 15px; padding: 0 6px; white-space: nowrap; }
.p8-cal-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-card); background: var(--surface); box-shadow: var(--shadow-card); }
.p8-cal { display: grid; grid-template-columns: 62px var(--cols); min-width: var(--minw, 100%); }
.p8-cal-hd { position: sticky; top: 0; z-index: 3; background: var(--surface-2); border-bottom: 1px solid var(--border); padding: 10px 10px; display: flex; align-items: center; gap: 8px; min-width: 0; border-left: 1px solid var(--line); }
.p8-cal-hd:first-child { border-left: 0; }
.p8-cal-hd .t { min-width: 0; }
.p8-cal-hd { align-items: flex-start; }
.p8-cal-hd strong { display: block; font-size: 13px; line-height: 1.3; }
.p8-cal-hd small { display: block; font-size: 11.5px; color: var(--muted); line-height: 1.3; }
.p8-cal-axis { position: relative; height: var(--h); }
.p8-cal-axis span { position: absolute; right: 8px; font-size: 11px; color: var(--muted); transform: translateY(-7px); white-space: nowrap; }
.p8-cal-col { position: relative; height: var(--h); border-left: 1px solid var(--line);
           background-image: repeating-linear-gradient(to bottom, var(--line) 0, var(--line) 1px, transparent 1px, transparent var(--hour)); }
.p8-cal-off { position: absolute; left: 0; right: 0; background: repeating-linear-gradient(135deg, var(--surface-sunk) 0, var(--surface-sunk) 6px, #fff 6px, #fff 12px); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.p8-cal-off span { position: absolute; left: 8px; top: 4px; font-size: 11px; color: var(--muted); white-space: nowrap; }
.p8-cal-now { position: absolute; left: 0; right: 0; height: 0; border-top: 2px solid var(--bad); z-index: 2; pointer-events: none; }
.p8-cal-now::before { content: ""; position: absolute; left: -4px; top: -5px; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }
.p8-cal-ev { position: absolute; z-index: 1; display: grid; align-content: start; gap: 1px; padding: 3px 6px 3px 8px; border-radius: 6px; overflow: hidden;
          background: color-mix(in srgb, var(--c) 12%, #fff); border: 1px solid color-mix(in srgb, var(--c) 30%, #fff); border-left: 3px solid var(--c); color: var(--text); font-size: 11.5px; line-height: 1.3; }
.p8-cal-ev:hover { box-shadow: 0 0 0 2px var(--primary-tint-2); z-index: 4; }
.p8-cal-ev b, .p8-cal-ev span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.p8-cal-ev b { font-weight: 600; font-size: 12px; }
.p8-cal-ev span { color: var(--text-2); }
.p8-cal-ev.short { padding-top: 1px; padding-bottom: 1px; align-content: center; }
.p8-cal-ev.in { background: color-mix(in srgb, var(--c) 24%, #fff); }
.p8-cal-ev.conf { border-color: var(--bad); border-left-color: var(--bad); box-shadow: 0 0 0 1px var(--bad-line); }
.p8-cal-ev.done { opacity: .62; }
.p8-cal-ev.ghost { background: #fff; border-style: dashed; }
.p8-cal-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: var(--s3); }
.p8-cal-legend span { display: inline-flex; gap: 6px; align-items: center; }
.p8-cal-legend i { width: 12px; height: 12px; border-radius: 3px; background: var(--c); }

/* phone agenda (replaces the grid under 768) */
.p8-agenda { display: none; }
.p8-agenda .grp { padding: 10px 14px 6px; font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--muted-2); background: var(--surface-2); border-bottom: 1px solid var(--line); }
.p8-ag { display: grid; grid-template-columns: 64px 1fr auto; gap: 10px; align-items: start; padding: 11px 14px; border-bottom: 1px solid var(--line); min-height: var(--tap); }
.p8-ag .tm { font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.p8-ag .tm small { display: block; font-weight: 400; color: var(--muted); }
.p8-ag .t strong { display: block; font-size: 14px; }
.p8-ag .t small { display: block; font-size: 12.5px; color: var(--muted); }
.p8-ag .bar-c { width: 4px; align-self: stretch; border-radius: 2px; background: var(--c); }
@media (max-width: 767px) {
  .p8-cal-wrap.day { display: none; }
  .p8-agenda { display: block; }
}

/* week view (declared sideways scroll area, R5 V02) */
.p8-wk { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 860px; }
.p8-wk th { font-size: 11px; letter-spacing: .5px; text-transform: uppercase; color: var(--muted-2); text-align: left; font-weight: 600; padding: 10px 12px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.p8-wk td { padding: 10px 12px; border-bottom: 1px solid var(--line); border-left: 1px solid var(--line); vertical-align: top; }
.p8-wk td:first-child { border-left: 0; position: sticky; left: 0; background: var(--surface); z-index: 1; min-width: 190px; }
.p8-wk .cell { display: grid; gap: 4px; }
.p8-wk .cell .n { font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
.p8-wk .cell small { color: var(--muted); font-size: 12px; }
.p8-wk .off { background: repeating-linear-gradient(135deg, var(--surface-sunk) 0, var(--surface-sunk) 6px, #fff 6px, #fff 12px); color: var(--muted); }

/* ---------- Daily entry grid (declared sideways scroll area, R5 V02) ---------- */
.p8-dg-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-card); background: var(--surface); box-shadow: var(--shadow-card); }
.p8-dg { width: 100%; min-width: 1120px; border-collapse: collapse; font-size: 12.5px; }
.p8-dg th { position: sticky; top: 0; z-index: 2; font-size: 10.5px; letter-spacing: .5px; text-transform: uppercase; color: var(--muted-2); text-align: left; font-weight: 600; padding: 9px 8px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.p8-dg td { padding: 4px 6px; border-bottom: 1px solid var(--line); border-left: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.p8-dg td:first-child, .p8-dg th:first-child { border-left: 0; position: sticky; left: 0; z-index: 1; background: var(--surface); }
.p8-dg th:first-child { z-index: 3; background: var(--surface-2); }
.p8-dg .p8-gc { display: block; min-height: 30px; padding: 5px 7px; border: 1px solid transparent; border-radius: 6px; line-height: 1.5; }
.p8-dg .p8-gc.ed { border-color: var(--border); background: #fff; }
.p8-dg .p8-gc.err { border-color: var(--bad); background: var(--bad-tint); }
.p8-dg .p8-gc.focus { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-tint-2); }
.p8-dg .p8-gc.ph { color: var(--muted-2); }
.p8-dg tr.first td { border-top: 2px solid var(--border); }
.p8-dg tr.cont td.pcell { color: var(--muted-2); }
.p8-dg tr.skip td { background: var(--surface-2); color: var(--muted); }
.p8-dg tr.warnrow td { background: #FFFBF3; }
.p8-dg tr.badrow td { background: #FFF7F9; }
.p8-dg .rownum { color: var(--muted-2); font-variant-numeric: tabular-nums; text-align: right; width: 34px; }
.p8-dg-sum { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* phone one-at-a-time card */
.p8-one { max-width: 640px; margin: 0 auto; }
.p8-one-progress { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: var(--s3); font-size: 13px; color: var(--muted); }
.p8-lcard { border: 1px solid var(--border); border-radius: var(--r-card); padding: 12px; display: grid; gap: 10px; background: var(--surface); }
.p8-lcard .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- small helpers ---------- */
.p8-mono { font-variant-numeric: tabular-nums; }
.p8-sep-v { width: 1px; align-self: stretch; background: var(--line); }
.p8-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; border: 1px solid var(--border); border-radius: var(--r-card); background: var(--surface); box-shadow: var(--shadow-card); }
.p8-facts > div { padding: 12px 16px; border-left: 1px solid var(--line); min-width: 0; }
.p8-facts > div:first-child { border-left: 0; }
.p8-facts .k { font-size: 11.5px; color: var(--muted); }
.p8-facts .v { font-size: 14px; font-weight: 600; margin-top: 2px; overflow-wrap: anywhere; }
@media (max-width: 1023px) { .p8-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); } .p8-facts > div:nth-child(3) { border-left: 0; } .p8-facts > div:nth-child(n+3) { border-top: 1px solid var(--line); } }
@media (max-width: 380px) { .p8-facts { grid-template-columns: 1fr; } .p8-facts > div { border-left: 0; border-top: 1px solid var(--line); } .p8-facts > div:first-child { border-top: 0; } }
.p8-choice { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r-card); background: #fff; }
.p8-choice.on { border-color: var(--primary); background: var(--primary-tint); box-shadow: 0 0 0 1px var(--primary); }
.p8-choice .t { flex: 1; min-width: 0; }
.p8-choice strong { display: block; }
.p8-choice small { display: block; color: var(--muted); font-size: 12.5px; }
@media (max-width: 1023px) { .p8-choice { min-height: var(--tap); } }
.p8-slots { display: flex; flex-wrap: wrap; gap: 8px; }
.p8-slot { display: inline-flex; align-items: center; justify-content: center; min-width: 84px; min-height: 36px; padding: 6px 10px; border: 1px solid var(--border-strong); border-radius: var(--r); background: #fff; font-size: 13px; font-weight: 600; }
.p8-slot.on { border-color: var(--primary); background: var(--primary); color: #fff; }
@media (max-width: 1023px) { .p8-slot { min-height: var(--tap); } }
.p8-hours { display: grid; gap: 0; }
.p8-hrow { display: grid; grid-template-columns: 110px minmax(0, 1fr) minmax(0, 1fr) 110px; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.p8-hrow:last-child { border-bottom: 0; }
@media (max-width: 767px) { .p8-hrow { grid-template-columns: 1fr 1fr; } .p8-hrow .d { grid-column: 1 / -1; font-weight: 700; } }

/* daily entry: desktop grid vs phone one-at-a-time (R5 V11) */
.p8-dg-phone { display: none; }
@media (max-width: 767px) { .p8-dg-desk { display: none; } .p8-dg-phone { display: block; } }

.p8-top { align-items: start; }

/* side columns in pack 08 record pages take the full width once the grid stacks */
@media (max-width: 1279px) { .grid > .p8-side { grid-column: span 12; } }
