:root {
  --navy: #13213c; --navy-2: #1e3157; --gold: #b89652; --bg: #f4f3ef; --card: #ffffff;
  --ink: #1a1d24; --muted: #646a76; --line: #e2e0d9;
  --ok: #2f7d4f; --ok-bg: #e3f1e8; --warn: #a76a00; --warn-bg: #fbf0d9; --bad: #b3261e; --bad-bg: #f9e3e1;
  --info: #2b5797; --info-bg: #e3ebf7; --idle: #6b6f78; --idle-bg: #ecebe7;
  --r: 10px; --pad: 16px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
a { color: var(--info); }

#top { position: sticky; top: 0; z-index: 10; background: var(--navy); color: #fff; padding: calc(10px + env(safe-area-inset-top)) var(--pad) 10px; display: flex; align-items: center; gap: 10px; }
#top .brand { font-weight: 700; letter-spacing: .02em; flex: 1; min-width: 0; }
#top .brand small { display: block; font-weight: 400; color: #c9cfdb; font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#top .brand span { color: var(--gold); }
.sync { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; background: var(--navy-2); border: 0; color: #fff; padding: 6px 10px; border-radius: 99px; cursor: pointer; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #4cc27a; }
.dot.off { background: #e0a030; }
.iconbtn { background: none; border: 0; color: #c9cfdb; font-size: .8rem; cursor: pointer; padding: 6px; }

main { max-width: 860px; margin: 0 auto; padding: var(--pad); }
.loading { padding: 40px; text-align: center; color: var(--muted); }

#nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; background: #fff; border-top: 1px solid var(--line); display: flex; padding-bottom: env(safe-area-inset-bottom); }
#nav a { flex: 1; text-align: center; padding: 10px 4px 9px; text-decoration: none; color: var(--muted); font-size: .78rem; font-weight: 600; border-top: 3px solid transparent; }
#nav a .ic { display: block; font-size: 1.15rem; line-height: 1.2; }
#nav a.on { color: var(--navy); border-top-color: var(--gold); }
#nav a .badge { background: var(--bad); color: #fff; border-radius: 99px; padding: 0 6px; font-size: .7rem; margin-left: 2px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-bottom: 12px; }
.card.tap { cursor: pointer; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .tiny { font-size: .75rem; }
.sec { margin: 22px 0 10px; display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.sec h2 { font-size: 1rem; text-transform: uppercase; letter-spacing: .06em; color: var(--navy); }
.num { font-variant-numeric: tabular-nums; }
.big { font-size: 2rem; font-weight: 700; line-height: 1; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .75rem; font-weight: 600; white-space: nowrap; }
.p-ok, .p-approved, .p-incentive, .p-pass { background: var(--ok-bg); color: var(--ok); }
.p-risk, .p-rejected, .p-penalty, .p-fail { background: var(--bad-bg); color: var(--bad); }
.p-low, .p-pending, .p-neutral { background: var(--warn-bg); color: var(--warn); }
.p-idle, .p-none { background: var(--idle-bg); color: var(--idle); }
.p-info { background: var(--info-bg); color: var(--info); }

.bar { height: 10px; background: var(--idle-bg); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--navy); border-radius: 99px; }
.bar.gold > i { background: var(--gold); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 10px 16px; border-radius: 8px; border: 1px solid var(--navy); background: var(--navy); color: #fff; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn.ghost { background: #fff; color: var(--navy); }
.btn.ok { background: var(--ok); border-color: var(--ok); }
.btn.bad { background: var(--bad); border-color: var(--bad); }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: .85rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.btns .btn { flex: 1; }

label.f { display: block; margin-bottom: 12px; font-weight: 600; font-size: .9rem; }
label.f > span { display: block; margin-bottom: 4px; }
input[type=text], input[type=number], input[type=date], input[type=password], input[type=month], input[type=tel], select, textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid #cfccc3; border-radius: 8px; background: #fff; font-weight: 400; }
textarea { min-height: 80px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: 0; border-color: var(--gold); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.seg { display: flex; border: 1px solid var(--navy); border-radius: 8px; overflow: hidden; }
.seg button { flex: 1; min-height: 44px; border: 0; background: #fff; color: var(--navy); font-weight: 600; cursor: pointer; border-right: 1px solid var(--navy); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--navy); color: #fff; }
.seg.pf button.on.pass { background: var(--ok); } .seg.pf button.on.fail { background: var(--bad); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid #cfccc3; background: #fff; border-radius: 99px; padding: 8px 12px; font-size: .85rem; cursor: pointer; }
.chip.on { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); font-weight: 600; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 10px; }
.stat b { display: block; font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.stat span { font-size: .75rem; color: var(--muted); }

.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.thumbs img, .thumbs .add { width: 76px; height: 76px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: #eee; }
.thumbs .add { display: grid; place-items: center; font-size: 1.6rem; color: var(--navy); cursor: pointer; border-style: dashed; }
.thumbs .t { position: relative; }
.thumbs .t button { position: absolute; top: -6px; right: -6px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: var(--bad); color: #fff; font-size: .8rem; cursor: pointer; }

table.t { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.t th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 8px 6px; border-bottom: 1px solid var(--line); }
table.t td { padding: 9px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t td.r, table.t th.r { text-align: right; }
.scroll { overflow-x: auto; }

.chart { width: 100%; height: auto; display: block; }
.note { background: var(--info-bg); color: #233d66; border-radius: 8px; padding: 10px 12px; font-size: .85rem; margin-bottom: 12px; }
.note.warn { background: var(--warn-bg); color: #6b4500; }
.empty { text-align: center; color: var(--muted); padding: 24px 10px; }

#toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; font-size: .9rem; max-width: calc(100% - 32px); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 30; }
#toast.on { opacity: 1; }
#modal { position: fixed; inset: 0; z-index: 20; background: rgba(10, 16, 30, .55); display: flex; align-items: flex-end; justify-content: center; }
#modal[hidden] { display: none; }
#modal .sheet { background: var(--bg); width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; border-radius: 14px 14px 0 0; padding: var(--pad); padding-bottom: calc(var(--pad) + env(safe-area-inset-bottom)); }
#modal .sheet .head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
#modal .x { background: none; border: 0; font-size: 1.5rem; cursor: pointer; color: var(--muted); }
#modal img.full { width: 100%; border-radius: 8px; }
@media (min-width: 700px) { #modal { align-items: center; } #modal .sheet { border-radius: 14px; } }

.login { max-width: 380px; margin: 8vh auto 0; }
.login h1 { color: var(--navy); margin-bottom: 4px; }
.login .rule { height: 3px; width: 48px; background: var(--gold); margin: 10px 0 22px; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tabs a { padding: 8px 14px; border-radius: 99px; text-decoration: none; color: var(--navy); background: #fff; border: 1px solid var(--line); font-size: .85rem; font-weight: 600; }
.tabs a.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.qcsteps { display: flex; gap: 6px; flex-wrap: wrap; }
@media (max-width: 420px) { .stats { grid-template-columns: repeat(3, 1fr); } .stat b { font-size: 1.15rem; } .grid2 { grid-template-columns: 1fr; } }
.sizegrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; margin-bottom: 12px; }
.sizegrid label { display: block; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 6px; text-align: center; }
.sizegrid span { display: block; font-weight: 700; font-size: .85rem; color: var(--navy); }
.sizegrid input { min-height: 40px; text-align: center; padding: 6px; }
.sizegrid small { display: block; font-size: .7rem; color: var(--muted); }
table.sz td, table.sz th { padding: 4px 6px; white-space: nowrap; }
