/* Brand palette taken from ccsacctiq.com, so PantryFlow sits alongside the
   other Corporate Coffee Systems tools rather than looking like a stranger.
   Source values: --coffee #c8006a, --coffee-dark #960051, --accent #f3008f,
   --navy #1d1e20, --text #1a1a1a, --muted #575760, --border #ddd6c8. */
:root {
  --brand: #c8006a;
  --brand-dark: #960051;
  --brand-bright: #f3008f;
  --brand-tint: #fdf0f7;
  --navy: #1d1e20;

  --bg: #faf8f5;          /* warm off-white, picks up the beige border tone */
  --surface: #ffffff;
  --surface-2: #f6f3ee;
  --border: #ddd6c8;
  --text: #1a1a1a;
  --muted: #575760;
  --accent: #c8006a;
  --accent-ink: #ffffff;
  --green: #2d7d46;
  --green-bg: #edf7f0;
  --amber: #96590a;
  --amber-bg: #fdf6e8;
  --red: #c0392b;
  --red-bg: #fdf0ee;
  --blue: #2b5fd9;
  --blue-bg: #e8f0fe;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(29,30,32,.07), 0 4px 12px rgba(29,30,32,.06);
  --tap: 46px;
  --safe-b: env(safe-area-inset-bottom, 0px);

  /* Sign-in screen. Kept as its own set because the card stays light on the
     dark backdrop, so it cannot simply reuse --surface. */
  --login-a: #1d1e20;           /* backdrop gradient, top-left */
  --login-b: #363740;           /* backdrop gradient, bottom-right */
  --login-card: #ffffff;
  --login-card-edge: transparent;
  --login-heading: #1d1e20;
  --login-field: #e8f0fe;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #f3008f;
    --brand-dark: #c8006a;
    --brand-bright: #ff4fb2;
    --brand-tint: #2a0a1c;

    --bg: #131315;
    --surface: #1d1e20;
    --surface-2: #232427;
    --border: #3a3733;
    --text: #f2efe9;
    --muted: #a8a49c;
    --accent: #f3008f;
    --accent-ink: #ffffff;
    --green: #5cbb7a; --green-bg: #10261a;
    --amber: #e0a94f; --amber-bg: #2b2005;
    --red: #e8695c;   --red-bg: #2c1512;
    --blue: #7aa2f7;  --blue-bg: #131f38;
    --shadow: 0 1px 2px rgba(0,0,0,.45);

    --login-a: #09090b;
    --login-b: #232427;
    --login-card: #1d1e20;
    --login-card-edge: #3a3733;
    --login-heading: #f2efe9;
    --login-field: #131315;
  }
}

* { box-sizing: border-box; }

/* The [hidden] attribute only sets `display: none` at the UA level, so any
   `display: flex/grid` rule below silently defeats it. Everything the app
   shows and hides (offline bar, back button, tab bar) uses [hidden], so this
   has to win. */
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

button, input, select, textarea { font: inherit; color: inherit; }

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

.offline-bar {
  position: sticky; top: 0; z-index: 60;
  display: flex; align-items: center; gap: 12px; justify-content: center;
  background: var(--amber-bg); color: var(--amber);
  border-bottom: 1px solid var(--border);
  padding: 7px 14px; font-size: 13px; font-weight: 600;
}
.offline-bar.syncing { background: var(--blue-bg); color: var(--blue); }
.link-btn { background: none; border: 0; text-decoration: underline; cursor: pointer; padding: 0; font-weight: 600; }

.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-title { flex: 1; min-width: 0; }
.topbar-title strong { display: block; font-size: 16px; letter-spacing: -.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-title small { display: block; color: var(--muted); font-size: 12.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.icon-btn {
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface-2); cursor: pointer; font-size: 20px; line-height: 1;
  display: grid; place-items: center; flex: none;
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%; border: 0; flex: none;
  background: var(--accent); color: var(--accent-ink);
  font-size: 12.5px; font-weight: 700; cursor: pointer;
}

.view { padding: 14px 14px calc(84px + var(--safe-b)); max-width: 820px; margin: 0 auto; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  display: flex; background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: var(--safe-b);
}
.tabbar button {
  flex: 1; border: 0; background: none; cursor: pointer;
  padding: 8px 4px 9px; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 10.5px; font-weight: 600; letter-spacing: .01em;
}
.tabbar button .tab-ico { font-size: 18px; line-height: 1; }
.tabbar button.active { color: var(--text); }
.tabbar button .badge-dot {
  position: absolute; transform: translate(13px, -4px);
  min-width: 15px; height: 15px; border-radius: 8px; background: var(--red);
  color: #fff; font-size: 9.5px; line-height: 15px; padding: 0 4px;
}

/* ---------- primitives ---------- */

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; margin-bottom: 12px;
}
.card.flat { box-shadow: none; }
.card-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.card-head h2, .card-head h3 { margin: 0; font-size: 15.5px; letter-spacing: -.01em; }
.card-head .spacer { flex: 1; }

