:root {
  --bg: #eef1f8;
  --grad-1: #2563eb;
  --grad-2: #4f46e5;
  --panel: #ffffff;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #e6e9f0;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --ok: #16a34a;
  --ok-bg: #dcfce7;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --err: #dc2626;
  --err-bg: #fee2e2;
  --shadow: 0 1px 3px rgba(15,23,42,.06), 0 8px 24px rgba(15,23,42,.07);
  --radius: 14px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.5;
  padding-bottom: 96px;
}

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px;
  background: linear-gradient(120deg, var(--grad-1), var(--grad-2));
  color: #fff; box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  font-size: 24px; width: 44px; height: 44px; border-radius: 12px;
  background: rgba(255,255,255,.18); display: grid; place-items: center;
}
.topbar h1 { font-size: 19px; margin: 0; font-weight: 700; letter-spacing: -.2px; }
.brand-sub { margin: 1px 0 0; font-size: 12.5px; color: rgba(255,255,255,.85); }

main { max-width: 680px; margin: 0 auto; padding: 14px 14px 20px; }

/* date + search */
.datebar { display: flex; align-items: center; gap: 10px; margin: 4px 2px 12px; }
.datebar label { font-weight: 600; color: var(--muted); font-size: 14px; }
.searchbar { position: sticky; top: 72px; z-index: 15; margin-bottom: 12px; }
input[type=date], input[type=search] {
  width: 100%; padding: 12px 14px; font-size: 16px; color: var(--ink);
  border: 1px solid var(--line); border-radius: 12px; background: #fff;
  box-shadow: var(--shadow); outline: none;
}
input[type=date] { width: auto; flex: 1; }
input:focus { border-color: var(--brand); }

/* category + item list */
.cat { margin-bottom: 14px; }
.cat-head {
  font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); padding: 6px 4px; position: sticky; top: 130px; background: var(--bg);
}
.item {
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; margin-bottom: 8px; box-shadow: var(--shadow);
}
.item.active { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(37,99,235,.15), var(--shadow); }
.item-info { min-width: 0; }
.item-name { font-weight: 600; font-size: 15px; white-space: normal; }
.item-stock { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.item-stock.low { color: var(--warn); }
.item-stock.zero { color: var(--err); }

/* qty stepper */
.stepper { display: flex; align-items: center; gap: 8px; flex: none; }
.step {
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; font-size: 22px; line-height: 1; color: var(--brand);
  display: grid; place-items: center; cursor: pointer; user-select: none;
}
.step:active { background: #eef2ff; }
.step[disabled] { color: #cbd5e1; cursor: default; }
.qty {
  width: 52px; text-align: center; font-size: 17px; font-weight: 700;
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 4px; background: #fff;
}

/* sticky submit bar */
.submitbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: #fff; border-top: 1px solid var(--line);
  box-shadow: 0 -6px 24px rgba(15,23,42,.08);
}
.submitbar .summary { font-size: 14px; color: var(--muted); }
.submitbar .summary strong { color: var(--ink); font-size: 16px; }

/* buttons */
.btn {
  appearance: none; border: 1px solid var(--line); background: #fff; color: var(--ink);
  font-size: 15px; font-weight: 600; padding: 12px 18px; border-radius: 12px;
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 8px;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:disabled { opacity: .55; cursor: default; }
.btn-lg { padding: 14px 20px; font-size: 16px; width: 100%; justify-content: center; }
.btn.ghost { background: rgba(255,255,255,.16); color: #fff; border-color: rgba(255,255,255,.3); }

/* confirmation */
.done-card {
  background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 26px 22px; text-align: center; margin-top: 20px;
}
.done-tick {
  width: 66px; height: 66px; border-radius: 50%; margin: 0 auto 12px;
  background: var(--ok-bg); color: var(--ok); font-size: 34px; display: grid; place-items: center;
}
.done-card h2 { margin: 0 0 4px; }
.status { list-style: none; padding: 0; margin: 16px 0; text-align: left; }
.status li { padding: 8px 12px; border-radius: 10px; margin-bottom: 6px; font-size: 14px; background: #f8fafc; }
.status li.ok { background: var(--ok-bg); color: #14532d; }
.status li.warn { background: var(--warn-bg); color: #7c2d12; }
.done-actions { display: flex; gap: 10px; justify-content: center; margin-top: 8px; flex-wrap: wrap; }

.loading { color: var(--muted); text-align: center; padding: 40px 0; }
.muted { color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 30px 0; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 108px; transform: translateX(-50%);
  background: #111827; color: #fff; padding: 10px 16px; border-radius: 10px;
  font-size: 14px; z-index: 50; box-shadow: var(--shadow); max-width: 90%;
}

/* login (shared with backend page) */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 20px;
  background: linear-gradient(120deg, var(--grad-1), var(--grad-2)); }
.login-card {
  background: #fff; border-radius: 18px; padding: 30px 26px; width: 100%; max-width: 340px;
  text-align: center; box-shadow: 0 20px 50px rgba(0,0,0,.25); display: flex; flex-direction: column; gap: 12px;
}
.login-logo { font-size: 40px; }
.login-card h1 { margin: 0; font-size: 22px; }
.login-card input { padding: 12px 14px; font-size: 16px; border: 1px solid var(--line); border-radius: 12px; }
.err { color: var(--err); font-size: 13px; margin: 0; }
