/* F&R app shell — shared chrome for every F&R form (this app now, coffee in
   Phase 5). Palette, type scale, header/footer, lists of rows, stepper, confirm
   bar, tabs and PIN gate are ported from coffee-inventory's Styles.html (v3
   chrome) so the coffee forms move onto this shell without a redesign. Nothing
   app-specific belongs here — that's app.css. */
:root {
  --ink: #2b2622;
  --muted: #6f665e;
  --line: #e2dcd4;
  --bg: #faf7f3;
  --card: #ffffff;
  --accent: #6f4e37;      /* coffee brown */
  --accent-ink: #ffffff;
  --cream: #f2ece4;
  --amber-bg: #fff4d6; --amber-ink: #8a6100; --amber-line: #e7c15a;
  --red-bg: #fde3e0;   --red-ink: #9b2216;  --red-line: #e39b90;
  --green-bg: #e6f2e7; --green-ink: #22652a; --green-line: #a9cfac;
  --ok: #2e7d32;
  --hdr-h: 64px;          /* the sticky header's height — chrome.js keeps it measured */
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 18px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(104px + env(safe-area-inset-bottom));
}
button, input, select { font-family: inherit; }
[hidden] { display: none !important; }
.wrap { max-width: 640px; margin: 0 auto; padding: 0 14px; }
@media (max-width: 380px) { .wrap { padding: 0 12px; } }

