:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #ebedf2;
  --border-strong: #dfe3ea;
  --text: #11161f;
  --muted: #6b7280;
  --muted-2: #9aa3af;
  --accent: #4f46e5;
  --accent-2: #6366f1;
  --accent-soft: #eef2ff;
  --amber: #b45309;
  --amber-soft: #fffbeb;
  --amber-border: #fde68a;
  --good: #15803d;
  --good-soft: #f0fdf4;
  --good-border: #bbf7d0;
  --bad: #dc2626;
  --bad-soft: #fef2f2;
  --bad-border: #fecaca;
  --row-cursor: #f2f4f9;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-xs: 0 1px 2px rgba(17, 22, 31, .05);
  --shadow-sm: 0 1px 3px rgba(17, 22, 31, .06), 0 1px 2px rgba(17, 22, 31, .04);
  --shadow-md: 0 6px 18px rgba(17, 22, 31, .09);
  --shadow-lg: 0 16px 40px rgba(17, 22, 31, .16);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden; /* nothing should force horizontal scroll/zoom on mobile */
}
.hidden { display: none !important; }
.ico, [data-ico] { display: inline-flex; align-items: center; justify-content: center; flex: none; }
svg { display: block; }

/* ---------------- Header ---------------- */
header {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 16px;
  padding: 11px 22px; background: rgba(255,255,255,.82); backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 3px 9px rgba(79,70,229,.32);
}
.brand-name { font-size: 15.5px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; }
header .spacer { flex: 1; }

.tabs { display: flex; gap: 2px; background: var(--surface-2); padding: 3px; border-radius: 11px; border: 1px solid var(--border); }
.tab {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: 8px; background: transparent; color: var(--muted);
  border: none; cursor: pointer; font-size: 13px; font-weight: 600; font-family: inherit;
  transition: background .15s, color .15s;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-xs); }
.tab-label { white-space: nowrap; }
.tab-badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--amber);
  color: #fff; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
}


main { padding: 26px 22px 70px; max-width: 1080px; margin: 0 auto; }

/* ---------------- Page head ---------------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-title { font-size: 22px; font-weight: 750; letter-spacing: -.02em; margin: 0; }
.page-sub { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }

/* ---------------- Controls ---------------- */
select, input, textarea {
  font-family: inherit; font-size: 14px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 10px 12px; width: 100%; transition: border-color .15s, box-shadow .15s;
}
select:focus, input:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-family: inherit; font-size: 13.5px; font-weight: 600; white-space: nowrap;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 9px 14px; cursor: pointer; transition: all .15s; width: auto;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: var(--shadow-xs); }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.ghost { background: var(--surface); color: var(--muted); }
.btn.ghost:hover { color: var(--text); border-color: var(--muted-2); }
.btn.danger { background: var(--surface); color: var(--bad); border-color: var(--bad-border); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.icon-only { padding: 10px; }
.btn.sm { padding: 6px 11px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

label.field { display: block; margin: 14px 0 5px; color: var(--muted); font-size: 12px; font-weight: 600; }
.row-flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.muted { color: var(--muted); font-size: 13px; }
.section-label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: none; letter-spacing: .02em; margin: 8px 2px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow-sm); }
.card-title { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; }
.card-title [data-ico] { color: var(--accent); }

/* select with icons */
.select-wrap { position: relative; display: flex; align-items: center; margin-bottom: 16px; }
.select-wrap.compact { margin-bottom: 0; min-width: 200px; }
.select-wrap .select-ico { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.select-wrap .select-caret { position: absolute; right: 11px; color: var(--muted); pointer-events: none; }
.bigselect { font-size: 15px; padding: 12px 36px; appearance: none; -webkit-appearance: none; font-weight: 500; box-shadow: var(--shadow-xs); }
.select-wrap.compact select { padding: 9px 34px 9px 34px; appearance: none; -webkit-appearance: none; font-size: 13.5px; font-weight: 500; box-shadow: var(--shadow-xs); }

/* ---------------- custom dropdown (self-built) ---------------- */
.dd { position: relative; display: inline-flex; vertical-align: middle; }
.dd.compact { min-width: 150px; }
.dd.block { display: flex; width: 100%; }
.dd-btn {
  display: inline-flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%;
  font-family: inherit; font-size: 13.5px; font-weight: 500; color: var(--text); text-align: left;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 9px 12px; cursor: pointer; box-shadow: var(--shadow-xs); transition: border-color .15s, box-shadow .15s;
}
.dd-btn:hover { border-color: var(--muted-2); }
.dd.open .dd-btn { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.dd-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dd-caret { color: var(--muted); flex: none; display: inline-flex; transition: transform .15s; }
.dd.open .dd-caret { transform: rotate(180deg); }
.dd-menu {
  position: fixed; z-index: 1000;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); padding: 5px; max-height: 280px; overflow-y: auto; display: none;
}
.dd.open .dd-menu { display: block; }
.dd-opt { padding: 8px 11px; border-radius: 7px; font-size: 13.5px; color: var(--text); cursor: pointer; white-space: nowrap; }
.dd-opt.hi { background: var(--surface-2); }
.dd-opt.sel { color: var(--accent); font-weight: 700; }
.dd-opt.sel.hi { background: var(--accent-soft); }
.dd.disabled { opacity: .55; pointer-events: none; }
/* status dropdown colored states */
.dd.status-sel { min-width: 104px; }
.dd.status-sel .dd-btn { font-weight: 700; }
.dd.status-sel.is-pending .dd-btn { color: var(--amber); border-color: var(--amber-border); background: var(--amber-soft); }
.dd.status-sel.is-pending .dd-caret { color: var(--amber); }
.dd.status-sel.is-approved .dd-btn { color: var(--good); border-color: var(--good-border); background: var(--good-soft); }
.dd.status-sel.is-approved .dd-caret { color: var(--good); }
.dd.status-sel.is-rejected .dd-btn { color: var(--bad); border-color: var(--bad-border); background: var(--bad-soft); }
.dd.status-sel.is-rejected .dd-caret { color: var(--bad); }

/* decorative per-row check toggle in the 読み取り結果 table */
.edit-table .chkcol { width: 40px; text-align: center; }
.icon-btn.confirm-check.is-checked { color: var(--good); border-color: var(--good-border); background: var(--good-soft); }

/* ---------------- Capture ---------------- */
.shoot {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px;
  width: 100%; padding: 30px; text-align: center; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  border: none; border-radius: var(--radius); margin-bottom: 18px; box-shadow: 0 12px 30px rgba(79,70,229,.28);
  transition: transform .1s, box-shadow .2s;
}
.shoot:hover { box-shadow: 0 16px 38px rgba(79,70,229,.34); }
.shoot:active { transform: scale(.99); }
.shoot-ico { width: 56px; height: 56px; border-radius: 16px; margin-bottom: 6px; background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.25); }
.shoot-main { font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
.shoot .sub { font-size: 13px; font-weight: 400; opacity: .92; }
.shoot input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload { position: relative; display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; margin-top: 10px; padding: 13px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--muted); font-size: 14px; font-weight: 600; cursor: pointer; transition: all .15s; }
.upload:hover { border-color: var(--accent-2); color: var(--accent); background: var(--accent-soft); }
.upload [data-ico] { color: var(--accent); }
.upload input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.queue { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 999px; padding: 7px 13px;
  font-size: 13px; font-weight: 500; box-shadow: var(--shadow-xs);
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1s infinite; }
.chip [data-ico] { color: var(--muted); }
.chip.working { border-color: var(--accent-2); color: var(--accent); }
.chip.done { border-color: var(--good-border); color: var(--good); } .chip.done [data-ico] { color: var(--good); }
.chip.err { border-color: var(--bad-border); color: var(--bad); } .chip.err [data-ico] { color: var(--bad); }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.3} }

