/* Packing List: the look of the app (colors, layout, phone sizes, dark mode). */
:root {
  --bg: #f6f6f4; --surface: #ffffff; --surface-2: #f0f0ed; --text: #1a1a1a; --muted: #6b6b66;
  --line: #deded9; --accent: #111111; --accent-text: #ffffff; --danger: #b42318; --warn-bg: #fff4d6;
  --warn-text: #6b4b00; --focus: #2f6fed; --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141414; --surface: #1e1e1e; --surface-2: #262626; --text: #f0f0ee; --muted: #a3a39e;
    --line: #333331; --accent: #f0f0ee; --accent-text: #111111; --danger: #ff7b6e; --warn-bg: #3a2f10;
    --warn-text: #ffd98a; --focus: #7aa5ff;
  }
}
:root[data-theme="dark"] {
  --bg: #141414; --surface: #1e1e1e; --surface-2: #262626; --text: #f0f0ee; --muted: #a3a39e;
  --line: #333331; --accent: #f0f0ee; --accent-text: #111111; --danger: #ff7b6e; --warn-bg: #3a2f10;
  --warn-text: #ffd98a; --focus: #7aa5ff;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
button, input, textarea, select { font: inherit; color: inherit; }
input, textarea, select {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; min-width: 0;
}
input:focus, textarea:focus, select:focus, button:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
textarea { resize: vertical; }
.wrap { max-width: 860px; margin: 0 auto; padding: 0 16px calc(96px + env(safe-area-inset-bottom)); } /* room so the host's floating badge never covers a button */
header.bar {
  position: -webkit-sticky; position: sticky; top: 0; z-index: 5; background: var(--bg); border-bottom: 1px solid var(--line);
  margin: 0 -16px 16px; padding: 10px 16px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
header.bar h1 { font-size: 18px; margin: 0; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 8px 12px; cursor: pointer;
  white-space: nowrap; min-height: 40px;
}
a.btn { text-decoration: none; color: inherit; display: inline-flex; align-items: center; }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }
.card h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.banner { background: var(--warn-bg); color: var(--warn-text); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.banner span { flex: 1; min-width: 180px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }
.lines input { border-radius: 0; border-width: 0 0 1px; padding: 6px 2px; background: transparent; }
.field { display: grid; gap: 4px; margin-bottom: 10px; }
.field > span { font-size: 13px; color: var(--muted); }

/* Orders list */
.orders { list-style: none; margin: 0; padding: 0; }
.orders li a {
  display: grid; grid-template-columns: auto 1fr auto; gap: 4px 14px; align-items: center; text-decoration: none; color: inherit;
  padding: 12px 4px; border-bottom: 1px solid var(--line);
}
.orders li:last-child a { border-bottom: 0; }
.orders .go { font-weight: 700; font-variant-numeric: tabular-nums; }
.orders .to { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.orders .meta { color: var(--muted); font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; }
.empty { text-align: center; padding: 28px 8px; color: var(--muted); }

/* Box entry */
.unit-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.unit-toggle button { border: 0; background: var(--surface); padding: 6px 12px; cursor: pointer; min-height: 34px; }
.unit-toggle button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.boxes-head, .box {
  display: grid; grid-template-columns: 26px minmax(0,1.4fr) minmax(0,1fr) minmax(0,.9fr) minmax(0,.9fr) 32px; gap: 6px; align-items: start;
}
.boxes-head { font-size: 12px; color: var(--muted); padding: 0 0 6px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.box { padding: 3px 0; }
.box .num { font-size: 12px; color: var(--muted); padding-top: 10px; text-align: right; font-variant-numeric: tabular-nums; }
.box input { padding: 7px 6px; font-variant-numeric: tabular-nums; }
.box input::placeholder { color: var(--muted); opacity: .7; }
.box .w small { display: block; white-space: nowrap; overflow: hidden; font-size: 11px; color: var(--muted); padding: 1px 2px 0; min-height: 15px; font-variant-numeric: tabular-nums; }
.box input.bad { border-color: var(--danger); }
.box select.sku { padding: 7px 4px; font-size: 14px; width: 100%; min-width: 0; }
.box select.sku.inherit { color: var(--muted); }
.box .del { border: 0; background: transparent; color: var(--muted); font-size: 20px; line-height: 1; height: 36px; cursor: pointer; border-radius: 6px; }
.box .del:hover { color: var(--danger); background: var(--surface-2); }
.box.ghost input { background: var(--surface-2); } /* the empty next box: ready to type in, just shaded */
.box.ghost .del { visibility: hidden; }
/* Totals: one thin strip (boxes · net · gross). The unit being typed is shown big, the other unit small. */
.totals { display: grid; grid-template-columns: minmax(0,.7fr) minmax(0,1fr) minmax(0,1fr); gap: 6px; text-align: center; }
.totals div { background: var(--surface-2); border-radius: 8px; padding: 6px 4px; line-height: 1.25; }
.totals b { display: block; font-size: 16px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.totals small { display: block; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.totals span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
@media (max-width: 480px) {
  .totals b { font-size: 15px; }
  /* phones: two lines per box. Line 1: the product (full width, so long names fit). Line 2: Lot + net + gross.
     The delete button sits under the box number, so both lines use the full width.
     Each empty box says what goes in it, so the column headings aren't needed. */
  .boxes-head { display: none; }
  .box {
    grid-template-columns: 24px minmax(0,1.2fr) minmax(0,1fr) minmax(0,1fr); gap: 6px 6px;
    grid-template-areas: "num sku sku sku" "del lot net gross";
  }
  .box { padding: 8px 0 6px; border-bottom: 1px solid var(--line); }
  .box > :nth-child(1) { grid-area: num; }
  .box > :nth-child(2) { grid-area: sku; }
  .box > :nth-child(3) { grid-area: lot; }
  .box > :nth-child(4) { grid-area: net; }
  .box > :nth-child(5) { grid-area: gross; }
  .box > :nth-child(6) { grid-area: del; }
  .box .num { font-size: 14px; font-weight: 600; color: var(--text); padding-top: 11px; text-align: left; }
  .box .del { align-self: start; width: 24px; height: 40px; padding: 0; font-size: 22px; }
  .box input, .box select.sku { font-size: 16px; padding: 9px 8px; min-height: 42px; }
  .box input { padding: 9px 6px; }
  .box .w input { font-size: 17px; }
  .box .w small { font-size: 11px; }
}
.saved { font-size: 13px; color: var(--muted); white-space: nowrap; }
.send { display: grid; gap: 10px; }
.send .btn { min-height: 52px; font-size: 17px; width: 100%; }
.step { display: inline-flex; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--accent-text); font-size: 12px; align-items: center; justify-content: center; margin-right: 6px; letter-spacing: 0; }
.cust { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.cust:last-child { border-bottom: 0; }
.cust > div:first-child { min-width: 0; }
.cust .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cust-edit { padding: 10px 0; border-bottom: 1px solid var(--line); }
.sync { font-size: 12px; color: var(--muted); white-space: nowrap; }
.sync.off { color: var(--warn-text); }
.login { max-width: 380px; margin: 8vh auto 0; }
.login img { width: 150px; display: block; margin: 0 auto 18px; border-radius: 10px; }
.login h1 { font-size: 20px; text-align: center; margin: 0 0 18px; }
.login .err { color: var(--danger); font-size: 14px; min-height: 20px; margin: 4px 0 10px; }
.linkbtn { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; padding: 6px 0; font-size: 14px; }
.continue { display: flex; align-items: center; justify-content: space-between; gap: 10px; text-decoration: none; color: inherit; }
.continue b { font-size: 17px; }
.toast button { margin-left: 12px; background: transparent; border: 1px solid currentColor; color: inherit; border-radius: 999px; padding: 2px 10px; cursor: pointer; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); max-width: min(420px, calc(100vw - 32px)); padding: 18px; }
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog:not([open]) { display: none; }
/* pop-ups on browsers without <dialog> (iPhones before iOS 15.4, older Firefox) */
dialog.fallback[open] { display: block; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); margin: 0; z-index: 101; width: calc(100vw - 32px); max-width: 420px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.dlg-backdrop { position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: rgba(0,0,0,.4); z-index: 100; }
/* spacing between buttons on browsers without flexbox "gap" (iPhones before iOS 14.5) */
@supports not (aspect-ratio: 1) {
  .actions > *, header.bar > *, .banner > *, .cust > * { margin: 3px 4px 3px 0; }
}
dialog h3 { margin: 0 0 8px; font-size: 18px; }
dialog .actions { justify-content: flex-end; margin-top: 14px; }
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--accent); color: var(--accent-text); padding: 10px 16px; border-radius: 999px; font-size: 14px; z-index: 50; max-width: calc(100vw - 32px); }
[hidden] { display: none !important; }
/* Getting-started checklist (company admins) */
.setup ol.steps { margin: 8px 0 0; padding: 0; list-style: none; counter-reset: st; }
.setup ol.steps li { counter-increment: st; border-top: 1px solid var(--line); }
.setup ol.steps a { display: flex; align-items: center; gap: 10px; padding: 11px 2px; text-decoration: none; color: inherit; }
.setup ol.steps a::before { content: counter(st); flex: none; width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--line); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; color: var(--muted); }
.setup ol.steps a::after { content: "›"; margin-left: auto; color: var(--muted); font-size: 20px; }
.setup ol.steps li.done a { color: var(--muted); text-decoration: line-through; }
.setup ol.steps li.done a::before { content: "✓"; background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
