:root {
  --bg: #0f172a;
  --bg-2: #1e293b;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --line: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #0891b2;
  --accent-2: #22d3ee;
  --ok: #16a34a;
  --ok-bg: #dcfce7;
  --warn: #d97706;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .12), 0 8px 24px rgba(15, 23, 42, .06);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Meiryo", sans-serif;
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
#app { max-width: 760px; margin: 0 auto; min-height: 100vh; }

/* ---------- Header ---------- */
.appbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg);
  color: #fff;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,.18);
}
.appbar .title { font-weight: 700; font-size: 17px; letter-spacing: .02em; }
.appbar .spacer { flex: 1; }
.appbar button {
  background: rgba(255,255,255,.12); color: #fff; border: none;
  padding: 8px 12px; border-radius: 10px; font-size: 14px; font-weight: 600;
}
.appbar .back { background: transparent; padding: 8px; font-size: 20px; line-height: 1; }

/* ---------- Bottom nav ---------- */
.tabbar {
  position: sticky; bottom: 0; z-index: 20;
  display: flex; background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-bottom);
}
.tabbar a {
  flex: 1; text-align: center; padding: 9px 4px; text-decoration: none;
  color: var(--muted); font-size: 11px; font-weight: 600;
}
.tabbar a .ico { display: block; font-size: 21px; line-height: 1.2; }
.tabbar a.active { color: var(--accent); }

/* ---------- Content ---------- */
.content { padding: 14px 14px 90px; }
.page-title { font-size: 20px; font-weight: 800; margin: 4px 2px 14px; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; margin-bottom: 12px;
}
.card.tap { cursor: pointer; transition: transform .05s; }
.card.tap:active { transform: scale(.99); }

.rec-row { display: flex; align-items: center; gap: 12px; }
.rec-main { flex: 1; min-width: 0; }
.rec-title { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.rec-thumb { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; background: var(--surface-2); flex-shrink: 0; }

/* ---------- Badges / chips ---------- */
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700;
  padding: 3px 9px; border-radius: 999px; }
