:root{
 --bg:#f3f3f3;--surface:#fff;--surface2:#fafafa;--text:#1a1a1a;--muted:#707070;
 --line:#e5e5e5;--primary:#0067c0;--primary2:#005a9e;--danger:#c42b1c;
 --dangerbg:#fff3f1;--hover:#f6f6f6;--radius:8px;
}
*{box-sizing:border-box}
html,body{margin:0;min-height:100%;background:var(--bg);color:var(--text);
font-family:"Segoe UI",system-ui,-apple-system,"Yu Gothic UI","Yu Gothic","Meiryo",sans-serif}
body{font-size:14px}
button,input{font:inherit}
button{min-height:36px;border:1px solid transparent;border-radius:6px;padding:0 13px;
display:inline-flex;align-items:center;justify-content:center;gap:7px;background:#fff;color:var(--text);
cursor:pointer;transition:.12s}
button:hover{background:var(--hover)}
button:active{background:#ededed}
button:focus-visible,input:focus-visible{outline:2px solid var(--primary);outline-offset:1px}
button.primary{background:var(--primary);color:#fff;border-color:var(--primary)}
button.primary:hover{background:var(--primary2);border-color:var(--primary2)}
button.secondary{border-color:#d5d5d5}
button.danger{background:var(--dangerbg);border-color:#efcfca;color:var(--danger)}
button.danger:hover{background:#ffe9e5}
button.small{min-height:32px;padding:0 10px;font-size:13px}
.ico{width:16px;height:16px;display:inline-flex;align-items:center;justify-content:center;flex:0 0 16px}
.ico svg{width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:1.55;
stroke-linecap:round;stroke-linejoin:round;pointer-events:none}
[hidden]{display:none!important}
.app{max-width:1220px;margin:auto;padding:22px 18px 76px}
.topbar{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:18px}
.brand{display:flex;align-items:center;gap:11px;min-width:0}
.brand-mark{width:42px;height:42px;border-radius:8px;background:#eaf3fc;color:var(--primary);
border:1px solid #d8e7f5;display:flex;align-items:center;justify-content:center;flex:none}
.brand-mark svg{width:25px;height:25px;fill:none;stroke:currentColor;stroke-width:1.55;
stroke-linecap:round;stroke-linejoin:round}
.title h1{margin:0;font-size:22px;font-weight:600;letter-spacing:-.2px;display:flex;align-items:center;gap:8px}
.loading-spinner{display:none;width:15px;height:15px;border:2px solid #d5d5d5;border-top-color:currentColor;border-radius:50%;animation:syncSpin .7s linear infinite;flex:0 0 15px;vertical-align:middle}
@keyframes syncSpin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}
.loading-spinner.is-loading{display:inline-block}
.title p{margin:2px 0 0;color:var(--muted);font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.card{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);
box-shadow:0 2px 8px rgba(0,0,0,.06);padding:18px;margin:12px 0}
.card-head{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:12px}
.card-title{margin:0;font-size:16px;font-weight:600}
.hint,.small-note{color:var(--muted);font-size:13px;line-height:1.6}
.row{display:flex;align-items:center;gap:8px;flex-wrap:wrap}.grow{flex:1;min-width:220px}
input{height:40px;width:100%;padding:0 12px;background:#fff;border:1px solid #c8c8c8;border-radius:6px}
.project-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(275px,1fr));gap:12px}
.project-card{border:1px solid var(--line);border-radius:8px;padding:15px;background:#fff}
.project-card:hover{border-color:#c8c8c8}
.project-name{font-size:16px;font-weight:600;word-break:break-word;margin-bottom:5px}
.project-meta{color:var(--muted);font-size:12px;line-height:1.65;margin:0 0 12px}
.project-actions{display:flex;gap:7px;flex-wrap:wrap}
.scan-box{display:flex;gap:8px}.scan-box input{height:46px;font-size:16px;flex:1}
.scan-record-btn{min-width:100px}

.manual-batch-box{
  display:flex;
  gap:8px;
  margin-top:8px;
}
.manual-batch-fields{
  display:flex;
  gap:8px;
  flex:1;
  min-width:0;
}
.manual-batch-fields input{
  height:46px;
  font-size:16px;
  min-width:0;
  flex:1;
}
.manual-qty{
  width:88px!important;
  flex:0 0 88px!important;
  text-align:center;
}
.manual-batch-btn{
  min-width:100px;
  flex:0 0 100px;
}
@media(max-width:700px){
  .manual-batch-box{flex-wrap:wrap}
  .manual-batch-fields{width:100%;flex-basis:100%}
  .manual-batch-btn{flex:1}
}
.toolbar{border-top:1px solid var(--line);margin-top:14px;padding-top:13px}
.status{min-height:20px;margin-top:8px;font-size:13px;color:#107c10}
.status.error{color:var(--danger)}
.cloud-status{font-size:12px;color:var(--muted)}
.stats{display:grid;grid-template-columns:repeat(3,1fr);gap:10px}
.stat{border:1px solid var(--line);border-radius:7px;padding:13px;background:var(--surface2)}
.stat b{display:block;font-size:22px;font-weight:600}.stat span{font-size:12px;color:var(--muted)}
.table-wrap{overflow:auto}table{border-collapse:collapse;width:100%;min-width:720px}
th,td{border-bottom:1px solid var(--line);padding:9px 10px;text-align:left;white-space:nowrap}
th{background:#f8f8f8;font-weight:600;font-size:13px}.empty{text-align:center;color:var(--muted);padding:28px}
.fab{position:fixed;right:20px;bottom:20px;width:46px;height:46px;min-height:46px;padding:0;
border:1px solid #d5d5d5;border-radius:50%;box-shadow:0 5px 18px rgba(0,0,0,.12)}
.modal-backdrop{position:fixed;inset:0;background:rgba(0,0,0,.28);display:flex;align-items:center;
justify-content:center;padding:18px;z-index:50}
.modal{width:min(540px,100%);background:#fff;border:1px solid #ddd;border-radius:8px;
padding:20px;box-shadow:0 18px 50px rgba(0,0,0,.2)}
.modal h2{margin:0 0 8px;font-size:18px}.modal p{color:var(--muted);line-height:1.6;white-space:pre-line}
.settings-row{display:flex;gap:8px}.settings-row input{flex:1}
@media(max-width:700px){
 .app{padding:14px 10px 70px}.stats{grid-template-columns:1fr}
 .scan-box{flex-wrap:wrap}.scan-box input{flex-basis:100%}.scan-box button{flex:1}
 .toolbar .row button{flex:1}.topbar{align-items:flex-start}
}
.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}

#modalRoot .modal{max-width:420px;padding:20px}
#modalRoot .modal h2{margin-bottom:4px}
#modalRoot .modal p{margin:0;color:#555;font-size:15px;line-height:1.5}
#modalInput{
  margin-top:14px;
}
#modalRoot .modal .row{margin-top:16px!important}

/* Flat / Windows 11 style icon buttons */
.icon-btn,
.icon-action,
.record-delete,
.project-action {
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border:0;
  background:transparent;
  border-radius:8px;
  width:34px;
  height:34px;
  padding:0;
  cursor:pointer;
  transition:background .15s ease, transform .1s ease;
}
.icon-btn:hover,
.icon-action:hover,
.record-delete:hover,
.project-action:hover {
  background:rgba(0,0,0,.06);
}
.icon-btn:active,
.icon-action:active,
.record-delete:active,
.project-action:active {
  transform:scale(.94);
}
.flat-icon {
  width:18px;
  height:18px;
  display:block;
  fill:none;
  stroke:currentColor;
  stroke-width:1.8;
  stroke-linecap:round;
  stroke-linejoin:round;
}
.flat-icon-fill {
  fill:currentColor;
  stroke:none;
}
.record-delete {
  color:#5f6368;
}
.record-delete:hover {
  color:#c5221f;
  background:rgba(197,34,31,.08);
}
.icon-label {
  display:inline-flex;
  align-items:center;
  gap:8px;
}

.status.status-auto-hide{
  animation:statusFadeOut .35s ease forwards;
  animation-delay:2.4s;
}
@keyframes statusFadeOut{
  from{opacity:1;transform:translateY(0)}
  to{opacity:0;transform:translateY(-4px)}
}

.quantity-cell{display:flex;align-items:center;gap:4px}
.stats-edit-btn{width:30px;height:30px}

#cameraRoot{position:fixed;inset:0;z-index:100;display:flex;align-items:center;justify-content:center;padding:12px;background:rgba(0,0,0,.28);}
#cameraRoot[hidden]{display:none!important;}
.camera-modal{width:min(390px,calc(100vw - 24px));}
.camera-preview-wrap{position:relative;overflow:hidden;border-radius:10px;background:#111;margin-top:8px;aspect-ratio:4/3;}
#cameraVideo{width:100%;height:100%;object-fit:cover;display:block;}
.camera-frame{position:absolute;left:50%;top:50%;width:50%;aspect-ratio:1/1;border:2px solid rgba(255,255,255,.95);border-radius:10px;transform:translate(-50%,-50%);box-shadow:0 0 0 9999px rgba(0,0,0,.16);pointer-events:none;}
.camera-qr-box{position:absolute;display:block;border:3px solid #22c55e;border-radius:5px;box-shadow:0 0 0 1px rgba(255,255,255,.7),0 0 12px rgba(34,197,94,.55);pointer-events:none;z-index:3;box-sizing:border-box;}
.camera-qr-box:not(.inside){border-color:#f59e0b;box-shadow:0 0 0 1px rgba(255,255,255,.7),0 0 10px rgba(245,158,11,.4);}
.camera-qr-box[hidden]{display:none!important;}
.camera-modal .card-head{padding:10px 12px;}
.camera-modal .card-title{font-size:16px;}
.camera-modal .status{padding:7px 10px;font-size:13px;}
.camera-modal #cameraClose{padding:5px 10px;font-size:13px;}
@media(max-width:700px){.camera-modal{width:min(360px,calc(100vw - 20px));}}
/* Tools section: same width and visual style as the project card */
.tools-card{
  width:100%;
  box-sizing:border-box;
  margin-top:12px;
  border:1px solid #d5d5d5;
  border-radius:8px;
  background:#fff;
  box-shadow:0 2px 6px rgba(0,0,0,.05);
  overflow:hidden;
}
.tools-card-header{
  min-height:42px;
  box-sizing:border-box;
  padding:0 14px;
  display:flex;
  align-items:center;
  border-bottom:1px solid #e5e5e5;
}
.tools-card-header h2{
  margin:0;
  font-size:14px;
  font-weight:600;
  color:var(--text);
}
.tools-card-body{
  padding:10px 12px;
  display:flex;
  align-items:center;
  justify-content:flex-start;
}

/* QR tool entry */
#qrToolEntry{
  display:none;
  position:relative;
  left:auto;
  top:auto;
  transform:none;
  width:46px;
  height:46px;
  min-height:46px;
  padding:0;
  border:1px solid #d5d5d5;
  border-radius:6px;
  background:#fff;
  color:var(--text);
  box-shadow:none;
  align-items:center;
  justify-content:center;
  gap:0;
  cursor:pointer;
  font-size:13px;
}
#qrToolEntry:hover{background:var(--hover)}
#qrToolEntry:active{background:#ededed}
#qrToolEntry .qr-entry-icon{
  width:28px;height:28px;display:inline-flex;align-items:center;justify-content:center;flex:0 0 28px
}
#qrToolEntry svg{
  width:28px;height:28px;fill:none;stroke:currentColor;stroke-width:1.55;
  stroke-linecap:round;stroke-linejoin:round;pointer-events:none
}

/* Visible only on the project management page */
body.qr-project-view #qrToolEntry{display:inline-flex}

/* QR tool modal */
#qrToolRoot{
  position:fixed;
  inset:0;
  z-index:200;
  display:flex;
  align-items:stretch;
  justify-content:center;
  padding:14px;
  background:rgba(0,0,0,.28);
}
#qrToolRoot[hidden]{display:none!important}
#qrToolPanel{
  width:min(1220px,100%);
  height:100%;
  background:#f3f3f3;
  border:1px solid #d8d8d8;
  border-radius:8px;
  box-shadow:0 18px 60px rgba(0,0,0,.24);
  overflow:hidden;
  display:flex;
  flex-direction:column;
}
#qrToolHeader{
  height:48px;
  flex:0 0 48px;
  padding:0 10px 0 15px;
  background:#fff;
  border-bottom:1px solid #e5e5e5;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}
#qrToolHeaderTitle{font-size:14px;font-weight:600}
#qrToolClose{
  min-height:32px;
  width:34px;
  padding:0;
  border:0;
  background:transparent;
  border-radius:6px;
}
#qrToolClose:hover{background:#f2f2f2}
#qrToolClose svg{
  width:17px;height:17px;fill:none;stroke:currentColor;stroke-width:1.7;
  stroke-linecap:round;stroke-linejoin:round
}
#qrToolFrame{
  width:100%;
  flex:1 1 auto;
  min-height:0;
  border:0;
  display:block;
  background:#f3f3f3;
}
@media(max-width:700px){
  #qrToolRoot{padding:0}
  #qrToolPanel{border:0;border-radius:0}
  #projectView .qr-entry-wrap{margin-top:-2px}
}