/* --- Header (coffee v3): title + date left, location dropdown right ---------- */
header {
  position: sticky; top: 0; z-index: 5;
  background: var(--accent); color: var(--accent-ink);
  padding: calc(10px + env(safe-area-inset-top)) 0 10px; box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
.header-bar { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.head-left { flex: 1; min-width: 0; }
header .title { font-size: 20px; font-weight: 700; line-height: 1.15;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
header .sub { font-size: 14px; opacity: .92; margin-top: 3px; line-height: 1.2;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back-btn {
  flex: 0 0 auto; width: 40px; height: 44px; margin-left: -6px; padding: 0;
  background: transparent; color: #fff; border: none; font-size: 34px; line-height: 1;
  cursor: pointer; touch-action: manipulation;
}
.loc-select {
  -webkit-appearance: none; appearance: none;
  font-size: 16px; font-weight: 700; color: #fff; background-color: transparent;
  border: 1px solid rgba(255,255,255,.55); border-radius: 8px;
  padding: 8px 28px 8px 10px; flex: 0 0 auto; max-width: 46%; min-height: 44px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='white' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
}
.loc-select option { color: var(--ink); background: #fff; }
@media (min-width: 420px) {
  header .title { font-size: 22px; }
  header .sub { font-size: 15px; }
  .loc-select { font-size: 18px; }
}

/* Jump chips: one per group, under the title inside the sticky header; the row
   scrolls sideways when the chips don't fit (320 px). */
header.with-jump { padding-bottom: 0; }
.jump {
  display: flex; gap: 6px; max-width: 640px; margin: 6px auto 0; padding: 0 14px 6px;
  overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.jump::-webkit-scrollbar { display: none; }
.jump-chip {
  flex: 0 0 auto; min-height: 44px; min-width: 44px; padding: 0 14px; border-radius: 999px;
  font-size: 15px; font-weight: 600; white-space: nowrap; color: #fff;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.45);
  cursor: pointer; touch-action: manipulation;
}
.jump-chip:active { background: #fff; color: var(--accent); }
@media (max-width: 380px) { .jump { padding: 0 12px 6px; } .jump-chip { padding: 0 12px; } }

/* --- Footer: logo · sync status · Done ------------------------------------------ */
.footer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  background: var(--card); border-top: 1px solid var(--line);
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom)); box-shadow: 0 -2px 8px rgba(0,0,0,.06);
}
.footer .wrap { display: flex; align-items: center; gap: 10px; }
.brandmark { flex: 0 0 auto; height: 52px; width: auto; display: block; border-radius: 6px; }
.sync {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px;
  background: none; border: none; padding: 8px 2px; min-height: 44px; text-align: left; color: var(--muted);
  font-size: 14px; cursor: pointer; touch-action: manipulation;
}
.sync-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sync-dot { flex: 0 0 auto; width: 11px; height: 11px; border-radius: 50%; background: #b5ada4; }
.sync-amber .sync-dot { background: #e0a100; }
.sync-red { color: var(--red-ink); font-weight: 600; }
.sync-red .sync-dot { background: #c62828; }
button.submit {
  flex: 0 0 auto; padding: 15px 18px; font-size: 18px; font-weight: 700;
  background: var(--accent); color: #fff; border: none; border-radius: 10px;
  white-space: nowrap; cursor: pointer; touch-action: manipulation;
}
button.submit.inactive { background: #b9a89b; }
@media (max-width: 340px) { .brandmark { height: 44px; } .footer .wrap { gap: 8px; } button.submit { padding: 14px 12px; font-size: 17px; } }
@media (min-width: 420px) { .brandmark { height: 60px; } button.submit { padding: 16px 22px; font-size: 19px; } }

/* --- Common ------------------------------------------------------------------------ */
.center { text-align: center; padding: 26px 10px; color: var(--muted); font-size: 17px; }
.lines-empty { padding: 22px 14px; text-align: center; color: var(--muted); font-size: 17px; }
.hint { font-size: 14px; color: var(--muted); }
.hint.pad { padding: 10px 14px; }
.status-line { min-height: 22px; font-size: 15px; color: var(--ok); padding: 10px 2px; text-align: center; }
.linkish { background: none; border: none; color: var(--accent); font-size: 15px; font-weight: 600;
  padding: 10px 6px; min-height: 44px; cursor: pointer; text-decoration: underline; }
.add-btn {
  width: 100%; min-height: 50px; font-size: 17px; font-weight: 700;
  background: var(--accent); color: #fff; border: none; border-radius: 10px;
  cursor: pointer; touch-action: manipulation;
}
.add-btn:disabled { background: #b9a89b; }
.text-input {
  width: 100%; padding: 12px; font-size: 17px; color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.badge { display: inline-block; margin-left: 6px; padding: 0 5px; border-radius: 4px;
  font-size: 11px; font-weight: 700; color: var(--muted); border: 1px solid var(--line);
  vertical-align: 2px; letter-spacing: .03em; }

/* --- Lists of rows ------------------------------------------------------------------------ */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; margin-top: 14px; }
.row {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 8px 10px 10px; border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: none; }
.row .name { flex: 1; min-width: 0; }
.iname { font-size: 15px; font-weight: 600; line-height: 1.25; }
@media (min-width: 420px) { .iname { font-size: 16px; } }
.row .sub { font-size: 13px; color: var(--muted); margin-top: 2px; line-height: 1.3; }
.row .sub .carry { color: var(--accent); font-weight: 600; margin-right: 8px; }
.row .sub .par { color: #a0968c; }

/* Grouped lists (groups.js): each section's header sticks just under the page
   header while its rows scroll past; a jump lands the header right there. */
.grp { scroll-margin-top: var(--hdr-h); }
.grp-h {
  position: sticky; top: var(--hdr-h); z-index: 1;
  padding: 7px 10px; background: var(--cream); color: var(--muted);
  font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  border-bottom: 1px solid var(--line);
}
.grp:first-child .grp-h { border-radius: 11px 11px 0 0; }
.grp + .grp .grp-h { border-top: 1px solid var(--line); }
.grp > .row:last-child { border-bottom: none; }

/* External [ − ] [ value ] [ + ] stepper (coffee thumb-test revision). */
.stepper { display: flex; align-items: stretch; flex: 0 0 auto; }
.step-btn {
  width: 48px; min-height: 50px; padding: 0;
  font-size: 26px; font-weight: 700; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  background: var(--cream); color: var(--accent); border: 1px solid var(--line);
  cursor: pointer; user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.step-btn.minus { border-radius: 10px 0 0 10px; }
.step-btn.plus  { border-radius: 0 10px 10px 0; }
.step-btn:active { background: #e6ddd0; }
.stepper input {
  width: 64px; min-height: 50px; padding: 8px 4px; font-size: 22px; text-align: center;
  background: #fff; color: var(--ink); border: 1px solid var(--line);
  border-left: none; border-right: none; border-radius: 0;
}
.stepper.compact .step-btn { width: 44px; }
.stepper.compact input { width: 40px; }
.stepper input.prefill { color: #a0968c; }
.stepper input.red { background: var(--red-bg); color: var(--red-ink); }

/* Confirm bar + summary sheet before a submit (in-page — no browser dialogs). */
.confirm-bar, .summary {
  margin-top: 14px; border: 1px solid var(--amber-line); background: var(--amber-bg);
  color: var(--amber-ink); border-radius: 12px; padding: 12px 14px 14px;
}
.confirm-bar, .summary { scroll-margin-top: calc(var(--hdr-h) + 8px); }
.summary { border-color: var(--line); background: var(--card); color: var(--ink); }
.confirm-title, .summary-title { font-size: 17px; font-weight: 700; }
.summary-grid { display: flex; gap: 18px; margin: 8px 0; font-size: 16px; }
.summary-grid b { font-size: 24px; }
.confirm-btns { display: flex; gap: 8px; margin-top: 12px; }
.confirm-btn {
  flex: 1 1 0; min-height: 48px; font-size: 16px; font-weight: 700;
  border-radius: 10px; cursor: pointer; touch-action: manipulation;
}
.confirm-btn.back { background: var(--accent); color: #fff; border: none; }
.confirm-btn.go { background: transparent; color: var(--amber-ink); border: 1px solid currentColor; }
.summary .confirm-btn.go { color: var(--muted); }

@keyframes pulse { 0%, 100% { box-shadow: inset 0 0 0 0 rgba(198,40,40,0); }
  30% { box-shadow: inset 0 0 0 3px rgba(198,40,40,.85); } }
.pulse { animation: pulse 1.1s ease-in-out 2; }

/* --- Folder tabs ------------------------------------------------------------------------ */
.tabs { display: flex; gap: 4px; margin: 14px 0 0; }
.tab {
  flex: 1; text-align: center; padding: 13px 8px; cursor: pointer;
  background: #ece5db; color: var(--muted); border: 1px solid var(--line);
  border-bottom: none; border-radius: 10px 10px 0 0; font-weight: 600; font-size: 17px;
}
.tab.active { background: var(--card); color: var(--ink); }
.tabs + .panel { margin-top: 0; border-radius: 0 0 12px 12px; }

/* --- PIN gate (coffee v4.2) ---------------------------------------------------------------- */
.pin-gate {
  max-width: 340px; margin: 30px auto 0; padding: 22px 18px 24px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,.05); text-align: center;
}
.pin-title { font-size: 22px; font-weight: 700; color: var(--ink); }
.pin-sub { font-size: 14px; color: var(--muted); margin: 6px 0 18px; line-height: 1.35; }
.pin-input {
  width: 100%; padding: 14px 12px; font-size: 26px; text-align: center;
  letter-spacing: .35em; font-weight: 700; color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
.pin-btn { margin-top: 14px; }
.pin-msg { min-height: 20px; margin-top: 12px; font-size: 15px; color: var(--muted); }
.pin-msg.err { color: var(--red-ink); font-weight: 600; }
