:root {
  color-scheme: light;
  --bg: #eef3f1;
  --paper: #ffffff;
  --paper-soft: #f7faf9;
  --ink: #18302d;
  --muted: #657672;
  --line: #d8e2df;
  --line-strong: #afc2bd;
  --brand: #174a45;
  --brand-2: #21756c;
  --brand-soft: #e3f2ef;
  --amber: #9d6100;
  --amber-soft: #fff3d8;
  --red: #b32d43;
  --red-soft: #fff0f2;
  --green: #28794b;
  --green-soft: #eaf7ee;
  --shadow: 0 12px 34px rgba(24, 48, 45, .1);
  --shadow-soft: 0 4px 14px rgba(24, 48, 45, .07);
  --radius: 12px;
  --radius-sm: 8px;
  font-family: Inter, "Yu Gothic UI", "Yu Gothic", Meiryo, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

.import-actions { display: grid; gap: 8px; margin: 16px 0; }
.import-actions small, .classification-help, .classification-message, .category-summary > small { color: var(--muted); font-size: 12px; line-height: 1.7; }
.button.small { padding: 7px 9px; font-size: 12px; }
.classification-card { padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper-soft); margin: 16px 0; }
.classification-card .section-title-row { flex-wrap: wrap; gap: 8px; }
.classification-card h3, .category-summary h3 { margin: 0; font-size: 15px; }
.allocation-rows { display: grid; gap: 10px; }
.allocation-row { display: grid; grid-template-columns: minmax(100px, 1.3fr) minmax(70px, .7fr) minmax(115px, 1fr) auto; gap: 7px; padding: 10px 0; border-top: 1px solid var(--line); align-items: end; }
.allocation-row .field { min-width: 0; margin: 0; gap: 5px; }
.allocation-row input { min-width: 0; width: 100%; font-size: 13px; padding: 8px; }
.allocation-row .field-label { font-size: 11px; }
.allocation-evidence { grid-column: 1 / -1; color: var(--muted); overflow-wrap: anywhere; font-size: 11px; }
.allocation-units { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }
.allocation-units summary { cursor: pointer; padding: 6px 0; }
.allocation-units .field-grid { padding-top: 6px; }
.allocation-context { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; border-left: 3px solid var(--line-strong); padding: 8px; background: #fff; }
.allocation-context .field:first-child, .allocation-context .usage-help { grid-column: 1 / -1; }
.allocation-context select { min-width: 0; width: 100%; font-size: 12px; padding: 8px; }
.usage-help { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.7; }
.facility-context-card { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; margin: 0 0 16px; background: #f7fafc; }
.facility-context-card h3 { font-size: 15px; margin: 0; }
.facility-context-card .field-grid { margin-top: 10px; }
.facility-context-card [hidden] { display: none !important; }
.usage-rule-settings { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.usage-rule-settings summary { cursor: pointer; font-weight: 700; font-size: 14px; }
.usage-rule-settings p { font-size: 12px; line-height: 1.7; }
.usage-rule-rows { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.writing-guide-card { border: 1px solid #a5cfc4; border-radius: var(--radius-sm); padding: 14px; background: #f4fbf7; margin: 0 0 18px; overflow-wrap: anywhere; }
.writing-guide-card .section-title-row { flex-wrap: wrap; gap: 8px; }
.writing-guide-card h3 { margin: 0; font-size: 16px; }
.guide-status { font-size: 13px; font-weight: 700; color: #6e4c0b; }
.guide-status.confirmed { color: var(--green); }
.guide-status.blocked { color: #a12d24; }
.guide-journal { background: white; border: 1px solid var(--line); padding: 10px; border-radius: 6px; font-size: 13px; }
.guide-journal p { margin: 4px 0; font-weight: 700; }
.guide-problems, .guide-instructions { font-size: 12px; padding-left: 20px; line-height: 1.8; }
.guide-problems { color: #7a4a0e; }
.guide-voucher { border-top: 1px solid var(--line); padding: 10px 0; }
.guide-voucher summary { cursor: pointer; font-size: 13px; font-weight: 700; }
.guide-voucher dl { display: grid; grid-template-columns: minmax(70px, .65fr) minmax(0, 2fr); gap: 6px 10px; font-size: 12px; line-height: 1.7; margin-bottom: 0; }
.guide-voucher dt { color: var(--muted); }
.guide-voucher dd { margin: 0; white-space: pre-line; }
.guide-text-details { font-size: 12px; }
.guide-text-details summary { cursor: pointer; padding: 6px 0; }
.guide-text-details textarea { width: 100%; margin-top: 6px; font-size: 12px; }
.allocation-footer { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin-top: 10px; flex-wrap: wrap; }
.allocation-footer strong { font-size: 12px; }
.classification-message { margin: 8px 0 0; }
.balance-error { color: var(--red); }
.allocation-row input.unclassified { border-color: var(--amber); background: var(--amber-soft); }
.receipt-form { container-type: inline-size; }
@container (max-width: 380px) {
  .allocation-row { grid-template-columns: minmax(0, 1fr) minmax(80px, .7fr); }
}
.category-summary { display: grid; gap: 12px; }
.category-total-row { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.rules-dialog { width: min(940px, calc(100vw - 32px)); max-height: 90vh; padding: 24px; border: 1px solid var(--line); border-radius: 14px; color: var(--ink); background: var(--paper); box-shadow: var(--shadow); }
.rules-dialog::backdrop { background: rgba(15, 40, 35, .5); }
.rules-dialog > p { font-size: 13px; line-height: 1.8; }
.rules-dialog h2 { margin-top: 0; }
.rule-rows { display: grid; gap: 12px; }
.rule-row { display: grid; grid-template-columns: minmax(140px, .6fr) minmax(250px, 2fr) auto; gap: 12px; align-items: center; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.rule-row .field { margin: 0; }
.rules-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
#rulesError { color: var(--red); }
.raw-ocr .button { margin-top: 10px; }

@media (max-width: 1450px) and (min-width: 1021px) {
  .status-row { display: none; }
  .topbar { grid-template-columns: 1fr auto; }
}
@media (max-width: 760px) {
  .allocation-row { grid-template-columns: minmax(100px, 1fr) minmax(80px, .7fr); }
  .rule-row { grid-template-columns: 1fr; gap: 8px; }
  .rules-dialog { padding: 16px; }
}
@media print { .rules-dialog { display: none !important; } }

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  min-width: 320px;
  height: 100%;
  margin: 0;
  color: var(--ink);
  background: var(--bg);
}

body {
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
label,
summary {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
.drop-zone:focus-within {
  outline: 3px solid rgba(33, 117, 108, .25);
  outline-offset: 2px;
}

.app-shell {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: 68px 1fr;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(250px, 1fr) auto minmax(390px, 1fr);
  gap: 18px;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 2px 18px rgba(24, 48, 45, .07);
  z-index: 5;
}

.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: #fff;
  background: var(--brand);
  box-shadow: 0 8px 18px rgba(23, 74, 69, .22);
}

.brand-mark svg {
  width: 34px;
  height: 34px;
}

.brand-name,
.brand-sub {
  display: block;
}

.brand-name {
  overflow: hidden;
  font-size: 17px;
  font-weight: 850;
  line-height: 1.15;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.brand-sub {
  margin-top: 4px;
  color: var(--brand-2);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .08em;
}

.status-row,
.top-actions,
.inline-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.top-actions {
  justify-content: flex-end;
}

.status-chip {
  min-height: 31px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--paper-soft);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.status-chip.safe {
  color: var(--green);
  border-color: #bfe0ca;
  background: var(--green-soft);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 4px rgba(40, 121, 75, .11);
}

.button {
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--ink);
  background: var(--paper);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(24, 48, 45, .05);
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease, background .15s ease;
}

.button:hover:not(:disabled) {
  border-color: var(--brand-2);
  box-shadow: var(--shadow-soft);
  transform: translateY(-1px);
}

.button:active:not(:disabled) {
  transform: translateY(0);
}

.button:disabled {
  cursor: not-allowed;
  opacity: .45;
}

.button.primary {
  color: #fff;
  border-color: var(--brand);
  background: var(--brand);
}

.button.primary:hover:not(:disabled) {
  background: var(--brand-2);
}

.button.quiet {
  border-color: var(--line);
  background: var(--paper-soft);
}

.button.danger-quiet {
  color: var(--red);
  border-color: #efcad0;
  background: var(--red-soft);
}

.button.danger {
  color: #fff;
  border-color: var(--red);
  background: var(--red);
}

.button.large {
  width: 100%;
  min-height: 46px;
  font-size: 14px;
}

.main-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(260px, 285px) minmax(560px, 1fr) minmax(300px, 325px);
  gap: 12px;
  padding: 12px;
}

.panel {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow-soft);
}

.panel-head {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.panel-head h1,
.panel-head h2 {
  margin: 2px 0 0;
  font-size: 16px;
  line-height: 1.25;
}

.eyebrow {
  margin: 0;
  color: var(--brand-2);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .1em;
}

.panel-body {
  min-height: 0;
  padding: 14px;
}

.scrollable {
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.count-badge,
.check-count {
  min-width: 44px;
  min-height: 28px;
  display: inline-grid;
  place-items: center;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--brand);
  background: var(--brand-soft);
  font-size: 12px;
  font-weight: 850;
}

.drop-zone {
  min-height: 142px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 15px;
  border: 1.5px dashed #81aaa4;
  border-radius: 11px;
  color: var(--brand);
  background: #f1f8f6;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}

.drop-zone:hover,
.drop-zone.dragging {
  border-color: var(--brand);
  background: var(--brand-soft);
  transform: translateY(-1px);
}

.drop-zone strong {
  font-size: 13px;
}

.drop-zone span,
.drop-zone small {
  color: var(--muted);
  font-size: 11px;
}

.drop-icon {
  width: 37px;
  height: 37px;
  display: grid;
  place-items: center;
  margin-bottom: 2px;
  border-radius: 10px;
  color: #fff !important;
  background: var(--brand-2);
}

.drop-icon svg {
  width: 25px;
  height: 25px;
}

.photo-tip {
  display: grid;
  gap: 3px;
  margin: 11px 0 13px;
  padding: 10px 11px;
  border-left: 3px solid #d6972d;
  border-radius: 4px 8px 8px 4px;
  color: #735118;
  background: var(--amber-soft);
  font-size: 11px;
  line-height: 1.55;
}

.receipt-list {
  display: grid;
  gap: 8px;
}

.empty-list {
  min-height: 88px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--muted);
  text-align: center;
}

.empty-list span {
  font-size: 12px;
  font-weight: 800;
}

.empty-list small {
  font-size: 10px;
  line-height: 1.5;
}

.receipt-item {
  position: relative;
  width: 100%;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: inherit;
  background: #fff;
  text-align: left;
  cursor: pointer;
}

.receipt-item:hover {
  border-color: #94b8b2;
  background: var(--paper-soft);
}

.receipt-item.selected {
  border-color: var(--brand-2);
  background: var(--brand-soft);
  box-shadow: inset 3px 0 0 var(--brand-2);
}

.receipt-thumb {
  width: 48px;
  height: 54px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.receipt-thumb img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.receipt-item-copy {
  min-width: 0;
}

.receipt-item-copy strong,
.receipt-item-copy span {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.receipt-item-copy strong {
  font-size: 12px;
}

.receipt-item-copy span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
}

.receipt-state {
  min-width: 22px;
  min-height: 22px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: var(--amber);
  background: var(--amber-soft);
  font-size: 11px;
  font-weight: 900;
}

.receipt-state.done {
  color: var(--green);
  background: var(--green-soft);
}

.detail-panel {
  position: relative;
}

.detail-head {
  min-height: 70px;
}

.detail-head .inline-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.detail-head .button {
  padding-inline: 9px;
  font-size: 11px;
  white-space: nowrap;
}

.detail-empty {
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 30px;
  color: var(--muted);
  text-align: center;
}

.detail-empty strong {
  color: var(--ink);
  font-size: 16px;
}

.detail-empty span {
  font-size: 12px;
}

.empty-illustration {
  width: 112px;
  color: #759d97;
}

.detail-content {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(200px, .78fr) minmax(320px, 1.22fr);
  overflow: hidden;
}

.image-stage {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 12px;
  border-right: 1px solid var(--line);
  background: #263532;
}

.image-toolbar {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 1px 10px;
  color: #dbe7e4;
  font-size: 10px;
}

.image-toolbar > span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.image-frame {
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: auto;
  border-radius: 8px;
  background-color: #dfe7e4;
  background-image: linear-gradient(45deg, rgba(255,255,255,.45) 25%, transparent 25%), linear-gradient(-45deg, rgba(255,255,255,.45) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, rgba(255,255,255,.45) 75%), linear-gradient(-45deg, transparent 75%, rgba(255,255,255,.45) 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}

.image-frame img {
  max-width: 100%;
  max-height: 100%;
  display: block;
  object-fit: contain;
  transform-origin: center;
  filter: drop-shadow(0 8px 20px rgba(0,0,0,.2));
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
}

.toggle input {
  width: 17px;
  height: 17px;
  accent-color: var(--brand-2);
}

.ocr-progress {
  padding: 11px 1px 0;
  color: #fff;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
  font-size: 10px;
}

.progress-track {
  height: 6px;
  display: block;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255,255,255,.2);
}

.progress-track span {
  width: 0;
  height: 100%;
  display: block;
  border-radius: inherit;
  background: #78d5c8;
  transition: width .2s ease;
}

.receipt-form {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 15px 22px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.review-banner {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border: 1px solid #efc5cc;
  border-radius: 8px;
  color: #8b2335;
  background: var(--red-soft);
  font-size: 11px;
  line-height: 1.5;
}

.review-icon {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--red);
  font-size: 12px;
  font-weight: 900;
}

.auto-fill-card {
  display: grid;
  gap: 11px;
  padding: 13px;
  border: 1.5px solid #85b9b1;
  border-radius: 10px;
  background: #f2faf8;
}

.auto-fill-heading {
  display: flex;
  align-items: center;
  gap: 9px;
  padding-bottom: 9px;
  border-bottom: 1px solid #c9e2dd;
  color: var(--brand);
  font-size: 12px;
}

.auto-fill-badge {
  padding: 4px 7px;
  border-radius: 999px;
  color: #fff;
  background: var(--brand-2);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .04em;
}

.manual-fields-label {
  margin: 2px 0 -3px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.field-grid {
  display: grid;
  gap: 10px;
}

.field-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field-grid.receipt-id-grid {
  grid-template-columns: minmax(82px, .72fr) minmax(145px, 1.35fr) minmax(105px, 1fr);
}

.field {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 5px;
}

.field-label {
  color: #40534f;
  font-size: 11px;
  font-weight: 800;
}

.field-label em {
  color: var(--red);
  font-size: 9px;
  font-style: normal;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--ink);
  background: #fff;
  outline: none;
  box-shadow: inset 0 1px 2px rgba(24, 48, 45, .03);
}

.field input,
.field select {
  height: 38px;
  padding: 0 9px;
}

.field textarea {
  padding: 9px;
  resize: vertical;
  line-height: 1.55;
}

.field input:hover,
.field select:hover,
.field textarea:hover {
  border-color: #87aaa4;
}

.field.needs-review input,
.field.needs-review select,
.field.needs-review textarea,
.field.invalid input,
.field.invalid select,
.field.invalid textarea {
  border-color: #dd7888;
  background: #fffafb;
}

.field-note {
  min-height: 13px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.4;
}

.field.needs-review .field-note,
.field.invalid .field-note {
  color: var(--red);
  font-weight: 700;
}

.prefix-input {
  display: grid;
  grid-template-columns: 32px 1fr;
}

.prefix-input > span {
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-right: 0;
  border-radius: 7px 0 0 7px;
  color: var(--muted);
  background: var(--paper-soft);
  font-weight: 800;
}

.prefix-input input {
  border-radius: 0 7px 7px 0;
}

.raw-ocr {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-soft);
}

.raw-ocr summary {
  padding: 9px 11px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.raw-ocr textarea {
  width: calc(100% - 20px);
  margin: 0 10px 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: 11px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  resize: vertical;
}

.confirm-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px;
  border: 1px solid #b9d9c3;
  border-radius: 8px;
  background: var(--green-soft);
  cursor: pointer;
}

.confirm-box input {
  width: 20px;
  height: 20px;
  accent-color: var(--green);
}

.confirm-box span,
.confirm-box small {
  display: block;
}

.confirm-box strong {
  font-size: 12px;
}

.confirm-box small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
}

.summary-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.report-fields {
  display: grid;
  gap: 9px;
}

.sample-rule {
  display: flex;
  align-items: center;
  padding: 8px 9px;
  border: 1px solid #d8c58f;
  border-radius: 7px;
  color: #6d4d12;
  background: #fff9e9;
  font-size: 10px;
  line-height: 1.45;
}

.compact-rule {
  min-height: 35px;
}

.sample-rules {
  padding: 11px;
  border: 1px solid #c9d9d5;
  border-radius: 8px;
  background: #f5f9f8;
}

.sample-rules strong {
  font-size: 11px;
}

.sample-rules ul {
  margin: 7px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 9.5px;
  line-height: 1.65;
}

.field.compact {
  gap: 4px;
}

.field.compact input,
.field.compact select {
  height: 35px;
  font-size: 12px;
}

.compact-grid {
  gap: 8px;
}

.total-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 12px;
  align-items: end;
  padding: 14px;
  border-radius: 10px;
  color: #fff;
  background: var(--brand);
  box-shadow: 0 9px 22px rgba(23, 74, 69, .2);
}

.total-card span {
  font-size: 11px;
  font-weight: 800;
}

.total-card strong {
  grid-row: span 2;
  font-size: 25px;
  line-height: 1;
  letter-spacing: -.03em;
}

.total-card small {
  color: #c9e3de;
  font-size: 9px;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.section-title-row h3 {
  margin: 0;
  font-size: 13px;
}

.check-count {
  min-width: 36px;
  min-height: 24px;
  color: var(--red);
  background: var(--red-soft);
  font-size: 10px;
}

.check-count.clear {
  color: var(--green);
  background: var(--green-soft);
}

.check-list {
  display: grid;
  gap: 6px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.check-list li {
  position: relative;
  padding: 8px 9px 8px 30px;
  border: 1px solid #edd0d5;
  border-radius: 7px;
  color: #7f2836;
  background: #fff8f9;
  font-size: 10px;
  line-height: 1.45;
}

.check-list li::before {
  content: "!";
  position: absolute;
  top: 8px;
  left: 9px;
  width: 14px;
  height: 14px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--red);
  font-size: 8px;
  font-weight: 900;
}

.check-list li.success-check {
  color: var(--green);
  border-color: #c7e3cf;
  background: var(--green-soft);
}

.check-list li.success-check::before {
  content: "✓";
  background: var(--green);
}

.check-list li.muted-check {
  color: var(--muted);
  border-color: var(--line);
  background: var(--paper-soft);
}

.check-list li.muted-check::before {
  content: "i";
  background: #7a8c88;
}

.privacy-card {
  padding: 11px;
  border: 1px solid #ead4a5;
  border-radius: 8px;
  color: #684a16;
  background: #fff8e8;
}

.privacy-card strong {
  font-size: 11px;
}

.privacy-card p {
  margin: 5px 0 0;
  font-size: 9px;
  line-height: 1.55;
}

.export-stack {
  display: grid;
  gap: 8px;
  margin-top: auto;
}

.export-stack > small {
  color: var(--muted);
  font-size: 9px;
  line-height: 1.5;
}

.export-toggle {
  color: var(--muted);
  font-size: 10px;
}

.toast-region {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.toast {
  max-width: 360px;
  padding: 11px 14px;
  border-radius: 8px;
  color: #fff;
  background: #223a37;
  box-shadow: var(--shadow);
  font-size: 12px;
  font-weight: 750;
  line-height: 1.5;
  animation: toast-in .2s ease both;
}

.toast.error {
  background: #8f2638;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(14, 29, 27, .56);
  backdrop-filter: blur(3px);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(440px, 100%);
  padding: 22px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(10, 29, 26, .28);
}

.modal h2 {
  margin: 0;
  font-size: 18px;
}

.modal p {
  margin: 10px 0 20px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.print-document {
  display: none;
}

@media (max-width: 1240px) {
  .status-row {
    display: none;
  }

  .topbar {
    grid-template-columns: minmax(250px, 1fr) auto;
  }

  .main-grid {
    grid-template-columns: 260px minmax(500px, 1fr) 300px;
  }

  .detail-content {
    grid-template-columns: minmax(190px, .65fr) minmax(310px, 1.35fr);
  }
}

@media (max-width: 1180px) {
  body {
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100vh;
    display: block;
  }

  .topbar {
    position: sticky;
    top: 0;
    grid-template-columns: 1fr auto;
  }

  .top-actions .danger-quiet {
    display: none;
  }

  .main-grid {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    align-items: start;
  }

  .panel {
    min-height: 520px;
  }

  .summary-panel {
    grid-column: 1 / -1;
    min-height: auto;
  }

  .summary-body {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) minmax(280px, 1fr);
  }
}

@media (max-width: 860px) {
  .topbar {
    position: static;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .app-shell {
    padding-top: 0;
  }

  .brand {
    justify-content: center;
  }

  .top-actions {
    justify-content: center;
    flex-wrap: wrap;
  }

  .main-grid {
    display: block;
    padding: 9px;
  }

  .panel {
    min-height: 0;
    margin-bottom: 9px;
  }

  .receipt-panel .panel-body {
    max-height: none;
  }

  .detail-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .inline-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .inline-actions .button {
    flex: 1 1 auto;
  }

  .detail-content {
    display: block;
  }

  .image-stage {
    height: 480px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .receipt-form {
    overflow: visible;
  }

  .field-grid.two,
  .field-grid.three,
  .field-grid.receipt-id-grid,
  .summary-body {
    grid-template-columns: 1fr;
  }
}

.voucher-page { background: #fff; color: #000; font-family: "Hiragino Mincho ProN", "Yu Mincho", "MS Mincho", serif; box-sizing: border-box; }
.voucher-journal { width: 277mm; page: voucher-journal; }
.voucher-payment { width: 190mm; page: voucher-payment; padding-top: 7mm; }
.voucher-svg { display: block; width: 100%; height: auto; }
.voucher-meta { min-height: 4mm; display: flex; justify-content: space-between; gap: 5mm; font: 7pt/1.4 sans-serif; overflow-wrap: anywhere; }
.voucher-purchase-heading { text-align: center; font: 700 15pt/1.4 "Yu Gothic", sans-serif; letter-spacing: 4pt; }
.voucher-purchase-rule { text-align: center; font: 700 10pt/1.4 "Yu Gothic", sans-serif; margin-bottom: 2mm; }
.voucher-rules { margin-top: 3mm; font: 8pt/1.6 "Yu Gothic", sans-serif; }
.voucher-preview-dialog { width: min(1240px, 96vw); max-width: 96vw; max-height: 94vh; padding: 0; color: var(--ink); border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.voucher-preview-dialog::backdrop { background: rgba(15,40,35,.5); }
.voucher-preview-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 16px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 1; }
.voucher-preview-toolbar h2 { margin: 0; font-size: 17px; }
.voucher-preview-toolbar > span { flex: 1; font-size: 12px; color: var(--muted); }
.voucher-preview-pages { padding: 22px; overflow: auto; }
.voucher-preview-pages .voucher-page { margin: 0 auto 20px; padding: 10mm; box-sizing: content-box; box-shadow: var(--shadow); }
.voucher-preview-pages .voucher-journal { min-height: 190mm; }
.voucher-preview-pages .voucher-payment { min-height: 277mm; }
.voucher-preview-pages .voucher-payment .voucher-purchase-heading { padding-top: 7mm; }

@page voucher-journal { size: A4 landscape; margin: 10mm; }
@page voucher-payment { size: A4 portrait; margin: 10mm; }
@media print {
  html, body { width: auto; height: auto; min-width: 0; overflow: visible; color: #000; background: #fff; margin: 0; padding: 0; }
  .app-shell, .toast-region, .modal-backdrop, dialog { display: none !important; }
  .print-document { display: block; }
  .voucher-page { margin: 0; break-after: page; break-inside: avoid; }
  .voucher-page:last-child { break-after: auto; }
}

