/* WORQ Petty Cash - mobile-first.
 *
 * Built for one hand, a crumpled receipt in the other, and a phone camera:
 *  - tap targets 48px and up;
 *  - system fonts only, nothing waits on a webfont over venue wifi;
 *  - safe-area insets respected, since it runs full-screen from the home screen;
 *  - no inline styles anywhere: the page's Content-Security-Policy forbids them.
 */

:root {
  color-scheme: light;
  --page: #f7f7f5;
  --card: #ffffff;
  --soft: #f1f0ec;
  --ink: #111111;
  --ink-2: #55534e;
  --ink-3: #8a877f;
  --line: rgba(0, 0, 0, 0.10);
  --brand: #f6a000;          /* WORQ orange */
  --brand-ink: #111111;      /* black on orange: ~9:1 contrast */
  --good: #13883a;
  --good-bg: #e6f5ea;
  --wait: #8a5a00;
  --wait-bg: #fff3d6;
  --bad: #c0362c;
  --bad-bg: #fbe5e2;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0e0e0d;
    --card: #1c1c1a;
    --soft: #262623;
    --ink: #f4f3ef;
    --ink-2: #c4c2b9;
    --ink-3: #8a877f;
    --line: rgba(255, 255, 255, 0.12);
    --good: #4cc46e;
    --good-bg: #13301b;
    --wait: #f6c34a;
    --wait-bg: #33280e;
    --bad: #ef6b60;
    --bad-bg: #3a1714;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--page);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;               /* 16px minimum stops iOS zooming into inputs */
}

button, input { font: inherit; color: inherit; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.brand-mark { height: 26px; width: auto; display: block; }
.brand-text { min-width: 0; line-height: 1.25; }
.brand-text .name { font-weight: 700; font-size: 16px; }
.brand-text .sub {
  font-size: 13px; color: var(--ink-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.icon-btn {
  margin-left: auto; min-width: 48px; min-height: 48px;
  border: 0; border-radius: 12px; background: transparent;
  font-size: 22px; color: var(--ink-2); cursor: pointer;
}
.icon-btn:active { background: var(--soft); }

/* ---------- Waiting-to-send banner ---------- */
.banner {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; font-size: 14px;
  background: var(--wait-bg); color: var(--wait);
  border-bottom: 1px solid var(--line);
}
.banner-btn {
  margin-left: auto; flex-shrink: 0;
  border: 1px solid currentColor; border-radius: 10px; background: transparent;
  padding: 8px 12px; font-size: 13px; font-weight: 700; cursor: pointer;
}

/* ---------- Layout ---------- */
.page {
  max-width: 520px; margin: 0 auto;
  padding: 20px 16px calc(32px + env(safe-area-inset-bottom));
}
.loading { color: var(--ink-3); text-align: center; padding: 40px 0; }
h1 { font-size: 23px; margin: 6px 0 8px; }
h2 { font-size: 20px; margin: 6px 0 8px; }
.lede { color: var(--ink-2); margin: 0 0 20px; line-height: 1.45; }

/* ---------- Forms ---------- */
.field { display: block; margin: 0 0 16px; }
.field-label { display: block; font-weight: 600; font-size: 14px; margin: 0 0 6px; }
.field-hint { font-weight: 400; color: var(--ink-3); }
.input {
  width: 100%; min-height: 50px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--card);
}
.input:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.input-code { text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
.input-code::placeholder { text-transform: none; letter-spacing: normal; font-weight: 400; }

.money { display: flex; align-items: stretch; }
.money-symbol {
  display: flex; align-items: center; padding: 0 14px;
  border: 1px solid var(--line); border-right: 0; border-radius: 12px 0 0 12px;
  background: var(--soft); font-weight: 700; color: var(--ink-2);
}
.money .input { border-radius: 0 12px 12px 0; }

/* ---------- Buttons ---------- */
.btn {
  display: block; width: 100%; min-height: 54px; margin: 0 0 10px;
  border: 0; border-radius: 14px; cursor: pointer;
  font-size: 17px; font-weight: 700;
}
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-primary:active { filter: brightness(0.94); }
.btn-primary:disabled { opacity: 0.55; cursor: default; }
.btn-secondary { background: var(--soft); color: var(--ink); }
.btn-link {
  background: transparent; color: var(--ink-2); font-weight: 600; font-size: 15px;
  min-height: 48px;
}

/* The one big thing on the main screen. */
.capture-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; width: 100%; min-height: 200px; margin: 4px 0 12px;
  border: 2px dashed var(--brand); border-radius: 20px;
  background: var(--card); cursor: pointer;
  font-size: 18px; font-weight: 700;
}
.capture-btn:active { background: var(--soft); }
.capture-icon { font-size: 54px; line-height: 1; }

/* ---------- Review ---------- */
.preview-wrap {
  border-radius: 16px; overflow: hidden; background: var(--soft);
  border: 1px solid var(--line); margin: 0 0 6px;
}
.preview { display: block; width: 100%; max-height: 52vh; object-fit: contain; }

.error {
  margin: 0 0 14px; padding: 11px 14px; border-radius: 12px;
  background: var(--bad-bg); color: var(--bad); font-size: 14px; line-height: 1.4;
}

/* ---------- Result ---------- */
.result { text-align: center; padding: 26px 0 10px; }
.result-mark {
  width: 84px; height: 84px; margin: 0 auto 14px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 40px;
  background: var(--good-bg); color: var(--good);
}
.result-mark.waiting { background: var(--wait-bg); color: var(--wait); }
.result p { color: var(--ink-2); line-height: 1.45; margin: 0 0 22px; }
.reference { font-weight: 700; letter-spacing: 0.06em; color: var(--ink); }

/* ---------- Recent list ---------- */
.recent { margin-top: 26px; }
.recent-title {
  font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-3); margin: 0 0 8px;
}
.recent-list { list-style: none; margin: 0; padding: 0; }
.recent-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 14px;
}
.recent-main { min-width: 0; flex: 1; }
.recent-what { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-when { color: var(--ink-3); font-size: 12.5px; margin-top: 2px; }
.pill {
  flex-shrink: 0; padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 700;
}
.pill-sent { background: var(--good-bg); color: var(--good); }
.pill-waiting { background: var(--wait-bg); color: var(--wait); }
.pill-failed { background: var(--bad-bg); color: var(--bad); }

/* ---------- Settings ---------- */
.detail {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 4px 16px; margin: 0 0 18px;
}
.detail-row {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.detail-row:last-child { border-bottom: 0; }
.detail-row span:first-child { color: var(--ink-3); }
.detail-row span:last-child { font-weight: 600; text-align: right; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(22px + env(safe-area-inset-bottom));
  max-width: calc(100% - 32px); padding: 12px 16px; border-radius: 12px;
  background: var(--ink); color: var(--page); font-size: 14px; z-index: 30;
}
.toast.bad { background: var(--bad); color: #fff; }