.chip.rotary { background: #e0f2fe; color: #0369a1; }
.chip.pillow { background: #ede9fe; color: #6d28d9; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: #fef3c7; color: var(--warn); }
.chip.open { background: #f1f5f9; color: var(--muted); }
.chip.done { background: var(--ok-bg); color: var(--ok); }

/* ---------- Forms ---------- */
.field { margin-bottom: 13px; }
.field > label { display: block; font-size: 13px; font-weight: 700; color: #334155; margin-bottom: 5px; }
.field .hint { font-weight: 500; color: var(--muted); font-size: 12px; }
input[type=text], input[type=date], input[type=time], input[type=number],
input[type=password], input[type=email], select, textarea {
  width: 100%; padding: 12px; font-size: 16px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; color: var(--text); font-family: inherit;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-2); border-color: var(--accent); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

.section-h { font-size: 13px; font-weight: 800; color: var(--accent); text-transform: none;
  margin: 18px 2px 8px; letter-spacing: .03em; display: flex; align-items: center; gap: 6px; }
.section-h::before { content: ""; width: 4px; height: 15px; background: var(--accent); border-radius: 2px; }

/* check list */
.checkline { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px dashed var(--line); }
.checkline:last-child { border-bottom: none; }
.checkline label { flex: 1; font-size: 14px; }
.checkline input[type=checkbox] { width: 24px; height: 24px; accent-color: var(--accent); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  width: 100%; padding: 14px; font-size: 16px; font-weight: 700; border: none;
  border-radius: 12px; background: var(--accent); color: #fff; cursor: pointer;
}
.btn:active { filter: brightness(.95); }
.btn.secondary { background: var(--surface); color: var(--accent); border: 1.5px solid var(--accent); }
.btn.ghost { background: var(--surface-2); color: var(--text); }
.btn.danger { background: var(--danger); }
.btn.sm { width: auto; padding: 9px 14px; font-size: 14px; }
.btn:disabled { opacity: .55; }
.btn-row { display: flex; gap: 10px; margin-top: 14px; }
.btn-row .btn { width: auto; flex: 1; }

.fab {
  position: fixed; right: 18px; bottom: calc(72px + var(--safe-bottom)); z-index: 25;
  width: 60px; height: 60px; border-radius: 50%; background: var(--accent);
  color: #fff; font-size: 30px; border: none; box-shadow: 0 6px 20px rgba(8,145,178,.45);
  display: flex; align-items: center; justify-content: center;
}

/* ---------- Photo / lot check ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photo-cell {
  position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
}
.photo-cell img { width: 100%; height: 100%; object-fit: cover; }
.photo-cell .rm { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,.6); color: #fff;
  border: none; border-radius: 50%; width: 24px; height: 24px; font-size: 14px; }
.photo-cell .kind { position: absolute; bottom: 0; left: 0; right: 0; background: rgba(0,0,0,.55);
  color: #fff; font-size: 10px; text-align: center; padding: 2px; }
.photo-add { border: 2px dashed var(--accent); color: var(--accent); font-size: 13px; font-weight: 700;
  display: flex; flex-direction: column; gap: 4px; }
.photo-add .ico { font-size: 26px; }

.lotcheck { background: #ecfeff; border: 1.5px solid var(--accent-2); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; }
.lotcheck .lc-title { font-weight: 800; color: var(--accent); margin-bottom: 8px; display:flex; align-items:center; gap:6px; }
.lc-pair { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px dashed #a5f3fc; font-size: 14px; }
.lc-pair:last-of-type { border-bottom: none; }
.lc-fac { font-size: 12px; font-weight: 800; background: var(--accent); color: #fff; padding: 2px 9px; border-radius: 999px; margin-left: 6px; }
.lc-big { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #fff;
  border: 2px solid var(--accent); border-radius: 12px; padding: 10px 14px; margin-bottom: 10px; }
.lc-big .lbl { color: var(--muted); font-weight: 700; font-size: 14px; }
.lc-big .big { font-size: 30px; font-weight: 900; color: var(--accent); letter-spacing: .02em; }

/* ロット整合性：確認カード（写真＋正しい値＋チェック） */
.verify-card { display: flex; gap: 12px; align-items: stretch; background: #fff;
  border: 1.5px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 10px; }
.verify-card.done { border-color: var(--ok); background: #f0fdf4; }
.verify-photo { width: 84px; flex-shrink: 0; }
.verify-photo .photo-cell { width: 84px; height: 84px; }
.verify-info { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.verify-label { font-size: 12px; color: var(--muted); font-weight: 700; }
.verify-sub { font-size: 10px; background: var(--surface-2); color: var(--muted); padding: 1px 6px; border-radius: 999px; margin-left: 4px; }
.verify-expected { font-size: 22px; font-weight: 900; color: var(--accent); line-height: 1.25; margin: 2px 0 6px;
  word-break: break-word; }
.verify-check { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; }
.verify-check input { width: 24px; height: 24px; accent-color: var(--ok); flex-shrink: 0; }
.verify-card.done .verify-check { color: var(--ok); }
/* 確認不要（固有記号なし等） */
.verify-card.skip { background: #eff6ff; border-color: #93c5fd; border-style: dashed; }
.verify-card.skip .verify-label { color: #1d4ed8; }
.verify-skip-note { font-size: 13px; color: #1e40af; font-weight: 600; line-height: 1.5; margin-top: 4px; }
.verify-skip-mark { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  background: #dbeafe; border-radius: 10px; color: #60a5fa; font-size: 30px; font-weight: 800; }
.verify-card.skip .verify-photo .photo-cell,
.verify-card.skip .verify-skip-mark { border: 1px dashed #93c5fd; }
.lc-pair .lbl { color: var(--muted); font-weight: 600; }
.lc-pair .val { font-weight: 800; text-align: right; }
.lc-confirm { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 10px; background: #fff; border-radius: 10px; }
.lc-confirm input { width: 26px; height: 26px; accent-color: var(--ok); }
.lc-confirm label { font-weight: 700; }

/* ---------- Misc ---------- */
.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 50px 20px; }
.empty .big { font-size: 46px; margin-bottom: 10px; }
.list-head { display: flex; align-items: center; gap: 8px; margin: 4px 2px 10px; }
.list-head .grow { flex: 1; }
.seg { display: flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { border: none; background: transparent; padding: 8px 12px; border-radius: 8px; font-weight: 700; font-size: 13px; color: var(--muted); }
.seg button.on { background: #fff; color: var(--accent); box-shadow: var(--shadow); }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--muted); font-weight: 600; flex-shrink: 0; }
.kv .v { font-weight: 600; text-align: right; }

/* login */
.login-wrap { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 24px; background: var(--bg); color: #fff; }
.login-card { background: var(--surface); color: var(--text); border-radius: 18px; padding: 26px; width: 100%; max-width: 380px; box-shadow: var(--shadow); }
.login-logo { width: 64px; height: 64px; margin: 0 auto 14px; display: block; }
.login-card h1 { font-size: 20px; text-align: center; margin: 0 0 4px; }
.login-card p.sub { text-align: center; color: var(--muted); margin: 0 0 20px; font-size: 14px; }

.toast {
  position: fixed; left: 50%; bottom: calc(96px + var(--safe-bottom)); transform: translateX(-50%);
  background: #0f172a; color: #fff; padding: 12px 18px; border-radius: 999px; font-size: 14px;
  font-weight: 600; z-index: 50; box-shadow: 0 8px 24px rgba(0,0,0,.3); max-width: 90%;
}
.toast.err { background: var(--danger); }
.toast.ok { background: var(--ok); }

.loading { display: flex; align-items: center; justify-content: center; padding: 50px; color: var(--muted); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.banner { background: #fef3c7; color: #92400e; padding: 9px 14px; font-size: 13px; text-align: center; font-weight: 600; }

.req::after { content: " *"; color: var(--danger); }

/* ---------- アプリ内カメラ ---------- */
.cam-ov { position: fixed; inset: 0; background: #000; z-index: 80; display: flex; flex-direction: column; }
.cam-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0; }
.cam-msg { position: absolute; inset: 0; z-index: 1; display: flex; align-items: center; justify-content: center;
  text-align: center; color: #fff; padding: 30px; font-size: 15px; font-weight: 600; line-height: 1.9;
  background: rgba(0,0,0,.65); pointer-events: none; }
.cam-top { position: relative; z-index: 2; display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: calc(12px + var(--safe-top)) 14px 12px;
  background: linear-gradient(to bottom, rgba(0,0,0,.55), transparent); }
.cam-hint { flex: 1; text-align: center; color: #fff; font-size: 13px; font-weight: 700; text-shadow: 0 1px 4px rgba(0,0,0,.9); }
.cam-btn { width: 44px; height: 44px; flex-shrink: 0; border: none; border-radius: 50%;
  background: rgba(0,0,0,.45); color: #fff; font-size: 21px; }
.cam-bottom { position: relative; z-index: 4; margin-top: auto; display: flex; align-items: center;
  justify-content: space-between; padding: 22px 30px calc(30px + var(--safe-bottom));
  background: linear-gradient(to top, rgba(0,0,0,.55), transparent); }
.cam-shutter { width: 76px; height: 76px; border-radius: 50%; background: #fff;
  border: 5px solid rgba(255,255,255,.5); box-shadow: 0 0 0 2px rgba(0,0,0,.2); }
.cam-shutter:active { transform: scale(.93); }
.cam-album { width: 48px; height: 48px; flex-shrink: 0; border-radius: 12px; background: rgba(255,255,255,.22);
  color: #fff; font-size: 24px; display: flex; align-items: center; justify-content: center; }
