/* Fiolino Intake — phone-first */
:root {
  --green: #1e3a2f;
  --green-mid: #2e5744;
  --accent: #c98a2b;
  --bg: #f6f4ef;
  --card: #ffffff;
  --ink: #21272b;
  --muted: #6b7680;
  --line: #e4e0d6;
  --good: #157347;
  --bad: #c0392b;
  --warn: #b7791f;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink);
  padding-bottom: calc(70px + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
}
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--green); color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
}
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 17px; letter-spacing: .02em; }
.brand span { color: var(--accent); }
.topbar-right { display: flex; gap: 6px; align-items: center; }
.role-badge, .env-badge {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  padding: 3px 8px; border-radius: 999px; font-weight: 700;
}
.role-badge { background: rgba(255,255,255,.18); color: #fff; }
.env-badge.env-sand { background: var(--accent); color: #fff; }
.env-badge.env-prod { background: var(--bad); color: #fff; }
.page { padding: 16px; max-width: 720px; margin: 0 auto; }

.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav a {
  flex: 1; text-align: center; padding: 8px 0 6px; text-decoration: none;
  color: var(--muted); font-size: 20px; line-height: 1.1;
}
.bottomnav a span { display: block; font-size: 10.5px; font-weight: 600; margin-top: 1px; }
.bottomnav a.active { color: var(--green); }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 12px;
}
.card h2 { margin: 0 0 8px; font-size: 15px; }
h1 { font-size: 20px; margin: 4px 0 14px; }
.sub { color: var(--muted); font-size: 13px; }

.btn {
  display: inline-block; border: 0; border-radius: 12px; cursor: pointer;
  background: var(--green); color: #fff; font-weight: 700; font-size: 15px;
  padding: 12px 18px; text-decoration: none; text-align: center;
}
.btn.block { display: block; width: 100%; }
.btn.secondary { background: #fff; color: var(--green); border: 1.5px solid var(--green-mid); }
.btn.warn { background: var(--bad); }
.btn.small { padding: 7px 12px; font-size: 13px; border-radius: 9px; }
.btn:disabled { opacity: .5; }

input[type=text], input[type=number], input[type=date], input[type=password], select, textarea {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px;
  font-size: 15px; background: #fff; color: var(--ink); font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--green-mid); border-color: transparent; }
label { display: block; font-size: 12.5px; font-weight: 700; color: var(--muted); margin: 10px 0 4px; text-transform: uppercase; letter-spacing: .04em; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; }
.pill.new { background: #fdf0e4; color: var(--warn); }
.pill.known { background: #e6f4ec; color: var(--good); }
.pill.up { background: #fdecea; color: var(--bad); }
.pill.down { background: #e6f4ec; color: var(--good); }
.pill.flat { background: #eef1f4; color: var(--muted); }
.pill.conf-low { background: #fdecea; color: var(--bad); }
.pill.conf-mid { background: #fdf0e4; color: var(--warn); }
.pill.create { background: #e6f0fa; color: #1d5c99; }
.pill.update { background: #efe9fb; color: #6237a8; }

.line-item { border-top: 1px solid var(--line); padding: 10px 0; }
.line-item:first-child { border-top: 0; }
.line-name { font-weight: 600; font-size: 14.5px; }
.line-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 4px; font-size: 13px; color: var(--muted); }
.delta-up { color: var(--bad); font-weight: 700; }
.delta-down { color: var(--good); font-weight: 700; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

.capture-tile {
  border: 2px dashed var(--line); border-radius: var(--radius); background: #fff;
  padding: 22px 10px; text-align: center; color: var(--muted); font-weight: 600;
  cursor: pointer; font-size: 14px;
}
.capture-tile.done { border-style: solid; border-color: var(--good); color: var(--good); }
.capture-tile img { max-width: 100%; max-height: 140px; border-radius: 8px; display: block; margin: 0 auto 8px; }

.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 50;
  background: var(--green); color: #fff; font-weight: 600; font-size: 14px;
  padding: 11px 18px 11px 14px; border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
  max-width: 88vw; display: flex; align-items: center; gap: 9px;
  transform: translate(-50%, 8px); opacity: 0;
  animation: toastIn .28s cubic-bezier(.2,.9,.3,1.2) forwards;
}
.toast::before { content: "✓"; font-size: 15px; flex: none;
  width: 22px; height: 22px; border-radius: 50%; background: rgba(255,255,255,.22);
  display: flex; align-items: center; justify-content: center; }
.toast.bad { background: var(--bad); }
.toast.bad::before { content: "✕"; }
.toast.leaving { animation: toastOut .2s ease forwards; }
@keyframes toastIn { to { transform: translate(-50%, 0); opacity: 1; } }
@keyframes toastOut { to { transform: translate(-50%, 8px); opacity: 0; } }

.spinner {
  width: 26px; height: 26px; border: 3px solid var(--line); border-top-color: var(--green);
  border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.progressbar { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
.progressbar > div { height: 100%; background: var(--green-mid); transition: width .4s; }

.stat-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)); gap: 8px; }
.stat-tile { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px; text-align: center; }
.stat-tile b { display: block; font-size: 22px; }
.stat-tile.alert b { color: var(--bad); }
.stat-tile.ok b { color: var(--good); }
.stat-tile small { color: var(--muted); font-size: 11px; font-weight: 600; }

.finding-group summary { font-weight: 700; padding: 10px 0; cursor: pointer; font-size: 14.5px; }
.finding-group li { font-size: 13.5px; margin: 5px 0; }
.finding-group a { color: var(--green-mid); }

table.mini { width: 100%; border-collapse: collapse; font-size: 13px; }
table.mini td, table.mini th { padding: 6px 8px; border-top: 1px solid var(--line); text-align: left; }
table.mini th { color: var(--muted); font-size: 11.5px; text-transform: uppercase; }

/* ---------- /scan: commercial polish ---------- */
.panel-anim { animation: panelIn .24s cubic-bezier(.2,.8,.3,1) both; }
@keyframes panelIn { from { opacity: 0; transform: translateY(14px) scale(.985); }
                     to { opacity: 1; transform: none; } }

.viewfinder {
  position: relative; border-radius: 16px; overflow: hidden; background: #0b0d0c;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.06);
}
.viewfinder video { width: 100%; max-height: 44vh; display: block; }
/* centered guide box: decode is restricted to this region (wide + short to
   match a barcode's shape), and it visually tells staff where to aim */
.vf-box { position: absolute; left: 10%; right: 10%; top: 27.5%; height: 45%;
  border-radius: 10px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.28); }
.vf-corner { position: absolute; width: 24px; height: 24px; border: 3px solid var(--accent);
  border-radius: 3px; opacity: .95; }
.vf-corner.tl { top: -2px; left: -2px; border-right: 0; border-bottom: 0; }
.vf-corner.tr { top: -2px; right: -2px; border-left: 0; border-bottom: 0; }
.vf-corner.bl { bottom: -2px; left: -2px; border-right: 0; border-top: 0; }
.vf-corner.br { bottom: -2px; right: -2px; border-left: 0; border-top: 0; }
.vf-line { position: absolute; left: 6%; right: 6%; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent) 20%, var(--accent) 80%, transparent);
  box-shadow: 0 0 14px var(--accent);
  animation: vfSweep 2.2s ease-in-out infinite; }
@keyframes vfSweep { 0%, 100% { top: 8%; } 50% { top: 90%; } }
.vf-msg { position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: center; color: #fff; font-weight: 600; text-align: center;
  padding: 20px; background: rgba(0,0,0,.45); cursor: pointer; }
.vf-badge { position: absolute; top: 8px; left: 8px; font-size: 10px; font-weight: 700;
  font-family: ui-monospace, Menlo, monospace; color: #fff; background: rgba(0,0,0,.6);
  padding: 3px 7px; border-radius: 6px; letter-spacing: .02em; }
#zoom-range { accent-color: var(--accent); }
/* active toggle (e.g. torch on) — wins over .btn.secondary via source order */
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }

.scan-card { border-radius: 18px; padding: 18px; }
.scan-name { font-size: 19px; font-weight: 750; line-height: 1.25; letter-spacing: -.01em; }
.scan-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center;
  margin-top: 7px; color: var(--muted); font-size: 13px; }
.price-row { display: flex; align-items: center; justify-content: center;
  gap: 14px; margin: 18px 0 4px; }
.price-hero { font-size: 48px; font-weight: 800; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; line-height: 1; cursor: pointer; }
.price-hero-input { font-size: 40px; font-weight: 800; text-align: center;
  max-width: 190px; font-variant-numeric: tabular-nums; }
.market-btn { flex: none; display: inline-flex; flex-direction: column; align-items: center;
  gap: 2px; text-decoration: none; color: var(--green-mid); font-size: 11px; font-weight: 700;
  padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--card); }
.market-btn b { font-size: 17px; line-height: 1; }
.success-pop { font-size: 52px; animation: pop .4s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes pop { from { transform: scale(.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* two-button photo slots (deterministic camera vs gallery) */
.photo-slot { margin-top: 12px; }
.photo-head { display: flex; justify-content: space-between; align-items: baseline; }
.photo-head label { margin: 0 0 4px; }
.photo-note { font-size: 12px; font-weight: 700; color: var(--good); }
.photo-note.pending { color: var(--muted); }
.photo-body { display: flex; gap: 10px; align-items: stretch; }
.photo-preview { flex: none; width: 60px; height: 60px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--card);
  display: flex; align-items: center; justify-content: center; font-size: 24px;
  color: var(--muted); overflow: hidden; }
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.photo-preview.done { border-color: var(--good); border-style: solid; }
.photo-btns { flex: 1; display: flex; gap: 8px; }
.photo-cam { flex: 2; padding: 12px 8px; }      /* camera is primary + bigger */
.photo-gal { flex: 1; padding: 12px 8px; font-size: 13px; }

.btn { transition: transform .08s ease, filter .12s ease; }
.btn:active { transform: scale(.965); filter: brightness(.92); }

/* ---------- dark mode (receiving door, bright/no light both) ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101311; --card: #191e1b; --ink: #e9e7df; --muted: #98a29a;
    --line: #2a312c; --green-mid: #57a37f;
  }
  .topbar { background: #0c1a13; }
  .bottomnav { background: #161a17; border-top-color: var(--line); }
  input[type=text], input[type=number], input[type=date], input[type=password], select, textarea {
    background: #10140f; color: var(--ink); border-color: var(--line); }
  .btn.secondary { background: transparent; color: var(--green-mid); }
  .capture-tile, .market-btn { background: #10140f; }
  .stat-tile, .photo-thumb { background: #10140f; }
  .pill.new { background: #3a2c17; } .pill.known { background: #17301f; color: #6fcb96; }
  .pill.up { background: #3a1d18; color: #e98474; } .pill.down { background: #17301f; color: #6fcb96; }
  .pill.flat { background: #22272a; } .pill.conf-mid { background: #3a2c17; }
  .pill.conf-low { background: #3a1d18; color: #e98474; }
  .pill.create { background: #16283a; color: #7cb7e8; } .pill.update { background: #291f3a; color: #b79ae8; }
}

.login-wrap { max-width: 340px; margin: 12vh auto 0; text-align: center; }
.login-wrap .brand-large { font-size: 26px; font-weight: 800; color: var(--green); margin-bottom: 24px; }
.login-wrap .brand-large span { color: var(--accent); }
.diff-row { display: flex; justify-content: space-between; font-size: 13.5px; padding: 3px 0; }
.diff-row .k { color: var(--muted); }
.photo-thumb { width: 54px; height: 54px; object-fit: cover; border-radius: 8px; }
