:root {
  --bg: #f5f7f8;
  --surface: #fff;
  --surface-alt: #eef2f3;
  --line: #d8e0e3;
  --text: #182225;
  --muted: #657377;
  --accent: #0f766e;
  --danger: #b42318;
  --shadow: 0 14px 38px rgba(25, 36, 42, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", Meiryo, system-ui, sans-serif;
}
button, input, textarea, select { font: inherit; }
button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 14px;
  cursor: pointer;
}
button:hover { border-color: var(--accent); }
.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.danger { color: var(--danger); }
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: rgba(245, 247, 248, 0.96);
  padding: 12px 18px;
}
.back-link {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--text);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  text-decoration: none;
}
.app-header h1 { margin: 0; font-size: 20px; }
.app-header p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.receipt-shell {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(320px, 1fr) minmax(320px, 460px);
  gap: 16px;
  padding: 16px;
}
.capture-panel, .list-panel, .detail-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 14px;
}
.camera-box {
  display: grid;
  gap: 8px;
  place-items: center;
  min-height: 154px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface-alt);
  padding: 14px;
  text-align: center;
  cursor: pointer;
}
.camera-box input { display: none; }
.camera-box span, label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.camera-box strong { font-size: 18px; }
.camera-box small { color: var(--muted); overflow-wrap: anywhere; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}
label { display: grid; gap: 6px; }
.full-span { grid-column: 1 / -1; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 10px 11px;
}
textarea { resize: vertical; }
.actions, .toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.toolbar { margin-top: 0; }
.toolbar input { flex: 1 1 220px; }
.ocr-status {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf9;
  color: var(--muted);
  padding: 9px 10px;
  font-size: 12px;
  line-height: 1.5;
}
.compliance-note {
  display: grid;
  gap: 4px;
  margin: 12px 0;
  border: 1px solid #f3d08a;
  border-radius: 8px;
  background: #fffbeb;
  padding: 10px;
  font-size: 12px;
  line-height: 1.6;
}
.compliance-note span { color: #7c5d12; }
.receipt-list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 190px);
  overflow: auto;
}
.receipt-row {
  display: grid;
  gap: 4px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  text-align: left;
}
.receipt-row.active { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12); }
.receipt-row strong, .receipt-row span { overflow-wrap: anywhere; }
.receipt-row span, .audit-log span { color: var(--muted); font-size: 12px; }
.row-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.badge {
  width: fit-content;
  border-radius: 999px;
  background: #eef2f3;
  color: var(--muted);
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 800;
}
.badge.checked, .badge.exported { background: #f0fdf4; color: #15803d; }
.badge.void { background: #fef2f2; color: var(--danger); }
.preview {
  display: grid;
  place-items: center;
  min-height: 260px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf9;
  overflow: hidden;
}
.preview img, .preview embed {
  width: 100%;
  max-height: 68vh;
  object-fit: contain;
}
.preview.empty { color: var(--muted); }
.audit-log {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}
.audit-entry {
  display: grid;
  gap: 3px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
  font-size: 13px;
}
@media (max-width: 1120px) {
  .receipt-shell { grid-template-columns: 1fr 1fr; }
  .detail-panel { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .app-header { grid-template-columns: auto 1fr; }
  .app-header button { grid-column: 1 / -1; }
  .receipt-shell { grid-template-columns: 1fr; padding: 10px; }
  .form-grid { grid-template-columns: 1fr; }
}
