/* Tian Bao app. Phone first: big targets, two languages on every label. */

:root {
  --bg: #f6f5f1;
  --card: #ffffff;
  --ink: #1c1b18;
  --muted: #6b6860;
  --line: #e2dfd6;
  --brand: #14532d;
  --brand-ink: #ffffff;
  --soft: #e8f0ea;
  --warn: #9a3412;
  --warn-soft: #fff1e8;
  --rec: #b91c1c;
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans SC", "PingFang SC", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12130f; --card: #1c1d18; --ink: #ecebe5; --muted: #a29f95; --line: #33342d;
    --brand: #4ade80; --brand-ink: #0b1a10; --soft: #1d2b21; --warn: #fdba74; --warn-soft: #2d1d12; --rec: #dc2626;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 var(--font); }
body { padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
#app { max-width: 560px; margin: 0 auto; padding: 16px 16px 40px; }

h1 { font-size: 1.35rem; margin: 4px 0 2px; }
h2 { font-size: 1.05rem; margin: 22px 0 8px; }
p { margin: 6px 0; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* Every label carries English, then Chinese (and Malay on the workers' screens). */
.l { display: inline-flex; flex-direction: column; line-height: 1.2; }
.l .zh { font-size: .92em; }
.l .ms { font-size: .85em; color: var(--muted); }
button .l, .tile .l { align-items: center; text-align: center; }
button .l .ms { color: inherit; opacity: .8; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.who { font-size: .875rem; color: var(--muted); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stack { display: grid; gap: 12px; }

label.field { display: grid; gap: 6px; font-weight: 600; }
input[type=text], input[type=password], input[type=search] {
  width: 100%; font: inherit; font-size: 1.05rem; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
}
input:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

button, .btn {
  font: inherit; font-weight: 600; border: 0; border-radius: 12px; padding: 12px 16px; min-height: 48px;
  background: var(--brand); color: var(--brand-ink); cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
}
button.quiet { background: transparent; color: var(--ink); border: 1px solid var(--line); }
button[disabled] { opacity: .45; cursor: not-allowed; }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile {
  min-height: 112px; border-radius: var(--radius); font-size: 1.15rem; flex-direction: column; gap: 6px;
}
.tile small { font-weight: 500; font-size: .75rem; opacity: .85; }

.error { background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: 10px 12px; }

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.list li { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.list .name { font-weight: 600; }
.list .zh { color: var(--ink); }
.units { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.unit { font-size: .8rem; background: var(--soft); border-radius: 999px; padding: 3px 10px; }
.tag { font-size: .72rem; border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; color: var(--muted); }
.missing { color: var(--warn); font-size: .85rem; }

.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.back { background: transparent; color: var(--ink); padding: 8px 0; min-height: 40px; }
button.compact { min-height: 36px; padding: 6px 10px; font-size: .85rem; }

/* Step 2: Pick it, the draft, the saved bill. */
.spread { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.wide { width: 100%; margin: 10px 0; }
.tap { cursor: pointer; }
.list li.tap:active { background: var(--soft); }
.list li.flag { border-color: var(--warn); }
.draft-note { display: grid; gap: 10px; margin-bottom: 14px; border-color: var(--brand); }
.totals { display: grid; gap: 4px; margin-top: 12px; }
.totals .big { font-size: 1.2rem; }
.field-label { font-weight: 600; margin-bottom: 6px; }
.item-title { font-size: 1.2rem; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: transparent; color: var(--ink); border: 1px solid var(--line); min-height: 44px; }
.chip[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
details input { margin-top: 8px; }
summary { cursor: pointer; padding: 6px 0; }
.strip { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin: 10px 0 14px; }
.strip canvas { display: block; width: 100%; height: auto; }
button small { font-weight: 500; font-size: .75rem; opacity: .85; }

/* Step 3: workers' Packing Lists. Big tick boxes and names for packing with full hands. */
.pack-state { display: flex; align-items: flex-start; gap: 8px; margin-top: 4px; }
.pack-state > b { font-size: 1.15rem; line-height: 1.2; }
.pack-card.done { border-color: var(--brand); background: var(--soft); }
.pack-card.cancelled .name { text-decoration: line-through; color: var(--muted); }
.pack-card.cancelled .pack-state { color: var(--warn); }
.pack-lines li { padding: 0; }
.pack-lines li.done { background: var(--soft); }
.pack-line { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 12px 14px; cursor: pointer; }
.pack-line input { width: 30px; height: 30px; margin: 0; accent-color: var(--brand); }
.pack-line .what { display: grid; gap: 2px; }
.pack-line .what .zh { font-size: 1.2rem; font-weight: 600; }
.pack-line .what .ms { color: var(--ink); }
.pack-lines li.done .what .zh, .pack-lines li.done .what .ms { text-decoration: line-through; text-decoration-color: var(--muted); }
.pack-line .qty { font-size: 1.5rem; font-weight: 700; text-align: right; display: grid; line-height: 1.1; }
.pack-line .qty small { font-size: .75rem; font-weight: 500; color: var(--muted); }
.notify-card { margin-bottom: 14px; border-color: var(--brand); }
.banner {
  position: fixed; left: 12px; right: 12px; top: calc(env(safe-area-inset-top) + 10px); z-index: 10;
  max-width: 536px; margin: 0 auto; box-shadow: 0 6px 24px rgb(0 0 0 / .25);
}

/* Step 4: Say it. One big button to hold while speaking; the AI's doubts marked in colour. */
.record {
  width: 100%; min-height: 200px; margin: 18px 0 10px; border-radius: 28px; flex-direction: column; gap: 10px;
  font-size: 1.25rem; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.record .rec-dot { width: 22px; height: 22px; border-radius: 50%; background: currentColor; opacity: .6; }
.record.on { background: var(--rec); color: #fff; }
.record.on .rec-dot { opacity: 1; animation: pulse 1s ease-in-out infinite; }
.rec-time { font-variant-numeric: tabular-nums; font-size: 1.4rem; min-height: 1.4em; }
@keyframes pulse { 50% { transform: scale(.7); opacity: .6; } }
.take { margin: 18px 0 4px; }
.reading { text-align: center; padding: 64px 16px; display: grid; justify-items: center; gap: 8px; }
.reading .big { font-size: 1.2rem; font-weight: 600; }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--brand); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .record.on .rec-dot, .spinner { animation: none; } }
.doubt { color: var(--warn); background: var(--warn-soft); border-radius: 8px; padding: 4px 8px; margin-top: 6px; }
.card.flag { border-color: var(--warn); }
.learn {
  display: flex; gap: 8px; align-items: center; margin-top: 8px; padding: 8px 10px; border-radius: 10px;
  background: var(--soft); cursor: pointer;
}
.learn input { width: 22px; height: 22px; margin: 0; flex: none; accent-color: var(--brand); }
.ai-note { margin-top: 10px; border-color: var(--warn); }
.heard { margin: 4px 0 8px; }
.heard p { white-space: pre-wrap; }

/* The user's own sign-in: switch between the owner's, the accounts person's and a worker's view. */
.view-bar { display: grid; gap: 6px; margin: 0 0 12px; padding: 8px 10px; border: 1px dashed var(--line); border-radius: 12px; }
.view-bar.previewing { border: 2px solid var(--warn); background: var(--warn-soft); color: var(--warn); }
.view-bar .chips { gap: 6px; }
.view-bar .chip { flex: 1; min-height: 44px; padding: 6px 8px; }
