:root{
  --piweb-bg: #f6f7fb;
  --piweb-card: #ffffff;
  --piweb-border: rgba(15, 23, 42, 0.08);
  --piweb-shadow: 0 10px 25px rgba(15, 23, 42, 0.06);
  --piweb-radius: 18px;

  --piweb-accent: #f8894f;     /* AMERO orange (primary) */
  --piweb-accent-2: #20c997;   /* mint — success / secondary */
  --piweb-warn: #ffcc66;       /* pastel amber — warnings */
}

.piweb-bg{
  background: radial-gradient(1200px 600px at 20% 0%, rgba(248,137,79,.12), transparent 60%),
              radial-gradient(900px 600px at 80% 20%, rgba(11,18,18,.06), transparent 55%),
              var(--piweb-bg);
}

.piweb-card{
  background: var(--piweb-card);
  border: 1px solid var(--piweb-border);
  border-radius: var(--piweb-radius);
  box-shadow: var(--piweb-shadow);
}

.piweb-divider{
  height: 1px;
  background: rgba(15, 23, 42, 0.08);
}

.piweb-nav{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255,255,255,0.65);
  border: 1px solid rgba(15,23,42,0.06);
  position: relative;
  transition: background 80ms ease;
}

.piweb-nav:hover{
  background: rgba(255,255,255,0.95);
}

.piweb-nav.is-active{
  background: linear-gradient(90deg, rgba(248,137,79,0.18), rgba(248,137,79,0.06));
  border-color: rgba(248,137,79,0.30);
  font-weight: 600;
  color: rgb(124, 53, 20);
}

.piweb-nav.is-active::before{
  content: "";
  position: absolute;
  left: -1px;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 0 4px 4px 0;
  background: rgba(248,137,79,0.85);
}

.piweb-pill{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(15,23,42,0.10);
  background: rgba(248,137,79,0.08);
  font-size: 12px;
}

.piweb-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(15,23,42,0.10);
  background: rgba(248,137,79,0.14);
}

.piweb-btn:hover{ background: rgba(248,137,79,0.20); }

