/*
 * The packing bench, wearing the Health Hue app shell.
 *
 * This is an APP that opens in the Hub panel — the third of the house shape
 * after consent-forms and health-hue-inventory — so it copies the CONSENT
 * app's shell and palette rather than interpreting them. Source of truth:
 * C:/Users/tatep/dev/consent-forms/api/src/app-shell.mjs (`:root`, `.tabs`,
 * `.body`). Founder ruling 2026-09-09, restated 2026-09-10: "they should be
 * identical… it's seamless." Consent shipped first, so it is the reference; a
 * third style is not a style, it is drift.
 *
 * NOT ghl-custom.js. That file is the Hub's own NAV CHROME, and its tokens
 * (#4A8AA6 accent, Open Sans) are the right answer for an injected tab or a
 * report panel drawn into the Hub's own furniture — a different surface with
 * its own rule. An app that opens in the panel sits beside Consent Forms and
 * Inventory, and has to be indistinguishable from them. This file was built on
 * the wrong one of those two rules and is corrected here.
 *
 * SINGLE LIGHT THEME, painted explicitly. The Hub has no dark mode, so a dark
 * variant would put a dark panel inside a permanently light shell. That is the
 * deliberate single-theme case, not a skipped requirement — every colour is set
 * and body carries an explicit background.
 *
 * Verify with `node tools/measure-subnav.mjs <url>` in health-hue-inventory:
 * it asserts 33 measured values against consent. "Matches consent" is a
 * command, not an opinion — measure it, do not eyeball it.
 */

:root {
  /* Copied verbatim from consent-forms app-shell.mjs `:root`. If these drift,
     re-read them there rather than nudging them here — a stale palette comment
     is how an accent token quietly becomes body text. */
  --paper:      #f6f8fa;   /* page */
  --card:       #ffffff;
  --ink:        #101822;   /* headings, primary text */
  --ink-2:      #3b4756;   /* secondary text */
  --muted:      #5f6c7b;   /* labels, timestamps, low-severity */
  --line:       #e2e7ec;   /* every border in the shell */
  --line-soft:  #eef2f6;   /* row rules inside a card */
  --accent:     #12507f;   /* active tab, links, primary action */
  --accent-soft:#e9f0f7;
  --accent-ink: #ffffff;
  --ok:         #1c6b48;
  --ok-bg:      #e6f2ec;
  --warn:       #8a5713;
  --warn-bg:    #fdf3e2;
  --err:        #b4342a;
  --err-bg:     #fdeceb;

  /* Kept as aliases so the component rules below read the same as before. */
  --surface:    #f6f8fa;
  --surface-2:  #eef2f6;

  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 14px/1.55 var(--font);
}

/* Numbers that change in place — money, counts, tracking — must not reflow the
   row they sit in every time a digit changes width. */