/* recent capture cards */
.recent { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.rec-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; box-shadow: var(--shadow-xs); cursor: pointer; transition: all .15s; }
.rec-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.rec-card .rec-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.rec-card .rec-fields { font-size: 13px; color: var(--text); display: grid; gap: 3px; }
.rec-card .rec-fields .k { color: var(--muted-2); font-size: 11px; }
.rec-card .rec-fields .v { font-weight: 500; }
.rec-card .rec-foot { display: flex; gap: 8px; margin-top: 12px; }
.rec-card .rec-foot .btn { flex: 1; }
.rec-card.new { animation: flash 1.4s ease; }
@keyframes flash { from { background: var(--accent-soft); } to { background: var(--surface); } }
.empty.soft { padding: 40px 20px; border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface); }
.rec-card .rec-top { display: flex; gap: 12px; align-items: flex-start; }
.rec-card.job { background: var(--surface-2); }
.rec-card.job.error { background: var(--bad-soft); border-color: var(--bad-border); }
.job-body { font-size: 12.5px; color: var(--muted); margin-top: 6px; }

/* thumbnails + spinner + working badge */
.thumb { flex: none; width: 52px; height: 52px; padding: 0; border: 1px solid var(--border-strong); border-radius: 9px; overflow: hidden; cursor: zoom-in; background: var(--surface-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.spin { display: inline-flex; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.badge.working { background: var(--accent-soft); color: var(--accent); border-color: #c7d2fe; }
.badge.error { background: var(--bad-soft); color: var(--bad); border-color: var(--bad-border); }
.badge.error .bdot { background: var(--bad); }

/* confirm view sync bar */
.sync-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 16px; margin-bottom: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-xs); }
.sync-label { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 700; color: var(--text); }
.sync-label [data-ico] { color: var(--accent); }
.sync-bar .select-wrap.compact { min-width: 180px; }
.sync-hint { font-size: 12.5px; color: var(--muted); margin-left: auto; }
/* compact one-line confirm toolbar */
.confirm-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 9px 12px; margin-bottom: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-xs); }
.tb-sync { display: inline-flex; align-items: center; gap: 7px; }
.tb-sync > [data-ico] { color: var(--accent); }
.tb-sync .select-wrap.compact { min-width: 150px; }
.tb-fill { flex: 1; min-width: 8px; }
.tb-bar { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tb-summary { font-size: 13px; font-weight: 600; color: var(--muted); }
/* list view: filters + count + capture buttons on one sticky row (pinned under the app header) */
.list-toolbar {
  position: sticky; top: var(--header-h, 54px); z-index: 20;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; margin-bottom: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-sm);
}
.list-toolbar .cap-actions { margin-left: auto; }
.confirm-toolbar .segmented { flex: none; }
.confirm-toolbar .select-wrap.compact { min-width: 150px; }
.confirm-toolbar { padding-top: 18px; }
/* status & group tags */
.badge.partial { background: var(--accent-soft); color: var(--accent); border-color: #c7d2fe; }
.badge.partial .bdot { background: var(--accent); }
.grouptag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); border: 1px solid #c7d2fe; font-size: 11.5px; font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grouptag [data-ico] { color: var(--accent); }
.grouptag { cursor: pointer; }
.grouptag.empty { background: transparent; color: var(--muted-2); border: 1px dashed var(--border-strong); }
.grouptag.empty [data-ico] { color: var(--muted-2); }
.review-table .grpcol { width: 150px; }
.review-table .stcol { width: 104px; }
.review-table th:nth-child(5), .review-table td:nth-child(5) { width: 64px; } /* 件数 (override) */
.review-table th:nth-child(7), .review-table td:nth-child(7) { width: 64px; } /* 追加 (override) */
@media (max-width: 560px) { .tb-fill { display: none; } .confirm-toolbar, .list-toolbar { gap: 8px; } .list-toolbar .cap-actions { margin-left: 0; width: 100%; } .list-toolbar .cap-actions .btn { flex: 1; } }
.review-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 2px; flex-wrap: wrap; }
.review-head .section-label { margin: 0; }
.review-head .sort-note { font-size: 12px; color: var(--muted-2); }