/* Solid brand CTA — for the single primary action on a screen. */
.piweb-btn-primary{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding: 10px 16px;
  border-radius: 14px;
  border: 0;
  background: linear-gradient(135deg, #f8894f, #ef7338);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 8px 18px rgba(248,137,79,0.30);
  transition: box-shadow .2s ease, transform .08s ease;
}
.piweb-btn-primary:hover{ box-shadow: 0 12px 26px rgba(248,137,79,0.45); }
.piweb-btn-primary:active{ transform: translateY(1px); }

.piweb-btn-secondary{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(15,23,42,0.10);
  background: rgba(255,255,255,0.75);
}

.piweb-btn-secondary:hover{ background: rgba(255,255,255,0.95); }

.piweb-input{
  width: 100%;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(15,23,42,0.10);
  background: rgba(255,255,255,0.9);
  outline: none;
}

.piweb-input:focus{
  box-shadow: 0 0 0 4px rgba(248,137,79,0.15);
  border-color: rgba(248,137,79,0.35);
}

.piweb-link{
  text-decoration: underline;
  text-underline-offset: 3px;
}

.piweb-alert{
  border-radius: 16px;
  border: 1px solid rgba(255, 204, 102, 0.55);
  background: rgba(255, 204, 102, 0.22);
  padding: 12px 14px;
}

/* Desktop stat tile. Padding + value-size dialed in so a 5-up row
   shows the numbers without each tile feeling like a poster. Touch-
   first stat blocks live in the operator/maintenance panels and
   intentionally keep their own larger sizing inline. */
.piweb-stat{
  border-radius: 14px;
  border: 1px solid rgba(15,23,42,0.08);
  background: rgba(255,255,255,0.75);
  padding: 10px 12px;
  box-shadow: var(--piweb-shadow);
}

.piweb-stat-label{
  font-size: 11px;
  color: rgba(15,23,42,0.55);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.piweb-stat-value{
  margin-top: 2px;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.15;
}

.piweb-panel{
  border-radius: 14px;
  border: 1px solid rgba(15,23,42,0.08);
  background: rgba(255,255,255,0.65);
  padding: 12px;
}

/* Lightweight table styling (used on dashboard + simple lists) */
.piweb-table{
  border-collapse: separate;
  border-spacing: 0;
}

.piweb-table thead th{
  font-size: 12px;
  color: rgba(15,23,42,0.60);
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 10px 10px;
  border-bottom: 1px solid rgba(15,23,42,0.10);
}

.piweb-table tbody td{
  padding: 10px 10px;
  border-bottom: 1px solid rgba(15,23,42,0.06);
  vertical-align: middle;
}

.piweb-table tbody tr:hover td{
  background: rgba(255,255,255,0.85);
}

/* ------------------------------
   Table entry ergonomics

   When users type long part numbers/descriptions in line-entry tables (SO Lines,
   Shipment Lines, Routing tables), narrow cells make it hard to see what they
   are typing. These classes give us predictable widths without relying on
   Tailwind arbitrary-value generation.
   ------------------------------ */

.piweb-table-wide{
  min-width: 1400px;
}

.piweb-input-narrow{
  min-width: 7rem;
}

.piweb-input-medium{
  min-width: 9rem;
}

.piweb-input-wide{
  min-width: 360px;
}


/* ------------------------------
   Searchable dropdown (typeahead)
   ------------------------------ */

.piweb-dropdown-panel{
  border-radius: 14px;
  border: 1px solid rgba(15,23,42,0.10);
  background: rgba(255,255,255,0.98);
  box-shadow: 0 12px 28px rgba(15,23,42,0.12);
  max-height: 280px;
  overflow: auto;
}

.piweb-dropdown-item{
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(15,23,42,0.06);
  cursor: pointer;
}

.piweb-dropdown-item:hover{
  background: rgba(248,137,79,0.10);
}

.piweb-dropdown-item:last-child{
  border-bottom: 0;
}

.piweb-muted{
  color: rgba(15,23,42,0.55);
  font-size: 12px;
}


/* ------------------------------
   List page toolbar — search + actions row
   ------------------------------ */

.piweb-toolbar{
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.piweb-toolbar .piweb-search{
  position: relative;
  flex: 1;
  min-width: 240px;
  max-width: 480px;
}

.piweb-toolbar .piweb-search input{
  padding-left: 36px;
}

.piweb-toolbar .piweb-search::before{
  content: "🔎";
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.55;
  font-size: 13px;
}


/* ------------------------------
   Sortable column headers
   ------------------------------ */

th[data-sort]{
  user-select: none;
  cursor: pointer;
}

th[data-sort]:hover{
  color: rgba(15,23,42,0.85);
}

th[data-sort-dir]{
  color: rgba(15,23,42,0.85);
}


/* Sticky column headers — apply to a <table>'s parent <div> with
   `data-list-sortable` and the table itself; the <thead> sticks to the
   top of its scroll container so long lists keep their context. */
table[data-list-sortable] > thead{
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  box-shadow: 0 1px 0 rgba(15,23,42,0.08);
}


/* Clickable table rows. Add `data-row-href="/foo/123"` to a <tr> and
   the row becomes a tap target (still keeps any nested links working). */
tr[data-row-href]{
  cursor: pointer;
}
tr[data-row-href]:hover td{
  background: rgba(248,137,79,0.04);
}


/* ------------------------------
   Dashboard stat tiles — clickable variant
   ------------------------------ */

a.piweb-stat{
  display:block;
  text-decoration: none;
  color: inherit;
  transition: transform 80ms ease, box-shadow 120ms ease;
}

a.piweb-stat:hover{
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(15,23,42,0.08);
}

.piweb-stat-accent-violet{ border-left: 4px solid #f8894f; }
.piweb-stat-accent-mint{   border-left: 4px solid #20c997; }
.piweb-stat-accent-amber{  border-left: 4px solid #ffcc66; }
.piweb-stat-accent-rose{   border-left: 4px solid #ff9aa2; }
.piweb-stat-accent-slate{  border-left: 4px solid #94a3b8; }


/* ------------------------------
   Form validation polish
   ------------------------------ */

.piweb-required::after{
  content: " *";
  color: #d04a4a;
  font-weight: 600;
}

.piweb-alert-error{
  border-color: rgba(208, 74, 74, 0.55);
  background: rgba(208, 74, 74, 0.10);
}

.piweb-alert-success{
  border-color: rgba(32, 201, 151, 0.45);
  background: rgba(32, 201, 151, 0.12);
}

.piweb-help{
  font-size: 12px;
  color: rgba(15,23,42,0.55);
  margin-top: 4px;
}


/* ===============================================================
   Touch-first operator console (Galaxy Tab Active 5, 8" rugged)

   Every interactive element below is sized for gloved fingers:
   - Inputs / buttons: 56px+ tall, 18px font
   - WO cards: tall enough to read at arm's length, full-width
   - Quick-qty chips for one-tap entry
   =============================================================== */

.piweb-touch-input{
  width: 100%;
  font-size: 18px;
  padding: 14px 16px;
  min-height: 56px;
  border-radius: 12px;
  border: 1px solid rgba(15,23,42,0.10);
  background: rgba(255,255,255,0.95);
  outline: none;
}

.piweb-touch-input:focus{
  box-shadow: 0 0 0 4px rgba(248,137,79,0.20);
  border-color: rgba(248,137,79,0.50);
}

.piweb-touch-label{
  display: block;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: rgba(15,23,42,0.65);
  margin-bottom: 8px;
}

.piweb-touch-btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  font-size: 20px;
  font-weight: 700;
  padding: 18px 20px;
  min-height: 68px;
  border-radius: 14px;
  border: 1px solid rgba(15,23,42,0.12);
  background: rgba(248,137,79,0.20);
  color: rgb(124, 53, 20);
  letter-spacing: .02em;
}

.piweb-touch-btn:active{
  background: rgba(248,137,79,0.32);
  transform: translateY(1px);
}

.piweb-touch-btn-success{
  background: rgba(32,201,151,0.30);
  color: rgb(20, 90, 70);
  border-color: rgba(32,201,151,0.30);
}

.piweb-touch-btn-success:active{
  background: rgba(32,201,151,0.45);
}

.piweb-wo-card{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  min-height: 84px;
  border-radius: 14px;
  border: 2px solid rgba(15,23,42,0.08);
  background: rgba(255,255,255,0.95);
  cursor: pointer;
  transition: background 80ms ease, border-color 80ms ease;
}

.piweb-wo-card:active{
  background: rgba(248,137,79,0.08);
}

.piweb-wo-card.is-selected{
  background: rgba(248,137,79,0.10);
  border-color: rgba(248,137,79,0.55);
  box-shadow: inset 0 0 0 1px rgba(248,137,79,0.40);
}

.piweb-qty-chip{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  padding: 14px 12px;
  font-size: 18px;
  font-weight: 700;
  border-radius: 12px;
  border: 1px solid rgba(15,23,42,0.10);
  background: rgba(255,255,255,0.95);
  cursor: pointer;
  user-select: none;
}

.piweb-qty-chip:active{
  background: rgba(248,137,79,0.18);
  transform: translateY(1px);
}

/* Big banner shown when a WO is mid-run on this machine. Green = good,
   orange = late, red = blocked. The page picks the color by class. */
.piweb-status-banner{
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 22px;
  border-radius: 16px;
  border-left: 6px solid rgba(32,201,151,0.75);
  background: linear-gradient(90deg, rgba(32,201,151,0.16), rgba(32,201,151,0.04));
  font-size: 20px;
  font-weight: 600;
  color: rgb(20, 80, 60);
}

/* Sticky machine header that stays visible while operator scrolls */
.piweb-machine-header{
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(246,247,251,0.95);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 14px 0;
  margin: -14px 0 8px 0;
  border-bottom: 1px solid rgba(15,23,42,0.06);
}


/* ───────────────────────────────────────────────────────────────
   Numbered step cards — for the linear operator flow.

   .piweb-step               wraps each step (machine, WO, coil, etc.)
   .piweb-step-num           round badge with the step number
   .piweb-step-num.is-done   badge turns green once the step is filled
   .piweb-step.is-locked     step is greyed out (waiting on prior step)
   ─────────────────────────────────────────────────────────────── */

.piweb-step{
  display: flex;
  gap: 16px;
  padding: 18px 18px 20px;
  border-radius: 16px;
  background: rgba(255,255,255,0.92);
  border: 1px solid rgba(15,23,42,0.06);
  box-shadow: var(--piweb-shadow);
  transition: opacity 120ms ease;
}

.piweb-step.is-locked{
  opacity: 0.45;
  pointer-events: none;
}

.piweb-step.is-done{
  border-color: rgba(32,201,151,0.30);
}

.piweb-step-body{
  flex: 1;
  min-width: 0;
}

.piweb-step-title{
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 12px;
  color: rgba(15,23,42,0.85);
  line-height: 1.2;
}

.piweb-step-num{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(248,137,79,0.15);
  color: rgb(124, 53, 20);
  font-size: 20px;
  font-weight: 800;
  flex-shrink: 0;
}

.piweb-step-num.is-done{
  background: rgba(32,201,151,0.32);
  color: rgb(20, 80, 60);
}

/* Submit button when the form isn't ready yet — visible but muted, so the
   operator can see the goal without being able to fire a partial post. */
.piweb-touch-btn[disabled]{
  opacity: 0.45;
  cursor: not-allowed;
}
.piweb-touch-btn[disabled]:active{
  transform: none;
}


/* ───────────────────────────────────────────────────────────────
   Loading indicators

   1. Top-of-viewport progress bar that animates while ANY HTMX
      request is in flight. Lives in base.html and is toggled by
      htmx:beforeRequest / htmx:afterRequest event handlers.

   2. A standard `.piweb-spinner` ring used inside loading overlays
      (the operator panel uses this while the machine panel is being
      fetched on Vercel cold starts).
   ─────────────────────────────────────────────────────────────── */

.piweb-progress{
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 9999;
  pointer-events: none;
  background: transparent;
  opacity: 0;
  transition: opacity 200ms ease;
}

.piweb-progress::before{
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 30%;
  background: linear-gradient(
    90deg,
    rgba(248,137,79,0) 0%,
    rgba(248,137,79,0.85) 50%,
    rgba(32,201,151,0) 100%
  );
  border-radius: 0 3px 3px 0;
  animation: piwebProgressSlide 1.4s ease-in-out infinite;
}

.piweb-progress.is-active{ opacity: 1; }

@keyframes piwebProgressSlide{
  0%   { left: -30%; width: 30%; }
  50%  { left: 35%;  width: 35%; }
  100% { left: 100%; width: 30%; }
}

.piweb-spinner{
  display: inline-block;
  width: 44px;
  height: 44px;
  border: 4px solid rgba(248,137,79,0.20);
  border-top-color: rgba(248,137,79,0.85);
  border-radius: 50%;
  animation: piwebSpin 0.8s linear infinite;
}

@keyframes piwebSpin{
  to { transform: rotate(360deg); }
}

/* Overlay that sits on top of #op-panel while the next machine panel is
   being fetched. Toggled by JS via .is-loading on the wrapper. */
.piweb-panel-overlay{
  position: absolute;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(246, 247, 251, 0.85);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  border-radius: 18px;
}

.is-loading > .piweb-panel-overlay{ display: flex; }


/* ───────────────────────────────────────────────────────────────
   Sidebar — drawer behavior on mobile/tablet, inline on desktop.

   On < lg (1024px) the aside is fixed-position, slid off-screen to
   the left by default, and slides in when `body.piweb-sidebar-open`
   is set. A backdrop appears behind it that closes the drawer on
   tap. On ≥ lg, the aside is its normal static column and the
   close-button + backdrop are hidden.
   ─────────────────────────────────────────────────────────────── */

.piweb-sidebar-close{ display: inline-flex; }

@media (max-width: 1023px) {
  .piweb-sidebar{
    position: fixed;
    inset: 0 auto 0 0;
    width: 18rem;
    max-width: 88vw;
    z-index: 60;
    transform: translateX(-100%);
    transition: transform 200ms ease;
    overflow-y: auto;
    background: rgba(246,247,251,0.98);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 0 60px rgba(15,23,42,0.20);
  }
  body.piweb-sidebar-open .piweb-sidebar{
    transform: translateX(0);
  }
  body.piweb-sidebar-open::after{
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.50);
    z-index: 55;
    cursor: pointer;
  }
  body{ overflow-x: hidden; }
  body.piweb-sidebar-open{ overflow: hidden; }
}

@media (min-width: 1024px) {
  .piweb-sidebar-close{ display: none; }
}


/* ───────────────────────────────────────────────────────────────
   Welcome toast — slides down from the top of the screen after a
   successful sign-in. Auto-closes after a few seconds. Non-modal,
   so it doesn't block any interaction underneath.
   ─────────────────────────────────────────────────────────────── */

.piweb-welcome{
  position: fixed;
  top: 0;
  left: 50%;
  z-index: 95;
  width: min(420px, calc(100% - 32px));
  background: rgba(255,255,255,0.98);
  border: 1px solid rgba(15,23,42,0.06);
  border-radius: 22px;
  box-shadow: 0 24px 60px rgba(15,23,42,0.18), 0 4px 12px rgba(15,23,42,0.06);
  padding: 22px 28px 24px;
  transform: translate(-50%, -120%);
  opacity: 0;
  transition: transform 360ms cubic-bezier(.2,.9,.3,1.15), opacity 220ms ease;
  pointer-events: auto;
  cursor: pointer;
  overflow: hidden;
}

.piweb-welcome::before{
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: linear-gradient(90deg,
    rgba(248,137,79,0.85) 0%,
    rgba(32,201,151,0.85) 100%);
}

.piweb-welcome.is-visible{
  transform: translate(-50%, 24px);
  opacity: 1;
}

.piweb-welcome.is-fading{
  opacity: 0;
  transform: translate(-50%, 8px);
}

.piweb-welcome__eyebrow{
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(15,23,42,0.50);
  margin-bottom: 6px;
}

.piweb-welcome__name{
  font-size: 28px;
  font-weight: 800;
  line-height: 1.1;
  color: rgba(15,23,42,0.92);
  margin-top: 2px;
}

.piweb-welcome__sub{
  margin-top: 4px;
  font-size: 13px;
  color: rgba(15,23,42,0.55);
}

@media (max-width: 640px) {
  .piweb-welcome{ padding: 18px 22px 20px; }
  .piweb-welcome__name{ font-size: 24px; }
}


/* Small confirmation toast for saves / completions. Lives bottom-right
   on desktop, full-width-ish bottom on mobile. Auto-dismisses. */
.piweb-toast{
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px 14px 16px;
  border-radius: 16px;
  background: rgba(255,255,255,0.98);
  border: 1px solid rgba(32,201,151,0.30);
  box-shadow: 0 18px 40px rgba(15,23,42,0.16);
  font-weight: 600;
  color: rgb(20, 90, 70);
  transform: translateY(40px);
  opacity: 0;
  transition: transform 260ms cubic-bezier(.2,.9,.3,1.15), opacity 200ms ease;
  max-width: calc(100% - 48px);
}

.piweb-toast.is-visible{
  transform: translateY(0);
  opacity: 1;
}

.piweb-toast.is-fading{
  opacity: 0;
  transform: translateY(12px);
}

.piweb-toast__icon{
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(32,201,151,0.20);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

/* Error look for the same toast: red, warning sign, never the green tick. */
.piweb-toast.is-error{
  border-color: rgba(225,29,72,0.35);
  color: rgb(159,18,57);
}
.piweb-toast.is-error .piweb-toast__icon{
  background: rgba(225,29,72,0.14);
}

@media (max-width: 640px) {
  .piweb-toast{
    left: 16px;
    right: 16px;
    bottom: 16px;
    justify-content: center;
  }
}


/* ───────────────────────────────────────────────────────────────
   Native <details> collapse used by ui.collapse_section macro

   - Strip the default triangle marker (Webkit/Blink/Firefox) so the
     macro's own ▸ chevron is the only disclosure indicator.
   - Toggle the closed/open status pills off the [open] attribute.
     The macro renders both pills always and lets CSS decide which
     is visible — no JS, no Jinja-side toggling.
   ─────────────────────────────────────────────────────────────── */
details.piweb-collapse > summary::-webkit-details-marker { display: none; }
details.piweb-collapse > summary { list-style: none; }
details.piweb-collapse:not([open]) > summary .piweb-collapse__closed { display: inline-flex; }
details.piweb-collapse[open]       > summary .piweb-collapse__closed { display: none; }
details.piweb-collapse:not([open]) > summary .piweb-collapse__open   { display: none; }
details.piweb-collapse[open]       > summary .piweb-collapse__open   { display: inline-flex; }

/* ───────────────────────────────────────────────────────────────
   Print-labels modal — native <dialog> (partials/label_print_modal.html)

   Used both on a normal page (WO form) and inside an HTMX-swapped
   fragment (operator panel). Kept framework-free so showModal()/close()
   work with no script at swap time. Centering is the browser default for
   an open modal <dialog>; we only supply the shell + backdrop.
   ─────────────────────────────────────────────────────────────── */
dialog.pk-label-modal {
  border: none;
  padding: 0;
  border-radius: 1rem;
  max-width: 28rem;
  width: calc(100% - 2rem);
  background: #fff;
  color: #0f172a;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.35);
  /* Scroll INSIDE the dialog rather than pushing the Print button off a
     tablet screen — 40 packed-per-label rows, or the operator chooser's two
     sections, easily outgrow a landscape viewport. */
  max-height: 88vh;
  overflow-y: auto;
}
dialog.pk-label-modal::backdrop { background: rgba(15, 23, 42, 0.45); }
dialog.pk-label-modal .pk-label-modal-card { padding: 1.35rem 1.5rem; }



/* ───────────────────────────────────────────────────────────────
   Time-clock kiosk (pages/timeclock_kiosk.html)

   Designed to be read from across a shop floor: the clock is the largest
   thing on the wall, and the confirmation card is colour-coded so a person
   already walking away can tell IN from OUT by the flash alone.

   `body.tc-locked` is the kiosk lock — set on the first tap, cleared only by
   an admin password. It hides the app chrome so a badge tap cannot wander
   into the ERP.
   ─────────────────────────────────────────────────────────────── */

body.tc-locked .piweb-sidebar,
body.tc-locked .piweb-topbar,
body.tc-locked nav,
body.tc-locked header { display: none !important; }
body.tc-locked main,
body.tc-locked .piweb-main { padding: 0 !important; margin: 0 !important; max-width: none !important; }
body.tc-locked { overflow: hidden; }

.tc-root {
  position: relative;
  min-height: 78vh;
  display: flex;
  flex-direction: column;
  background: #0B1212;
  color: #F8FAFC;
  border-radius: 1rem;
  overflow: hidden;
  /* Kiosk fills the glass once locked. */
}
body.tc-locked .tc-root {
  position: fixed; inset: 0; min-height: 100vh; border-radius: 0; z-index: 60;
}

/* ── first-touch gate ── */
.tc-start {
  position: absolute; inset: 0; z-index: 40;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .5rem; width: 100%; border: 0; cursor: pointer;
  background: radial-gradient(circle at 50% 40%, #16302f 0%, #0B1212 70%);
  color: #F8FAFC; font: inherit;
}
.tc-start-icon { font-size: 4rem; }
.tc-start-title { font-size: 1.6rem; font-weight: 800; letter-spacing: .01em; }
.tc-start-sub { font-size: .85rem; color: #94A3B8; }

/* ── status strip ── */
.tc-topline {
  display: flex; align-items: center; justify-content: space-between;
  padding: .7rem 1.1rem; font-size: .85rem; color: #94A3B8;
}
.tc-net { display: inline-flex; align-items: center; gap: .5rem; }
.tc-dot { width: .55rem; height: .55rem; border-radius: 999px; display: inline-block; }
.tc-dot-on { background: #34D399; box-shadow: 0 0 10px #34D39988; }
.tc-dot-off { background: #F8894F; box-shadow: 0 0 10px #F8894F88; animation: tc-pulse 1.6s infinite; }
.tc-qbadge {
  background: #F8894F; color: #0B1212; font-weight: 800; font-size: .72rem;
  border-radius: 999px; padding: .05rem .45rem; margin-left: .15rem;
}
.tc-camwrap { display: inline-flex; align-items: center; gap: .35rem; margin-left: .6rem; }
.tc-camdot { width: .55rem; height: .55rem; border-radius: 999px; display: inline-block; }
.tc-camdot-on { background: #60A5FA; box-shadow: 0 0 10px #60A5FA88; }
.tc-camdot-off { background: #64748B; }
/* Parked off-screen rather than display:none: a display:none <video> stops
   decoding frames on some Android builds and the capture returns blank. */
.tc-cam {
  position: fixed; left: -9999px; top: 0;
  width: 2px; height: 2px; opacity: .01; pointer-events: none;
}
.tc-exitbtn {
  background: transparent; border: 1px solid #334155; color: #94A3B8;
  border-radius: .6rem; padding: .25rem .6rem; font-size: 1rem; cursor: pointer;
}

/* ── clock ── */
.tc-main { position: relative; flex: 1; display: flex; align-items: center; justify-content: center; }
.tc-idle {
  text-align: center; padding: 1rem 1.2rem 2rem;
  transition: opacity .25s ease, filter .25s ease;
}
.tc-idle.tc-dim { opacity: .12; filter: blur(3px); }

.tc-clock {
  font-variant-numeric: tabular-nums;
  font-weight: 800; letter-spacing: -.02em; line-height: 1;
  font-size: clamp(4.5rem, 17vw, 12rem);
}
.tc-secs { font-size: .3em; color: #64748B; margin-left: .18em; vertical-align: super; }
.tc-ampm { font-size: .26em; color: #94A3B8; margin-left: .3em; }
.tc-date { color: #94A3B8; font-size: clamp(.95rem, 2.4vw, 1.5rem); margin-top: .35rem; }

/* ── badge prompt ── */
.tc-tap { margin-top: clamp(1rem, 4vh, 2.5rem); }
.tc-badge-ring {
  width: 5.5rem; height: 5.5rem; margin: 0 auto .8rem;
  border-radius: 999px; border: 3px solid #F8894F;
  display: flex; align-items: center; justify-content: center;
  animation: tc-ring 2.4s ease-out infinite;
}
.tc-badge-dot { width: 2rem; height: 2rem; border-radius: 999px; background: #F8894F; }
.tc-tap-text { font-size: clamp(1rem, 2.6vw, 1.5rem); font-weight: 600; }
.tc-nfc { color: #64748B; font-size: .8rem; margin-top: .35rem; }

@keyframes tc-ring {
  0%   { box-shadow: 0 0 0 0 rgba(248,137,79,.55); }
  70%  { box-shadow: 0 0 0 2.2rem rgba(248,137,79,0); }
  100% { box-shadow: 0 0 0 0 rgba(248,137,79,0); }
}
@keyframes tc-pulse { 50% { opacity: .35; } }

/* ── manual fallback ── */
.tc-manual { margin-top: 1.4rem; display: flex; gap: .4rem; justify-content: center; }
.tc-manual-input {
  background: #111C1C; border: 1px solid #334155; color: #E2E8F0;
  border-radius: .6rem; padding: .5rem .8rem; width: min(16rem, 60vw); font-size: .95rem;
}
.tc-manual-btn {
  background: #F8894F; color: #0B1212; font-weight: 700; border: 0;
  border-radius: .6rem; padding: .5rem 1rem; cursor: pointer;
}

/* ── confirmation card ── */
.tc-card {
  position: absolute; inset: 0; z-index: 30;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .25rem; text-align: center;
  opacity: 0; pointer-events: none; transform: scale(.92);
  transition: opacity .18s ease, transform .18s cubic-bezier(.2,1.3,.4,1);
}
.tc-card.tc-show { opacity: 1; pointer-events: auto; transform: scale(1); }
.tc-in    { background: radial-gradient(circle at 50% 40%, #0f3d2e 0%, #0B1212 72%); }
.tc-out   { background: radial-gradient(circle at 50% 40%, #3a2a12 0%, #0B1212 72%); }
.tc-offline { background: radial-gradient(circle at 50% 40%, #1e2a3a 0%, #0B1212 72%); }
.tc-error { background: radial-gradient(circle at 50% 40%, #401717 0%, #0B1212 72%); }

.tc-card-icon {
  font-size: clamp(3.5rem, 12vw, 7rem); line-height: 1;
  animation: tc-pop .45s cubic-bezier(.2,1.5,.4,1);
}
.tc-in .tc-card-icon { color: #34D399; }
.tc-out .tc-card-icon { color: #F8894F; }
.tc-card-what { font-size: clamp(1.4rem, 4.5vw, 2.6rem); font-weight: 800; letter-spacing: .02em; }
.tc-card-name {
  font-size: clamp(1.8rem, 6.5vw, 4rem); font-weight: 800; text-transform: capitalize;
  margin-top: .1rem;
}
.tc-card-time { font-size: clamp(1.1rem, 3.2vw, 2rem); color: #E2E8F0; font-variant-numeric: tabular-nums; }
.tc-card-meta { color: #94A3B8; font-size: clamp(.85rem, 2vw, 1.05rem); margin-top: .35rem; }

@keyframes tc-pop {
  0%   { transform: scale(.3) rotate(-12deg); opacity: 0; }
  60%  { transform: scale(1.15) rotate(3deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); }
}

/* ── who's on the clock ── */
.tc-onclock { padding: .6rem 1.1rem 1rem; border-top: 1px solid #1E293B; }
.tc-onclock-h { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #64748B; margin-bottom: .35rem; }
.tc-onclock-list { display: flex; flex-wrap: wrap; gap: .35rem; }
.tc-chip {
  background: #0f3d2e; color: #A7F3D0; border: 1px solid #14532d;
  border-radius: 999px; padding: .12rem .6rem; font-size: .8rem; font-weight: 600;
}

/* ── PIN pad + exit panel ── */
.tc-pin, .tc-exitpanel {
  position: absolute; inset: 0; z-index: 50;
  display: none; align-items: center; justify-content: center;
  background: rgba(11,18,18,.92);
}
.tc-pin.tc-show, .tc-exitpanel.tc-show { display: flex; }

.tc-pin-card, .tc-exitcard {
  background: #111C1C; border: 1px solid #334155; border-radius: 1rem;
  padding: 1.2rem 1.3rem; width: min(20rem, 92vw); text-align: center;
}
.tc-pin-title, .tc-exit-title { font-weight: 800; font-size: 1.1rem; }
.tc-pin-name { color: #94A3B8; margin-bottom: .3rem; text-transform: capitalize; }
.tc-pin-dots { font-size: 1.6rem; letter-spacing: .3rem; min-height: 2rem; color: #F8894F; }
.tc-pin-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .45rem; margin: .6rem 0; }
.tc-pin-key {
  background: #0B1212; border: 1px solid #334155; color: #E2E8F0;
  border-radius: .7rem; padding: .9rem 0; font-size: 1.3rem; font-weight: 700; cursor: pointer;
}
.tc-pin-key:active { background: #1E293B; }
.tc-pin-ok { background: #14532d; border-color: #14532d; color: #A7F3D0; }
.tc-pin-alt { color: #94A3B8; }
.tc-pin-cancel { background: transparent; border: 0; color: #94A3B8; cursor: pointer; padding: .3rem; }

.tc-exit-sub { color: #94A3B8; font-size: .85rem; margin: .2rem 0 .7rem; }
.tc-exit-input {
  display: block; width: 100%; margin-bottom: .5rem;
  background: #0B1212; border: 1px solid #334155; color: #E2E8F0;
  border-radius: .6rem; padding: .6rem .8rem; font-size: 1rem;
}
.tc-exit-err { color: #FCA5A5; font-size: .85rem; min-height: 1.1rem; }
.tc-exit-go {
  width: 100%; background: #F8894F; color: #0B1212; font-weight: 800;
  border: 0; border-radius: .6rem; padding: .65rem; font-size: 1rem; cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  .tc-badge-ring, .tc-card-icon, .tc-dot-off { animation: none; }
  .tc-card { transition: opacity .12s ease; }
}

/* Arm-this-tablet block inside the kiosk exit panel. */
.tc-arm { margin-top: .9rem; padding-top: .8rem; border-top: 1px solid #334155; }
.tc-arm-state { font-size: .8rem; color: #94A3B8; margin-bottom: .45rem; }
.tc-arm-go {
  width: 100%; background: transparent; border: 1px solid #F8894F; color: #F8894F;
  font-weight: 700; border-radius: .6rem; padding: .55rem; cursor: pointer;
}
.tc-arm-hint { font-size: .7rem; color: #64748B; margin-top: .35rem; }

/* ───────────────────────────────────────────────────────────────
   Floating next-step chip — reserve room for it.

   `.piweb-next-step` is position:fixed at the bottom-right, so it takes
   no layout space and permanently occludes that corner of whatever is
   underneath. On a page whose own controls sit bottom-right (the
   shipper's photo Upload button, for one) the chip lands squarely on
   top of them and there is no scroll position that clears it, because
   the page simply ends there.

   Padding the page bottom when the chip is present gives the last card
   somewhere to scroll to. `:has()` keeps it targeted — pages without a
   chip get no extra whitespace. Unsupported engines just behave as they
   did before; this is a nicety, not a dependency.
   ─────────────────────────────────────────────────────────────── */
body:has(.piweb-next-step) main{
  padding-bottom: 7rem;
}