.num { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- chrome -- */

/* The sub-nav. A full-bleed WHITE bar flush to the top of the panel with only
   its own 22px side padding — it is chrome, not content, so it gets no outer
   margin, no radius and no shadow, and nothing may sit above it. There is
   deliberately NO title band: the Hub panel already prints the app's name and a
   Close button directly above this iframe, and repeating it costs a whole band
   of vertical space to say what the chrome above already said. */
.tabs {
  display: flex; gap: 2px; padding: 0 22px;
  background: #fff; border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
/* Text only — no icons, which the Hub does not use here. */
.tabs button {
  background: none; border: 0; padding: 11px 14px;
  font: inherit; font-size: 13.5px; color: var(--muted);
  border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap;
}
.tabs button[aria-selected="true"] {
  color: var(--accent); border-bottom-color: var(--accent); font-weight: 600;
}

/* ---------------------------------------------------------------- layout -- */

/* Consent's `.body`: deep bottom gutter so the last row clears the panel edge,
   and a 1680px cap that is NOT centred — a packing queue squeezed into the
   middle of a clinic monitor wastes the screen it most needs. */
.body { padding: 20px 24px 96px; max-width: 1680px; }

/* The demo banner. Unmistakable on purpose: a review surface that looks live
   and is not will eventually be read as live. It sits INSIDE .body rather than
   above the sub-nav — the bar has to stay flush to the top of the panel, and a
   notice about the data is content anyway. */
.demobar {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  padding: 13px 16px; margin-bottom: 16px;
  background: var(--warn-bg); border: 1px solid #f0e0bf; border-radius: var(--radius);
  color: var(--warn); font-size: 13.5px;
}
.demobar strong { font-weight: 700; }
.demobar .note { color: var(--warn); }

.wrap { display: flex; align-items: flex-start; gap: 16px; }
.queue { width: 340px; flex: 0 0 340px; }
.detail { flex: 1; min-width: 0; }

@media (max-width: 920px) {
  .wrap { flex-direction: column; gap: 12px; }
  .queue, .detail { width: 100%; flex: none; }
}
@media (max-width: 720px) {
  .body { padding: 16px 14px 96px; }
}

/* Consent's card: 10px radius, a plain 1px rule, NO shadow. The Hub apps sit on
   paper and separate by line, not by elevation. */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 16px; overflow: hidden;
}
.card > header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
  background: #fff;
}
.card > header h2 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: -.01em; }
.card > header .spacer { flex: 1; }
.card > header .count { color: var(--muted); font-size: 12.5px; }
/* Named `.pad`, as consent names it, and NOT `.body` — the shell's own content
   box is `.body`, and a card inner sharing that class nests one inside the
   other and makes `document.querySelector('.body')` ambiguous for the
   measuring tool. */
.card .pad { padding: 14px 16px; }
.card .pad.tight { padding: 0; }

/* ----------------------------------------------------------------- queue --
   The queue's filter strip moved OUT of this card and up into the sub-nav
   (To pack / Shipped / All orders), so there is no second tab style here. A
   card-level tab strip under a sub-nav reads as two navigations competing. */

.olist { list-style: none; margin: 0; padding: 0; max-height: calc(100vh - 220px); overflow-y: auto; }
.olist li { border-bottom: 1px solid var(--line); }
.olist li:last-child { border-bottom: 0; }

.orow {
  display: block; width: 100%; text-align: left; cursor: pointer;
  border: 0; border-left: 3px solid transparent; background: none;
  padding: 10px 14px; font: inherit; color: inherit;
}
.orow:hover { background: var(--surface); }
.orow[aria-current="true"] { background: var(--surface-2); border-left-color: var(--accent); }
.orow .r1 { display: flex; align-items: center; gap: 8px; }
.orow .no { font-weight: 700; letter-spacing: -.01em; }
.orow .r2 { display: flex; justify-content: space-between; gap: 8px; margin-top: 3px; color: var(--ink-2); }
.orow .r3 { display: flex; justify-content: space-between; gap: 8px; margin-top: 2px; color: var(--muted); font-size: 12px; }
.orow .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ----------------------------------------------------------------- pills -- */

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .01em; white-space: nowrap;
}
.pill-paid    { background: var(--warn-bg); color: var(--warn); }
.pill-packed  { background: var(--accent-soft); color: var(--accent); }
.pill-shipped { background: var(--ok-bg);  color: var(--ok); }
.pill-pending,
.pill-cancelled,
.pill-refunded { background: var(--surface-2); color: var(--muted); }
/* Status is never colour alone — every pill carries its word. */

/* ---------------------------------------------------------------- detail -- */

.ohead { display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap; padding: 14px; border-bottom: 1px solid var(--line); }
.ohead .no { font-size: 20px; font-weight: 700; letter-spacing: -.02em; margin: 0 0 2px; }
.ohead .sub { color: var(--muted); font-size: 12.5px; }
.ohead .spacer { flex: 1; }
.ohead .total { text-align: right; }
.ohead .total .amt { font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.ohead .total .lbl { color: var(--muted); font-size: 12px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 720px) { .grid2 { grid-template-columns: 1fr; } }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--ink); }

address { font-style: normal; line-height: 1.55; }

/* ------------------------------------------------------------- pick list -- */