#recent { display: block; } /* hold the full-width review table, not the old card grid */
.jobs-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.review-table { border-collapse: collapse; width: 100%; font-size: 13.5px; table-layout: fixed; }
.review-table .fname, .review-table .fsub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.review-table th { background: var(--surface-2); border-bottom: 1px solid var(--border-strong); padding: 10px 12px; text-align: left; font-size: 12px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.review-table th.sortable { cursor: pointer; user-select: none; }
.review-table th.sortable:hover { color: var(--text); }
.review-table th.sortable.active { color: var(--accent); }
.review-table th.sortable [data-ico] { vertical-align: middle; margin-left: 2px; }
.review-table td { border-bottom: 1px solid var(--border); padding: 8px 12px; vertical-align: middle; }
.review-table tbody tr:last-child td { border-bottom: none; }
.review-table tbody tr { cursor: pointer; transition: background .12s; }
.review-table tbody tr:hover td { background: var(--surface-2); }
.review-table tbody tr.checked td { background: var(--good-soft); }
.review-table .cbcol { width: 40px; text-align: center; }
.review-table .imgcol { width: 54px; }
.review-table .actcol { width: 1%; white-space: nowrap; }
.review-table input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; vertical-align: middle; }
.review-table .thumb { width: 40px; height: 40px; }
.review-table .fname { font-weight: 600; }
.review-table .fsub { font-size: 11.5px; color: var(--muted-2); margin-top: 1px; }
.review-table .devcell, .review-table .addcell { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
@media (max-width: 560px) { .sync-hint { display: none; } }

/* DB banner (continuous approval) */
.banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; margin-bottom: 14px; background: var(--accent-soft); border: 1px solid #c7d2fe; border-radius: var(--radius-sm); }
.banner-left { display: flex; align-items: center; gap: 9px; font-size: 13.5px; font-weight: 600; color: var(--accent); }

/* confirm modal image */
.confirm-img { display: block; width: 100%; padding: 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface-2); cursor: zoom-in; }
.confirm-img img { width: 100%; max-height: 260px; object-fit: contain; display: block; }

/* lightbox */
.modal-overlay.lightbox { cursor: zoom-out; padding: 28px; }
.modal-overlay.lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; box-shadow: var(--shadow-lg); animation: pop .18s cubic-bezier(.2,.8,.3,1); }