h1 { font-size: 21px; margin: 4px 0 14px; letter-spacing: -.02em; }
h2 { font-size: 16px; margin: 22px 0 10px; letter-spacing: -.01em; }
h3 { font-size: 14px; margin: 0 0 8px; }
p.muted, .muted { color: var(--muted); }
small.muted { font-size: 12.5px; }
.mono { font-variant-numeric: tabular-nums; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: var(--tap); padding: 0 18px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-2);
  font-weight: 600; cursor: pointer; text-decoration: none; color: var(--text);
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.success { background: var(--green); color: #fff; border-color: var(--green); }
.btn.danger  { background: var(--red); color: #fff; border-color: var(--red); }
.btn.ghost   { background: none; }
.btn.block   { width: 100%; }
.btn.sm      { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=time], input[type=search], select, textarea {
  width: 100%; min-height: var(--tap); padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text); appearance: none;
}
textarea { min-height: 90px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: -1px; }
.field-row { display: flex; gap: 10px; }
.field-row > * { flex: 1; min-width: 0; }
.check-line { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; font-size: 14px; }
.check-line input[type=checkbox] { width: 20px; height: 20px; min-height: 0; flex: none; accent-color: var(--blue); }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
  white-space: nowrap;
}
.pill.green { background: var(--green-bg); color: var(--green); border-color: transparent; }
.pill.amber { background: var(--amber-bg); color: var(--amber); border-color: transparent; }
.pill.red   { background: var(--red-bg);   color: var(--red);   border-color: transparent; }
.pill.blue  { background: var(--blue-bg);  color: var(--blue);  border-color: transparent; }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .big { font-size: 34px; margin-bottom: 8px; opacity: .55; }

.list { list-style: none; margin: 0; padding: 0; }
.row {
  display: flex; align-items: center; gap: 11px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .grow strong { display: block; font-size: 14.5px; }
/* Block, because several rows stack two lines of detail — a label and the
   note explaining it — and inline <small> ran them together. */
.row .grow small { display: block; color: var(--muted); font-size: 12.5px; }

/* A finished stop. The whole row goes green rather than just its badge, so a
   rep glancing down the day's list sees what is behind them without reading a
   word. Drawn as its own rounded block instead of a full-width band: a band
   would collide with the card's own rounded corners at the top and bottom of
   the list. */
.row.done {
  background: var(--green-bg);
  border: 1px solid rgba(45,125,70,.22);
  border-left: 3px solid var(--green);
  border-radius: 9px;
  padding: 11px 12px;
  margin: 6px 0;
}
.row.done:first-child { margin-top: 0; }
.row.done:last-child { margin-bottom: 0; }
.row.done .grow strong { color: var(--green); }
.row.done .grow small { color: var(--green); opacity: .8; }
.row.done .bar { background: rgba(45,125,70,.2); }
/* Solid, so the badge still reads as a badge against the tint behind it.
   The ink follows the surface colour: white on dark green in daylight, dark on
   pale green at night. */
.row.done .pill.green { background: var(--green); color: var(--surface); }

.bar { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; margin-top: 7px; }
.bar > i { display: block; height: 100%; background: var(--green); transition: width .25s; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 13px;
}
.stat b { display: block; font-size: 22px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); }

.seg { display: flex; background: var(--surface-2); border: 1px solid var(--border);
       border-radius: 10px; padding: 3px; gap: 3px; margin-bottom: 14px; overflow-x: auto; }
.seg button { flex: 1; border: 0; background: none; padding: 9px 10px; border-radius: 8px;
              font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap; }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; }

/* ---------- checklist ---------- */