.picks { list-style: none; margin: 0; padding: 0; }
.picks li { border-bottom: 1px solid var(--line); }
.picks li:last-child { border-bottom: 0; }
.pick {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 12px 14px; cursor: pointer; user-select: none;
}
.pick:hover { background: var(--surface); }
.pick input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; flex: none; }
.pick .qty {
  flex: none; min-width: 34px; text-align: center;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px;
  padding: 3px 6px; font-weight: 700;
}
.pick .title { flex: 1; min-width: 0; }
.pick .slug { display: block; color: var(--muted); font-size: 11.5px; font-family: var(--mono); }
.pick .money { color: var(--ink-2); }
.pick.done .title, .pick.done .money { color: var(--muted); text-decoration: line-through; }

.pickfoot { padding: 9px 14px; background: var(--surface); border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }

/* ----------------------------------------------------------------- rates -- */

.rates { list-style: none; margin: 0; padding: 0; }
.rates li { border-bottom: 1px solid var(--line); }
.rates li:last-child { border-bottom: 0; }
.rate { display: flex; align-items: center; gap: 12px; padding: 11px 14px; }
.rate:hover { background: var(--surface); }
.rate .svc { flex: 1; min-width: 0; }
.rate .svc b { font-weight: 600; }
.rate .svc span { display: block; color: var(--muted); font-size: 12px; }
.rate .amt { font-weight: 700; }

/* The money the flat tier leaves on the table — or takes off it. Shown per
   order because that gap IS the accepted cost of launching before parcel data
   exists, and an accepted cost nobody can see stops being accepted. */
.delta { font-weight: 600; white-space: nowrap; }
.delta-pos { color: var(--ok); }
.delta-neg { color: var(--err); }

/* ----------------------------------------------------------------- forms -- */

.field { display: block; }
.field span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 3px; }
.field input {
  width: 100%; padding: 7px 9px;
  border: 1px solid var(--line); border-radius: 6px; background: #fff;
  font: inherit; color: var(--ink);
}
.field input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 560px) { .grid4 { grid-template-columns: repeat(2, 1fr); } }

/* --------------------------------------------------------------- buttons -- */

/* Consent's buttons, with this app's naming kept. There, `.btn` is the filled
   accent and `.btn.ghost` the outline; here the bench already calls the filled
   one `.btn-primary` and uses bare `.btn` for secondary actions, so the two
   LOOKS are mapped onto those names rather than renaming every call site. What
   has to match is the rendered pixels, not the class names. */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 15px; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--line); background: none; color: var(--accent);
  font: inherit; font-size: 13px; font-weight: 600; white-space: nowrap;
}
.btn:hover { background: var(--accent-soft); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #0e4069; }
.btn-danger { color: var(--err); border-color: #f0cfcc; }
.btn-danger:hover { background: var(--err-bg); }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* --------------------------------------------------------------- notices -- */

.notice { display: flex; gap: 10px; padding: 11px 14px; border-radius: var(--radius); border: 1px solid; }
.notice p { margin: 0 0 6px; }
.notice p:last-child { margin-bottom: 0; }
.notice .ico { flex: none; font-weight: 700; }
.notice-info { background: var(--surface-2); border-color: var(--line); color: var(--ink-2); }
/* Tinted borders, not invented darker inks: the consent shell tints the border
   and leaves the text on the state token, so a notice here and a receipt there
   read as the same object. #f0e0bf is the warn analogue of consent's own
   #cfe5d8 / #f0cfcc — consent has no warn-bordered box to copy. */
.notice-warn { background: var(--warn-bg); border-color: #f0e0bf; color: var(--warn); }
.notice-err  { background: var(--err-bg);  border-color: #f0cfcc; color: var(--err); }
.notice-ok   { background: var(--ok-bg);   border-color: #cfe5d8; color: var(--ok); }
.notice code { font-family: var(--mono); font-size: 12px; }

.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty h3 { margin: 0 0 4px; font-size: 14px; color: var(--ink-2); }

.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--muted); }
.strong { font-weight: 700; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mb8 { margin-bottom: 8px; }

/* A spinner would be the fourth thing on screen during a one-second fetch.
   Dimming what is already there says the same and moves nothing. */
.busy { opacity: .55; pointer-events: none; }

.sronly {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
