/* CityCycle Kho — giao diện dùng một tay, trong kho, có thể đeo găng.
   Nguyên tắc: nút to, tương phản cao, không có thao tác nào cần chính xác. */

:root {
  --blue:#0033CC; --blue-d:#00259a;
  --ink:#111418; --muted:#5a6472; --line:#d8dce2;
  --bg:#f4f6f8; --card:#fff;
  --ok:#0a7d33; --warn:#b45309; --err:#b3261e;
  --tap:52px;                       /* chiều cao chạm tối thiểu */
}

* { box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
html,body { margin:0; height:100%; }
body {
  font:16px/1.45 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
  background:var(--bg); color:var(--ink);
  overscroll-behavior-y:contain;
}
button,input,select { font:inherit; color:inherit; }

/* ── khung ────────────────────────────────────────────────────────────── */
.app { display:flex; flex-direction:column; min-height:100%; }
header {
  background:var(--blue); color:#fff; padding:10px 14px;
  display:flex; align-items:center; gap:10px;
  position:sticky; top:0; z-index:20;
  padding-top:calc(10px + env(safe-area-inset-top));
}
header h1 { font-size:16px; margin:0; font-weight:600; letter-spacing:.02em; flex:1; }
header .who { font-size:12px; opacity:.85; text-align:right; line-height:1.2; }

main { flex:1; padding:12px; padding-bottom:calc(12px + env(safe-area-inset-bottom)); }
.card {
  background:var(--card); border:1px solid var(--line); border-radius:12px;
  padding:14px; margin-bottom:12px;
}
.card h2 { font-size:14px; margin:0 0 10px; color:var(--muted); font-weight:600;
  text-transform:uppercase; letter-spacing:.06em; }

/* ── nút ──────────────────────────────────────────────────────────────── */
.btn {
  display:flex; align-items:center; justify-content:center; gap:8px;
  width:100%; min-height:var(--tap); padding:0 16px;
  border:1px solid var(--line); border-radius:10px; background:#fff;
  font-weight:600; cursor:pointer;
}
.btn:active { transform:translateY(1px); }
.btn.primary { background:var(--blue); border-color:var(--blue); color:#fff; }
.btn.primary:disabled { background:#9aa6bd; border-color:#9aa6bd; }
.btn.ghost { background:transparent; }
.btn.danger { color:var(--err); border-color:#f0c8c5; }
.btn.sm { min-height:40px; font-size:14px; width:auto; padding:0 12px; }
.row { display:flex; gap:8px; }
.row > * { flex:1; }

/* ── trạng thái mạng / hàng đợi ───────────────────────────────────────── */
/* iOS không có Background Sync: hàng đợi chỉ chạy khi app đang mở.
   Badge này phải BÁM DÍNH và khó chịu, nếu không toa sẽ nằm im cả ngày. */
.badge-queue {
  position:sticky; top:0; z-index:30;
  background:#fde68a; color:#7c2d12; border-bottom:1px solid #f59e0b;
  padding:10px 14px; font-size:14px; font-weight:600;
  display:flex; align-items:center; justify-content:space-between; gap:10px;
}
.badge-queue[hidden] { display:none; }
.badge-queue button { background:#7c2d12; color:#fff; border:0; border-radius:8px;
  padding:8px 12px; font-weight:600; cursor:pointer; }

.offline-dot { width:8px; height:8px; border-radius:50%; background:#22c55e; flex:none; }
.offline-dot.off { background:#ef4444; }

/* ── quét ─────────────────────────────────────────────────────────────── */
#reader { width:100%; border-radius:12px; overflow:hidden; background:#000; }
#reader video { width:100% !important; height:auto !important; display:block; }

.manual { display:flex; gap:8px; margin-top:10px; }
.manual input {
  flex:1; min-height:var(--tap); padding:0 12px; border:1px solid var(--line);
  border-radius:10px; background:#fff; text-transform:uppercase;
  font-family:ui-monospace,SFMono-Regular,Menlo,monospace; letter-spacing:.06em;
}

/* ── chọn màu ─────────────────────────────────────────────────────────── */
.colors { display:grid; gap:8px; }
.color-btn {
  display:flex; align-items:center; justify-content:space-between;
  min-height:var(--tap); padding:0 14px; border:2px solid var(--line);
  border-radius:10px; background:#fff; cursor:pointer; text-align:left;
}
.color-btn b { font-size:17px; }          /* màu là chốt chặn — phải to */
.color-btn span { color:var(--muted); font-size:13px; }

/* ── nhập số lượng ────────────────────────────────────────────────────── */
.sizes { display:grid; grid-template-columns:repeat(auto-fit,minmax(70px,1fr)); gap:10px; }
.size-cell { text-align:center; }
.size-cell label { display:block; font-weight:700; margin-bottom:6px; font-size:15px; }
.size-cell input {
  width:100%; min-height:56px; text-align:center; font-size:22px; font-weight:600;
  border:1px solid var(--line); border-radius:10px; background:#fff;
}
.size-cell input:focus { outline:2px solid var(--blue); border-color:var(--blue); }

/* ── danh sách dòng trong toa ─────────────────────────────────────────── */
.lines { display:grid; gap:8px; }
.line {
  display:flex; align-items:center; gap:10px; padding:10px 12px;
  border:1px solid var(--line); border-radius:10px; background:#fff;
}
.line .info { flex:1; min-width:0; }
.line .info b { display:block; font-size:14px; }
.line .info small { color:var(--muted); font-family:ui-monospace,Menlo,monospace; }
.line .qty { font-weight:700; white-space:nowrap; font-size:15px; }

.total { display:flex; justify-content:space-between; align-items:baseline;
  padding:12px 4px 4px; font-size:15px; }
.total b { font-size:22px; }

/* ── thông báo ────────────────────────────────────────────────────────── */
.msg { padding:12px 14px; border-radius:10px; margin-bottom:12px; font-size:14px; }
.msg.err  { background:#fde8e6; color:#7f1d1d; border:1px solid #f3bfba; }
.msg.ok   { background:#dcfce7; color:#14532d; border:1px solid #a7f3c1; }
.msg.warn { background:#fef3c7; color:#78350f; border:1px solid #fcd34d; }
.msg[hidden] { display:none; }

.hint { color:var(--muted); font-size:13px; margin-top:8px; }
.center { text-align:center; }
[hidden] { display:none !important; }

/* ── màn hình thành công ──────────────────────────────────────────────── */
.done-toa { font-size:34px; font-weight:700; color:var(--blue); text-align:center; margin:6px 0 2px; }
.done-sub { text-align:center; color:var(--muted); margin-bottom:16px; }
#toaCanvas { width:100%; border:1px solid var(--line); border-radius:10px; }

/* ── trạng thái gửi: "đã lên sheet" vs "chờ gửi" phải nhìn khác hẳn ───── */
.state { font-size:13px; font-weight:700; padding:3px 9px; border-radius:999px; }
.state.sent    { background:#dcfce7; color:#14532d; }
.state.pending { background:#fef3c7; color:#78350f; }

/* ── Bàn phím PIN ────────────────────────────────────────────────────────
   Phím to, cách nhau rõ: nhân viên kho hay đeo găng hoặc tay ẩm. */
.pin-dots { display:flex; justify-content:center; gap:14px; margin:6px 0 18px; }
.pin-dots i {
  width:16px; height:16px; border-radius:50%;
  border:2px solid var(--line); background:#fff; display:block;
}
.pin-dots i.on { background:var(--blue); border-color:var(--blue); }

.pinpad { display:grid; grid-template-columns:repeat(3,1fr); gap:10px; }
.pinpad button {
  min-height:64px; font-size:24px; font-weight:600;
  border:1px solid var(--line); border-radius:12px; background:#fff; cursor:pointer;
}
.pinpad button:active { background:#eef1f5; transform:translateY(1px); }
.pinpad button.wide { grid-column:span 1; font-size:15px; font-weight:600; }