.chk {
  display: flex; gap: 11px; padding: 13px 0; border-bottom: 1px solid var(--border);
  align-items: flex-start;
}
.chk:last-child { border-bottom: 0; }
.chk-box {
  width: 27px; height: 27px; flex: none; margin-top: 1px;
  border: 2px solid var(--border); border-radius: 8px; background: var(--surface);
  cursor: pointer; display: grid; place-items: center; font-size: 15px; color: transparent;
  transition: background .12s, border-color .12s;
}
.chk.done .chk-box { background: var(--green); border-color: var(--green); color: #fff; }
.chk.skipped .chk-box, .chk.na .chk-box { background: var(--amber); border-color: var(--amber); color: #fff; font-size: 13px; }
.chk-body { flex: 1; min-width: 0; }
.chk-body .lbl { font-weight: 600; font-size: 14.5px; }
.chk.done .chk-body .lbl { color: var(--muted); }
.chk-body .help { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.chk-meta { font-size: 11.5px; color: var(--muted); margin-top: 5px; display: flex; gap: 7px; flex-wrap: wrap; align-items: center; }
.chk-value { margin-top: 8px; }
.section-head {
  font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); margin: 16px 0 2px;
}
.section-head:first-child { margin-top: 0; }

/* ---------- audit lines ----------
   Each line stacks: what is being checked, the verdict, why it failed, and
   the evidence. The verdict buttons are deliberately large — this is done
   standing up, on a phone, often one-handed. */

.audit-line {
  padding: 13px 12px; margin: 0 -12px;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid transparent;
}
.audit-line:last-child { border-bottom: 0; }
.audit-line.pass { border-left-color: var(--green); background: var(--green-bg); }
.audit-line.fail { border-left-color: var(--red);   background: var(--red-bg); }
.audit-line.na   { border-left-color: var(--border); background: var(--surface-2); }

.audit-head { display: flex; gap: 10px; align-items: flex-start; }
.audit-head .grow { flex: 1; min-width: 0; }
.audit-head strong { display: block; font-size: 14.5px; line-height: 1.35; }
.audit-head small { display: block; font-size: 12.5px; margin-top: 3px; line-height: 1.4; }

.audit-choice { display: flex; gap: 8px; margin-top: 10px; }
.audit-choice .choice {
  flex: 1; min-height: 40px; font-weight: 700; justify-content: center;
  border: 1.5px solid var(--border); background: var(--surface); color: var(--muted);
}
.audit-choice .choice.ok.active   { background: var(--green); border-color: var(--green); color: #fff; }
.audit-choice .choice.bad.active  { background: var(--red);   border-color: var(--red);   color: #fff; }
.audit-choice .choice.skip.active { background: var(--muted); border-color: var(--muted); color: var(--surface); }
.audit-choice .choice:disabled { opacity: .55; }

.audit-note { margin-top: 9px; width: 100%; }
.audit-photos { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; margin-bottom: 7px; }
.audit-thumb {
  width: 56px; height: 56px; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--border); cursor: pointer;
}

/* ---------- photos ---------- */

.area {
  border: 1px solid var(--border); border-radius: 11px; padding: 12px; margin-bottom: 11px;
  background: var(--surface-2);
}
.area.satisfied { border-color: var(--green); background: var(--green-bg); }
.area-head { display: flex; align-items: center; gap: 9px; margin-bottom: 9px; }
.area-head strong { flex: 1; font-size: 14.5px; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 7px; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 9px; overflow: hidden;
         background: var(--border); border: 1px solid var(--border); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .rm {
  position: absolute; top: 3px; right: 3px; width: 21px; height: 21px; border-radius: 50%;
  border: 0; background: rgba(0,0,0,.65); color: #fff; font-size: 13px; line-height: 21px;
  cursor: pointer; padding: 0;
}
.thumb.pending::after {
  content: 'queued'; position: absolute; inset: auto 0 0 0; background: rgba(15,23,42,.78);
  color: #fff; font-size: 9.5px; text-align: center; padding: 2px; font-weight: 700; letter-spacing: .04em;
}
.add-photo {
  aspect-ratio: 1; border: 2px dashed var(--border); border-radius: 9px; background: none;
  cursor: pointer; display: grid; place-items: center; color: var(--muted); font-size: 22px;
}

/* ---------- modal & toast ---------- */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; background: rgba(15,23,42,.5);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .15s ease;
}
@media (min-width: 640px) { .modal-backdrop { align-items: center; } }
.modal {
  background: var(--surface); width: 100%; max-width: 560px;
  max-height: 92vh; overflow-y: auto;
  border-radius: 16px 16px 0 0; padding: 18px 16px calc(18px + var(--safe-b));
  animation: slideup .2s ease;
}
@media (min-width: 640px) { .modal { border-radius: 16px; padding-bottom: 18px; } }
.modal h3 { font-size: 17px; margin: 0 0 4px; }
.modal .modal-sub { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
@keyframes fade { from { opacity: 0 } }
@keyframes slideup { from { transform: translateY(16px); opacity: .6 } }

.toast-root { position: fixed; left: 0; right: 0; bottom: calc(72px + var(--safe-b)); z-index: 200;
              display: flex; flex-direction: column; align-items: center; gap: 7px; pointer-events: none; }
.toast {
  background: var(--accent); color: var(--accent-ink); padding: 10px 16px; border-radius: 999px;
  font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow); max-width: 90%;
  animation: slideup .18s ease;
}
.toast.error { background: var(--red); color: #fff; }
.toast.ok { background: var(--green); color: #fff; }

.banner {
  padding: 11px 13px; border-radius: 10px; font-size: 13.5px; margin-bottom: 12px;
  border: 1px solid transparent; line-height: 1.45;
}
.banner.info  { background: var(--blue-bg);  color: var(--blue); }
.banner.warn  { background: var(--amber-bg); color: var(--amber); }
.banner.error { background: var(--red-bg);   color: var(--red); }
.banner.ok    { background: var(--green-bg); color: var(--green); }
.banner ul { margin: 6px 0 0; padding-left: 18px; }

/* Sign-in screen — a full-bleed dark gradient with the card sitting on it,
   matching the CCS AcctIQ sign-in so the two feel like one suite.
   Fixed positioning is deliberate: it escapes the app shell's padding and
   max-width so the gradient really does reach every edge. */
.login-screen {
  position: fixed; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  padding: 24px calc(24px + env(safe-area-inset-right, 0px))
           calc(24px + env(safe-area-inset-bottom, 0px)) calc(24px + env(safe-area-inset-left, 0px));
  background: linear-gradient(160deg, var(--login-a), var(--login-b));
  overflow-y: auto;
}
.login-card {
  background: var(--login-card);
  width: 100%; max-width: 380px;
  border-radius: 14px;
  padding: 32px 28px;
  box-shadow: 0 12px 32px rgba(0,0,0,.25);
  border: 1px solid var(--login-card-edge);
}
.login-card h1 { font-size: 22px; font-weight: 700; color: var(--login-heading);
                 margin: 0 0 6px; letter-spacing: -.01em; }
.login-card .subtitle { color: var(--muted); font-size: 13.5px; margin: 0 0 20px; line-height: 1.5; }
.login-card label.field > span { font-size: 12.5px; font-weight: 600; }
.login-card input { background: var(--login-field); }
.login-card .btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.login-card .btn.primary:disabled { opacity: .6; }

/* Lettermark shown only when no wordmark file has been supplied. */
.login-logo { width: 56px; height: 56px; border-radius: 14px; background: var(--brand);
              color: #fff; display: grid; place-items: center; font-size: 26px;
              margin: 0 0 16px; }
/* When public/brand/logo.png exists this replaces the lettermark. */
.brand-logo { display: block; max-width: 220px; max-height: 66px; width: auto; height: auto;
              margin: 0 0 16px; }
/* Centred on the sign-in card only — the same class also sits in the top bar,
   where it has to stay hard against the left edge. */
.login-card .brand-logo,
.login-card .login-logo { margin-left: auto; margin-right: auto; }
.topbar-logo { height: 22px; width: auto; margin-right: 2px; flex: none; }
.spinner { width: 22px; height: 22px; border: 2.5px solid var(--border); border-top-color: var(--blue);
           border-radius: 50%; animation: spin .7s linear infinite; margin: 34px auto; }
@keyframes spin { to { transform: rotate(360deg) } }

/* A quiet divider inside a card, for splitting one list into named groups. */
.row-head { font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
            color: var(--muted); margin: 10px 0 2px; }
.row-head:first-child { margin-top: 0; }

.drag-handle { cursor: grab; color: var(--muted); font-size: 17px; padding: 0 3px; touch-action: none; }
li.dragging { opacity: .45; }