/* ---------------- Status badge ---------------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; border: 1px solid transparent; white-space: nowrap; }
.badge .bdot { width: 6px; height: 6px; border-radius: 50%; }
.badge.pending { background: var(--amber-soft); color: var(--amber); border-color: var(--amber-border); }
.badge.pending .bdot { background: var(--amber); }
.badge.approved { background: var(--good-soft); color: var(--good); border-color: var(--good-border); }
.badge.approved .bdot { background: var(--good); }

/* ---------------- DB: stats / toolbar / table ---------------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; box-shadow: var(--shadow-xs); }
.stat .lbl { font-size: 12px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.stat .lbl [data-ico] { color: var(--muted-2); }
.stat .num { font-size: 26px; font-weight: 750; letter-spacing: -.02em; margin-top: 3px; }
.stat.pending .num { color: var(--amber); } .stat.pending .lbl [data-ico] { color: var(--amber); }
.stat.approved .num { color: var(--good); } .stat.approved .lbl [data-ico] { color: var(--good); }

.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.segmented button { border: none; background: transparent; color: var(--muted); font-family: inherit; font-size: 13px; font-weight: 600; padding: 6px 13px; border-radius: 7px; cursor: pointer; transition: all .15s; }
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-xs); }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { border-bottom: 1px solid var(--border); padding: 11px 14px; text-align: left; white-space: nowrap; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
th { background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: 12px; position: sticky; top: 0; }
tbody tr { transition: background .12s; }
tbody tr:hover td { background: var(--surface-2); }
tbody tr.is-pending td { background: rgba(180,83,9,.035); }
tbody tr.is-pending:hover td { background: rgba(180,83,9,.06); }
td[contenteditable] { min-width: 80px; outline: none; border-radius: 5px; }
td[contenteditable]:focus { background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); }
tr.new td { animation: rowflash 1.4s ease; }
@keyframes rowflash { from { background: var(--accent-soft); } to { background: transparent; } }
td.actions { white-space: nowrap; text-align: right; width: 1%; }
.row-actions { display: inline-flex; gap: 2px; opacity: .35; transition: opacity .12s; }
tr:hover .row-actions, tr.is-pending .row-actions { opacity: 1; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; background: transparent; border: none; color: var(--muted-2); padding: 6px; border-radius: 7px; cursor: pointer; transition: all .12s; }
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.icon-btn.bordered { border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 9px; color: var(--muted); background: var(--surface); box-shadow: var(--shadow-xs); }
.icon-btn.bordered:hover { color: var(--accent); border-color: var(--accent-2); }
.icon-btn.approve:hover { color: var(--good); background: var(--good-soft); }
.icon-btn.del:hover { color: var(--bad); background: var(--bad-soft); }

.empty { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty .empty-ico { width: 52px; height: 52px; margin: 0 auto 12px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted-2); display: flex; align-items: center; justify-content: center; }
.empty .empty-title { font-weight: 700; color: var(--text); font-size: 15px; }
.empty .empty-sub { font-size: 13px; margin-top: 4px; }

/* ---------------- Templates ---------------- */
.tmpl-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tmpl-card { background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 15px 16px; cursor: pointer; transition: all .15s; }
.tmpl-card:hover { border-color: var(--accent-2); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.tmpl-card.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tmpl-card h3 { margin: 0 0 5px; font-size: 15px; font-weight: 700; }
.tmpl-card .cols { color: var(--muted); font-size: 12.5px; }

.chat { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.chat-log { display: flex; flex-direction: column; gap: 9px; max-height: 340px; overflow-y: auto; padding: 4px; }
.msg { padding: 10px 13px; border-radius: 12px; max-width: 86%; font-size: 14px; line-height: 1.55; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.chat-input { display: flex; gap: 8px; align-items: flex-end; }
.chat-input textarea { flex: 1; min-height: 46px; }

.cols-editor table { font-size: 13px; }
.cols-editor table th { padding: 9px 12px; }
.cols-editor table td { padding: 4px 8px; }
.cols-editor table input, .cols-editor table select { background: transparent; border: 1px solid transparent; padding: 6px 8px; box-shadow: none; }
.cols-editor table input:focus, .cols-editor table select:focus { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ---------------- Toast ---------------- */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 9px; background: var(--surface); color: var(--text); border: 1px solid var(--border); padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow-md); z-index: 80; max-width: 90%; font-size: 14px; font-weight: 500; }
.toast.good { border-color: var(--good-border); } .toast.good [data-ico] { color: var(--good); }
.toast.bad { border-color: var(--bad-border); } .toast.bad [data-ico] { color: var(--bad); }

/* ---------------- Modal ---------------- */
.modal-overlay { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 18px; background: rgba(17,22,31,.42); backdrop-filter: blur(3px); animation: fade .15s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal { width: 100%; max-width: 460px; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); overflow: hidden; animation: pop .18s cubic-bezier(.2,.8,.3,1); max-height: 90vh; display: flex; flex-direction: column; }
@keyframes pop { from { transform: translateY(12px) scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 12px; }
.modal-title { font-size: 16px; font-weight: 700; display: block; }
.modal-sub { font-size: 12.5px; color: var(--muted); }
.modal-body { padding: 4px 20px 18px; overflow-y: auto; display: grid; gap: 12px; }
.modal-field label { display: block; font-size: 11.5px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.modal-field .ftype { color: var(--accent); font-weight: 600; }
.modal-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); }
.modal-progress { height: 3px; background: var(--accent); transition: width .25s ease; }

/* device chip (capture) + device tag (cards) */
.device-chip { display: inline-flex; align-items: center; gap: 7px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 999px; padding: 8px 14px; font-size: 13px; font-weight: 600; color: var(--text); cursor: pointer; font-family: inherit; box-shadow: var(--shadow-xs); transition: all .15s; }
.device-chip:hover { border-color: var(--accent-2); color: var(--accent); }
.device-chip [data-ico]:first-child { color: var(--accent); }
.device-chip [data-ico]:last-child { color: var(--muted-2); }
.dev-tag { display: inline-flex; align-items: center; gap: 3px; margin-left: 8px; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); font-size: 10.5px; font-weight: 600; }
.dev-tag [data-ico] { color: var(--muted-2); }

/* modal bulk bar */
.modal-bulk { padding: 0 20px 4px; }
.modal-bulk .btn { width: 100%; }

/* per-photo multi-row editor */
.batch-row { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; background: var(--surface-2); }
.batch-row + .batch-row { margin-top: 10px; }
.batch-row-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.batch-row-title { font-size: 12px; font-weight: 700; color: var(--muted); }
.batch-fields { display: grid; gap: 10px; }
.batch-row .modal-field input { background: var(--surface); }
.rec-fields .more { color: var(--muted-2); font-size: 12px; margin-top: 2px; }

/* ---------------- Confirm: full-screen (original | table) ---------------- */
.confirm-screen { position: fixed; inset: 0; z-index: 60; background: var(--bg); display: flex; flex-direction: column; animation: fade .15s ease; }
.confirm-bar { display: flex; align-items: center; gap: 14px; padding: 12px 18px; background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow-xs); flex-wrap: wrap; }
.confirm-titles { display: flex; flex-direction: column; min-width: 0; }
.confirm-title { font-size: 16px; font-weight: 750; letter-spacing: -.01em; }
.confirm-sub { font-size: 12.5px; color: var(--muted); }
.confirm-regen { display: flex; align-items: center; }
.confirm-bulk { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-left: 6px; }
.confirm-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.confirm-split { flex: 1; display: flex; min-height: 0; }
.confirm-orig { flex: 0 0 44%; background: #0f1115; overflow: hidden; position: relative; padding: 0; }
.split-handle { flex: 0 0 8px; cursor: col-resize; background: var(--border); position: relative; display: flex; align-items: center; justify-content: center; transition: background .12s; }
.split-handle:hover, .confirm-split.dragging .split-handle { background: var(--accent); }
.split-handle .grip { width: 2px; height: 28px; border-radius: 2px; background: var(--muted-2); }
.split-handle:hover .grip, .confirm-split.dragging .split-handle .grip { background: #fff; }
.confirm-split.dragging .confirm-orig, .confirm-split.dragging .confirm-tablewrap { pointer-events: none; } /* don't let the PDF object swallow drag */
body.resizing { cursor: col-resize; user-select: none; }
.orig-root { width: 100%; height: 100%; position: relative; }
/* transform-based viewer: the stage clips, the content is GPU-transformed (no layout/scroll thrash on zoom or pan) */
.orig-stage { position: absolute; inset: 0; overflow: hidden; cursor: grab; user-select: none; -webkit-user-select: none; touch-action: none; overscroll-behavior: contain; }
.orig-stage.grabbing { cursor: grabbing; }
.orig-zoom { position: absolute; top: 0; left: 0; transform-origin: 0 0; will-change: transform; }
.orig-zoom.orig-pdf { display: flex; flex-direction: column; gap: 12px; }
.confirm-orig .orig-img { display: block; border-radius: 8px; box-shadow: 0 8px 30px rgba(0,0,0,.4); -webkit-user-drag: none; user-drag: none; pointer-events: none; }
/* receipt-region highlight overlay (lives inside the transformed content so it scales with the image) */
.orig-hilite { position: absolute; border: 2px solid var(--accent); border-radius: 4px; background: color-mix(in srgb, var(--accent) 14%, transparent); box-shadow: 0 0 0 9999px rgba(0,0,0,.34); pointer-events: none; transition: opacity .12s; }
.orig-hilite.hidden { display: none; }
.confirm-orig .pdf-page { display: block; border-radius: 6px; box-shadow: 0 6px 20px rgba(0,0,0,.4); background: #fff; }
/* floating "which receipt" crop preview shown on row hover */
.receipt-peek { position: fixed; z-index: 80; overflow: hidden; border-radius: 10px; border: 1px solid var(--border-strong); background: #11141a; box-shadow: var(--shadow-lg, 0 18px 50px rgba(0,0,0,.55)); pointer-events: none; }
.receipt-peek-img { position: absolute; background-repeat: no-repeat; }
.edit-table tbody tr.has-region:hover td { background: var(--accent-soft); }
.edit-table td.rownum.zoomable { cursor: zoom-in; }
.edit-table td.rownum.zoomable:hover { color: var(--accent); text-decoration: underline; }
.conf-warn { display: inline-flex; vertical-align: middle; margin-left: 3px; }
.conf-warn.low { color: var(--bad, #e5484d); }
.conf-warn.med { color: var(--warn, #e6a23c); }
.confirm-orig .orig-loading { color: var(--muted-2); margin: auto; font-size: 13px; }
.confirm-orig .orig-empty { color: var(--muted-2); text-align: center; margin: auto; }
.orig-zoombar { position: absolute; right: 14px; bottom: 14px; display: flex; align-items: center; gap: 2px; padding: 4px; background: rgba(20,22,28,.82); backdrop-filter: blur(6px); border: 1px solid rgba(255,255,255,.14); border-radius: 11px; color: #fff; box-shadow: var(--shadow-md); z-index: 2; }
.orig-zoombar .zb { background: transparent; border: none; color: #fff; padding: 7px; border-radius: 8px; cursor: pointer; display: inline-flex; }
.orig-zoombar .zb:hover { background: rgba(255,255,255,.16); }
.orig-zoombar .zoom-lvl { font-size: 12px; font-weight: 600; min-width: 44px; text-align: center; }
.orig-zoombar .pdf-pager { display: inline-flex; align-items: center; gap: 2px; margin-left: 4px; padding-left: 6px; border-left: 1px solid rgba(255,255,255,.18); }
.orig-zoombar .pdf-pageno { font-size: 12px; font-weight: 600; min-width: 40px; text-align: center; }
.confirm-tablewrap { flex: 1; overflow: auto; padding: 18px; min-width: 0; }
.edit-table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13.5px; }
.edit-table th { position: sticky; top: 0; background: var(--surface-2); border-bottom: 1px solid var(--border-strong); padding: 10px 10px; text-align: left; font-size: 12px; font-weight: 700; color: var(--muted); white-space: nowrap; z-index: 1; }
.edit-table th .thtype { color: var(--accent); font-weight: 600; font-size: 10.5px; margin-left: 6px; }
.edit-table td { border-bottom: 1px solid var(--border); padding: 5px 6px; vertical-align: middle; }
/* drop guide line while dragging — box-shadow, so the row height never shifts */
.edit-table tbody tr.drop-before td { box-shadow: inset 0 2px 0 0 var(--accent); }
.edit-table tbody tr.drop-after td { box-shadow: inset 0 -2px 0 0 var(--accent); }
/* column header drag-to-reorder (vertical guide via box-shadow — no layout shift) */
.edit-table th.colhead { cursor: grab; user-select: none; }
.edit-table th.colhead:active { cursor: grabbing; }
.edit-table th.colhead.col-dragging { opacity: .45; }
.edit-table th.colhead.col-drop-before { box-shadow: inset 2px 0 0 0 var(--accent); }
.edit-table th.colhead.col-drop-after { box-shadow: inset -2px 0 0 0 var(--accent); }
.edit-table td.rownum, .edit-table th.rownum { color: var(--muted-2); font-size: 12px; text-align: center; width: 32px; }
.edit-table td.rowact, .edit-table th.rowact { width: 36px; text-align: center; }
.edit-table td.draghandle, .edit-table th.draghandle { width: 28px; text-align: center; color: var(--muted-2); cursor: grab; }
.edit-table td.draghandle:active { cursor: grabbing; }
.edit-table td.cbcol, .edit-table th.cbcol { width: 32px; text-align: center; }
.edit-table .rowchk { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; vertical-align: middle; }
.edit-table tbody tr.checked td { background: var(--good-soft); }
.edit-table tbody tr.dragging { opacity: .5; background: var(--accent-soft); }
.addrow { margin-top: 12px; }
.edit-table input, .edit-table textarea { border: 1px solid transparent; background: transparent; padding: 8px 36px 8px 9px; border-radius: 7px; width: 100%; font-family: inherit; font-size: 13.5px; }
.edit-table textarea { resize: none; overflow: hidden; min-height: 38px; line-height: 1.45; white-space: pre-wrap; }
.edit-table input:focus, .edit-table textarea:focus { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.cell-edit { position: relative; display: flex; align-items: center; }
.cell-edit .cell-save { position: absolute; right: 4px; top: 4px; display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; padding: 0; border: none; border-radius: 6px; background: var(--accent); color: #fff; cursor: pointer; box-shadow: var(--shadow-sm); opacity: 0; pointer-events: none; transition: opacity .12s; }
.cell-edit.editing .cell-save { opacity: 1; pointer-events: auto; }
.cell-edit .cell-save:hover { background: var(--accent-2); }
.edit-table td.delcol, .edit-table th.delcol { width: 34px; text-align: center; }
/* status dropdown in the detail footer */
.status-sel select { padding: 9px 30px 9px 12px; appearance: none; -webkit-appearance: none; font-weight: 700; font-size: 13.5px; cursor: pointer; }
.status-sel.is-approved select { color: var(--good); border-color: var(--good-border); background: var(--good-soft); }
.status-sel.is-rejected select { color: var(--bad); border-color: var(--bad-border); background: var(--bad-soft); }
/* capture buttons in the list header */
.cap-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.cap-actions .btn { position: relative; overflow: hidden; }
/* 却下 badge */
.badge.rejected { background: var(--bad-soft); color: var(--bad); border-color: var(--bad-border); }
.badge.rejected .bdot { background: var(--bad); }
.edit-table tbody tr:hover td { background: var(--surface-2); }
@media (max-width: 760px) {
  .confirm-split { flex-direction: column; }
  .split-handle { display: none; }
  .confirm-orig { flex: 0 0 auto !important; max-height: 38vh; }
  .confirm-actions { width: 100%; margin-left: 0; }
  .confirm-actions .btn { flex: 1; }
  .confirm-bulk { width: 100%; order: 5; }
}

/* toggle (領収書モード) */
.toggle { display: flex; align-items: center; gap: 11px; margin: 16px 0 4px; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle .toggle-track { flex: none; width: 40px; height: 23px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background .15s; }
.toggle .toggle-thumb { position: absolute; top: 2px; left: 2px; width: 19px; height: 19px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .15s; }
.toggle input:checked + .toggle-track { background: var(--accent); }
.toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(17px); }
.toggle input:focus-visible + .toggle-track { box-shadow: 0 0 0 3px var(--accent-soft); }
.toggle-text { display: flex; flex-direction: column; line-height: 1.35; }
.toggle-text strong { font-size: 13.5px; }
.toggle-text .muted { font-size: 11.5px; }
/* in receipt mode: columns are fixed → hide manual column add + the chat designer */
#editor.receipt-on #addCol { display: none; }
#editor.receipt-on .split > .card:first-child { display: none; }
#editor.receipt-on .split { grid-template-columns: 1fr; }

/* ---------------- Custom dialog ---------------- */
.dialog-overlay { z-index: 70; }
.dialog { width: 100%; max-width: 384px; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); overflow: hidden; animation: pop .18s cubic-bezier(.2,.8,.3,1); }
.dialog-head { display: flex; align-items: center; gap: 12px; padding: 22px 22px 0; }
.dialog-ico { flex: none; width: 40px; height: 40px; border-radius: 11px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; }
.dialog-ico.danger { background: var(--bad-soft); color: var(--bad); }
.dialog-title { font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.dialog-body { padding: 12px 22px 0; color: var(--muted); font-size: 14px; line-height: 1.6; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 22px; }

/* ---------------- Responsive ---------------- */
@media (max-width: 820px) { .split { grid-template-columns: 1fr; } }
@media (max-width: 640px) {
  .page-head { flex-direction: column; align-items: stretch; gap: 12px; }
  .page-head > div { text-align: left; }
  .page-head .btn { width: 100%; justify-content: center; }
  .page-head .device-chip { align-self: flex-start; } /* compact, left-aligned identity chip */
  .page-title { font-size: 20px; }
  .stats { gap: 8px; }
  .stat { padding: 11px 12px; } .stat .num { font-size: 21px; } .stat .lbl { font-size: 11px; }
  /* iOS zooms in on focus when a control's font-size is < 16px — keep all inputs at 16px */
  select, input, textarea, td[contenteditable], .bigselect,
  .cols-editor table input, .cols-editor table select { font-size: 16px; }
  .modal { max-width: 100%; border-radius: 16px; }
  .recent { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  header { padding: 10px 12px; gap: 8px; }
  .brand-name, .conn-text { display: none; }
  main { padding: 18px 14px 56px; }
  .tabs { gap: 1px; padding: 3px; }
  .toolbar { gap: 8px; } .segmented button { padding: 6px 12px; }
  .sync-bar { gap: 8px; }
  .sync-bar .select-wrap.compact { flex: 1; min-width: 0; }
  .banner { flex-wrap: wrap; }
  .banner .row-flex { width: 100%; } .banner .row-flex .btn { flex: 1; }
}
/* very narrow: tabs become icon-only so the header never overflows (the zoom bug) */
@media (max-width: 480px) {
  .tab-label { display: none; }
  .tab { padding: 8px 12px; }
  .brand { margin-right: 2px; }
}

/* ============ Auth gate (login) ============ */
.auth-gate {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); padding: 24px;
}
.auth-card {
  width: 100%; max-width: 360px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px;
}
.auth-brand { display: flex; align-items: center; gap: 9px; font-size: 19px; font-weight: 700; color: var(--text); }
.auth-brand .brand-name { font-weight: 700; }
.auth-sub { color: var(--muted); font-size: 13px; margin: 6px 0 18px; }
.auth-card input { width: 100%; }
.auth-error { margin-top: 12px; color: #c0392b; font-size: 13px; }
.auth-submit { width: 100%; justify-content: center; margin-top: 18px; }

/* 領収書を削除（確認画面フッターのボタン） */
.btn.ghost.del-receipt { color: var(--bad); }
.btn.ghost.del-receipt:hover { background: var(--bad-soft); border-color: var(--bad); }

/* 却下理由メモ（確認画面フッター） */
.btn.ghost.reject-memo { color: var(--bad); max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn.ghost.reject-memo.empty { color: var(--muted); }
.btn.ghost.reject-memo:hover { background: var(--bad-soft); }

/* グループ選択ダイアログ */
.group-pick-label { padding: 14px 22px 6px; color: var(--muted); font-size: 12px; font-weight: 600; }
.group-pick-list { margin: 0 22px; max-height: 200px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.group-pick-item { display: flex; align-items: center; gap: 7px; width: 100%; text-align: left; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font-size: 13.5px; cursor: pointer; }
.group-pick-item:hover { border-color: var(--accent-2); background: var(--surface-2); }
.group-pick-item.sel { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 700; }

/* ============ Analytics (分析) ============ */
.an-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.an-card { background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-xs); }
.an-card-label { color: var(--muted); font-size: 12px; font-weight: 600; }
.an-card-value { font-size: 26px; font-weight: 800; margin-top: 4px; letter-spacing: -.01em; }
.an-card-sub { color: var(--muted-2); font-size: 12px; margin-top: 2px; }
.an-bar-wrap { display: flex; height: 16px; border-radius: 999px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); }
.an-bar { display: flex; width: 100%; }
.an-seg { display: block; }
.an-seg.approved { background: #16a34a; }
.an-seg.rejected { background: #dc2626; }
.an-seg.partial  { background: #f59e0b; }
.an-seg.pending  { background: #cbd5e1; }
.an-legend { display: flex; gap: 16px; flex-wrap: wrap; margin: 10px 0 4px; color: var(--muted); font-size: 12.5px; }
.an-lg { display: inline-flex; align-items: center; gap: 6px; }
.an-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.an-dot.approved { background: #16a34a; } .an-dot.rejected { background: #dc2626; }
.an-dot.partial { background: #f59e0b; } .an-dot.pending { background: #cbd5e1; }
.an-table th.num, .an-table td.num { text-align: right; white-space: nowrap; }
@media (max-width: 760px) { .an-cards { grid-template-columns: repeat(2, 1fr); } }

/* ============================================================================
   v2: 取り込みキュー / レビュー / スケール対応一覧
   ============================================================================ */

/* ---- ヘッダーのユーザー表示 ---- */
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-email { font-size: 12.5px; color: var(--muted); max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 760px) { .user-email { display: none; } }

/* ---- ドロップゾーン ---- */
.dropzone {
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius);
  background: var(--surface); padding: 34px 24px; text-align: center;
  transition: border-color .15s, background .15s, transform .15s;
}
.dropzone.dragover { border-color: var(--accent); background: var(--accent-soft); transform: scale(1.005); }
.dropzone .dz-ico { color: var(--muted-2); display: inline-flex; }
.dropzone.dragover .dz-ico { color: var(--accent); }
.dz-title { font-size: 16px; font-weight: 650; margin-top: 8px; }
.dz-sub { font-size: 13px; color: var(--muted); margin-top: 5px; }
.dz-actions { display: flex; gap: 10px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.dz-status { margin: 18px auto 0; max-width: 460px; text-align: left; }
.dz-status-row { display: flex; align-items: center; gap: 10px; font-size: 13.5px; margin-bottom: 8px; }

/* ---- プログレスバー ---- */
.pbar { height: 6px; border-radius: 999px; background: var(--border); overflow: hidden; }
.pbar-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s ease; }
.pbar.done .pbar-fill { background: var(--good); }
.pbar.live .pbar-fill { background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

.spinner {
  width: 13px; height: 13px; border-radius: 50%; flex: none;
  border: 2px solid var(--border-strong); border-top-color: var(--accent);
  animation: spin .8s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-row { display: flex; align-items: center; gap: 10px; padding: 26px 4px; color: var(--muted); font-size: 13.5px; }

/* ---- 取り込みサマリー ---- */
.ing-summary { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin: 16px 0; box-shadow: var(--shadow-xs); }
.ing-sum-head { display: flex; align-items: center; gap: 10px; margin-bottom: 11px; font-size: 14.5px; }
.ing-sum-head .spacer { flex: 1; }
.ing-chips { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 12px; }
.ing-actions { margin-top: 12px; }

.jchip { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.jchip.st-ok { background: var(--good-soft); border-color: var(--good-border); color: var(--good); }
.jchip.st-bad { background: var(--bad-soft); border-color: var(--bad-border); color: var(--bad); }
.jchip.st-run { background: var(--accent-soft); border-color: #c7d2fe; color: var(--accent); }
.jchip.st-queue { background: var(--surface-2); }
.jchip.st-dup { background: var(--amber-soft); border-color: var(--amber-border); color: var(--amber); }

/* ---- ジョブ一覧 ---- */
.job-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.job-table th { text-align: left; font-size: 11.5px; font-weight: 600; color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); position: sticky; top: 0; z-index: 1; }
.job-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.job-table tr.is-failed td { background: var(--bad-soft); }
.job-table .jname { font-weight: 550; max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-table .num { text-align: right; }
.jstage { margin-left: 8px; font-size: 11.5px; color: var(--muted); }
.jerr { display: block; margin-top: 3px; font-size: 11.5px; color: var(--bad); max-width: 520px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- ツールバー ---- */
.toolbar.sticky { position: sticky; top: var(--header-h, 56px); z-index: 5; background: var(--bg); padding-top: 10px; padding-bottom: 10px; }
.toolbar .spacer { flex: 1; }
.field-inline { font-size: 12.5px; color: var(--muted); }

.searchbox { display: inline-flex; align-items: center; gap: 7px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 0 10px; height: 34px; color: var(--muted-2); min-width: 240px; }
.searchbox input { border: 0; outline: 0; background: transparent; font: inherit; font-size: 13px; color: var(--text); width: 100%; height: 100%; padding: 0; }
.searchbox input::-webkit-search-cancel-button { cursor: pointer; }

.btn.sm { height: 32px; padding: 0 11px; font-size: 12.5px; }
.btn.ghost.on { background: var(--accent-soft); border-color: #c7d2fe; color: var(--accent); }

.kbd-hint { font-size: 11.5px; color: var(--muted-2); display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.kbd-hint kbd { font: inherit; font-size: 10.5px; background: var(--surface); border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; padding: 1px 5px; margin: 0 1px; color: var(--muted); }
@media (max-width: 1100px) { .kbd-hint { display: none; } }

/* ---- ページャ ---- */
.pager { display: flex; align-items: center; gap: 10px; padding: 14px 4px; font-size: 12.5px; }
.pager .btn { margin-left: 0; }
.pager .muted { flex: 1; }

/* ---- レビュー行の追加要素 ---- */
/* キーボードカーソル行。
   inset の左線を全セルに掛けると、セル境界ごとに縦棒が並んで縞模様になるので、
   線は先頭セルだけ。背景は hover と区別できる程度の薄い色に留める。 */
.review-table tr.cursor > td { background: var(--row-cursor); box-shadow: none; }
.review-table tr.cursor > td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.review-table tbody tr.cursor:hover > td { background: var(--row-cursor); }
.review-table .fsub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.review-table td.money { font-variant-numeric: tabular-nums; font-weight: 600; }
.review-table th.num, .review-table td.num, .db-table th.num, .db-table td.num { text-align: right; }
.flagcol { min-width: 150px; }

.flag { display: inline-flex; align-items: center; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 5px; margin: 1px 3px 1px 0; background: var(--amber-soft); border: 1px solid var(--amber-border); color: var(--amber); white-space: nowrap; cursor: help; }
.flag.sev { background: var(--bad-soft); border-color: var(--bad-border); color: var(--bad); }
.flag.ok { background: var(--good-soft); border-color: var(--good-border); color: var(--good); cursor: default; }
.conf { display: inline-flex; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 5px; margin: 1px 3px 1px 0; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--muted); white-space: nowrap; cursor: help; }
.conf.cf-low { background: var(--bad-soft); border-color: var(--bad-border); color: var(--bad); }
.conf.cf-med { background: var(--amber-soft); border-color: var(--amber-border); color: var(--amber); }

.icon-btn.approve { color: var(--good); }
.icon-btn.approve:hover { background: var(--good-soft); }

/* ---- 検算バナー（確認詳細） ---- */
.check-banner { display: flex; align-items: center; gap: 9px; padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; margin-bottom: 12px; }
.check-banner.ok { background: var(--good-soft); border: 1px solid var(--good-border); color: var(--good); }
.check-banner.warn { background: var(--amber-soft); border: 1px solid var(--amber-border); color: var(--amber); }
.check-banner.bad { background: var(--bad-soft); border: 1px solid var(--bad-border); color: var(--bad); }
.check-detail { font-weight: 450; opacity: .85; font-size: 12px; }
.edit-table td.gtcol, .edit-table th.gtcol { text-align: right; white-space: nowrap; }
.gt { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; cursor: help; }

/* ---- データテーブル ---- */
.db-table { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--surface); }
.db-table th { text-align: left; font-size: 11.5px; font-weight: 600; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); position: sticky; top: 0; z-index: 1; }
.db-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.db-table td[contenteditable]:focus { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 4px; background: var(--surface); }
.db-table tr.is-pending td:first-child { box-shadow: inset 3px 0 0 var(--amber-border); }
.db-table .row-actions { display: flex; gap: 2px; justify-content: flex-end; }

/* ---- 分析カード ---- */
.an-card.warn { border-color: var(--amber-border); background: var(--amber-soft); }
.an-card.warn .an-card-value { color: var(--amber); }

/* ---- v2 レイアウト補正 ----
   データ主体の画面なので本文幅を広げる。また旧レビュー表（件数/追加列）向けに
   書かれていた nth-child の固定幅が新しい列構成に当たって金額・状態列を潰すので、
   新レイアウトに合わせて上書きする。 */
main { max-width: 1440px; }

.review-table th:nth-child(5), .review-table td:nth-child(5),
.review-table th:nth-child(7), .review-table td:nth-child(7) { width: auto; }
.review-table th.flagcol, .review-table td.flagcol { width: 250px; white-space: normal; line-height: 1.75; }
.review-table th.num, .review-table td.num { width: 110px; }
.review-table th.grpcol, .review-table td.grpcol { width: 140px; }
.review-table th.stcol, .review-table td.stcol { width: 96px; }
.review-table th.actcol, .review-table td.actcol { width: 78px; white-space: nowrap; text-align: right; }
.review-table td.actcol { padding-left: 4px; padding-right: 10px; }

/* ツールバーが折り返したときもキーボードヒントは右端に置く */
.kbd-hint { margin-left: auto; }

/* 重複スキップは「エラー」ではないので赤くしない */
.job-table tr .jchip.st-dup + .jerr, .job-table td .jerr.neutral { color: var(--muted); }

/* ---- 明細編集テーブルの行揃え ----
   input と textarea で箱の高さが違い、1行しかない行でも文字の縦位置がずれていた。
   両者の padding / line-height / 高さを揃えて、同じ位置に文字が来るようにする。
   （セル右の 36px の余白は、いまは使っていない保存ボタン用だったので詰める） */
.edit-table input, .edit-table textarea {
  padding: 9px 10px;
  line-height: 1.45;
  box-sizing: border-box;
  min-height: 38px;
}
.edit-table input { height: 38px; }
.edit-table textarea { min-height: 38px; }
/* 金額・税率は数字なので右揃え + 等幅数字にして、桁を目で追えるようにする。
   また値の幅は決まっているので列幅を固定し、店名・内訳に幅を回す。 */
.edit-table td.numcell input, .edit-table td.numcell textarea { text-align: right; font-variant-numeric: tabular-nums; }
.edit-table th.numcell { text-align: right; }
.edit-table th.numcell .thtype { margin-left: 4px; }
.edit-table th.numcell, .edit-table td.numcell { width: 130px; }

.check-banner.info { background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--muted); }
.check-banner .check-detail { margin-left: 4px; }

/* 領収書1枚あたりの合計はヘッダーに置く（行ごとの値ではないため） */
.receipt-total { display: inline-flex; align-items: baseline; gap: 6px; margin-left: 12px; padding-left: 12px; border-left: 1px solid var(--border-strong); cursor: help; }
.receipt-total .rt-label { font-size: 11.5px; color: var(--muted-2); }
.receipt-total .rt-value { font-size: 13.5px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.check-banner .check-detail.strong { font-weight: 700; font-variant-numeric: tabular-nums; }

/* 分析: セクション見出しと未承認金額の強調 */
.an-h { font-size: 14px; font-weight: 700; margin: 24px 0 10px; color: var(--text); }
/* API 利用セクションの小見出し。an-h の下にもう一段。 */
.an-h3 { font-size: 12px; font-weight: 700; margin: 18px 0 8px; color: var(--muted); letter-spacing: .04em; }
.an-note { font-size: 12.5px; margin: 10px 2px 0; }
.an-table td.num.pend { color: var(--amber); font-weight: 650; }

/* 勘定科目の定義テーブル */
.acct-card { margin-bottom: 22px; }
.acct-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.acct-head .muted { margin: 6px 0 0; font-size: 12.5px; max-width: 720px; }
.acct-wrap { max-height: 460px; overflow-y: auto; }
#acctTable th { font-size: 11.5px; }
#acctTable td { padding: 4px 8px; }
#acctTable input { width: 100%; border: 1px solid transparent; background: transparent; border-radius: 6px; padding: 7px 8px; font: inherit; font-size: 13px; }
#acctTable input:hover { border-color: var(--border); }
#acctTable input:focus { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: 0; }
#acctTable .acct-name { font-weight: 650; }
#acctTable td:nth-child(1) { width: 130px; }
#acctTable td:nth-child(2), #acctTable th:nth-child(2) { width: 90px; }
#acctTable td:nth-child(4), #acctTable th:nth-child(4) { width: 220px; }
#acctTable td:nth-child(5), #acctTable th:nth-child(5) { width: 58px; }
#acctTable .acct-act { width: 74px; white-space: nowrap; text-align: right; }
#acctTable tr.inactive { opacity: .45; }
#acctTable tr.inactive .acct-name { text-decoration: line-through; }

/* ---- 重複の比較 ---- */
.flag.clickable { cursor: pointer; gap: 4px; }
.flag.clickable:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.check-banner .dup-open { margin-left: auto; flex: none; }

.dup-overlay { align-items: flex-start; padding: 40px 20px; overflow-y: auto; }
.dup-box { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); width: min(1180px, 100%); padding: 20px 22px 18px; }
.dup-head { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.dup-head .spacer { flex: 1; }
.dup-sub { font-size: 12.5px; margin: 8px 0 16px; }
.dup-cmp { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px) { .dup-cmp { grid-template-columns: 1fr; } }
.dup-pane { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); }
.dup-pane.mine { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.dup-pane-title { padding: 9px 13px; font-size: 12.5px; font-weight: 700; background: var(--surface); border-bottom: 1px solid var(--border); }
.dup-pane.mine .dup-pane-title { color: var(--accent); }
.dup-view { height: 320px; overflow: auto; background: #fff; display: flex; align-items: flex-start; justify-content: center; cursor: zoom-in; }
.dup-view img, .dup-view canvas { max-width: 100%; height: auto; display: block; }
.dup-fields { display: grid; grid-template-columns: 92px 1fr; gap: 2px 12px; margin: 0; padding: 12px 13px; background: var(--surface); font-size: 13px; }
.dup-fields dt { color: var(--muted); font-size: 11.5px; padding-top: 3px; }
.dup-fields dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.dup-fields dd.dup-empty { color: var(--muted-2); font-weight: 400; }
.dup-fields dd.dup-small { font-weight: 400; font-size: 12px; color: var(--muted); }
.dup-foot { display: flex; align-items: center; margin-top: 18px; }
.dup-foot .spacer { flex: 1; }
