*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Hiragino Kaku Gothic ProN", "Meiryo", sans-serif;
  background: #f5f7fb;
  color: #24313f;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.demo-banner {
  background: #fff3cd;
  border-bottom: 1px solid #ffc107;
  color: #7a5c00;
  font-size: .82rem;
  font-weight: 600;
  text-align: center;
  padding: 7px 16px;
}
.analyze-unavailable {
  margin-top: 8px;
  font-size: .82rem;
  color: #999;
  text-align: center;
}
.privacy-note {
  margin-top: 14px;
  font-size: .76rem;
  color: #7a8fa3;
  line-height: 1.7;
  text-align: center;
  padding: 10px 14px;
  background: #f5f8fb;
  border-radius: 6px;
  border: 1px solid #e2e9f2;
}

.site-header {
  background:
    linear-gradient(135deg, rgba(20, 83, 94, .96) 0%, rgba(39, 84, 119, .94) 58%, rgba(62, 90, 120, .92) 100%),
    radial-gradient(circle at 78% 22%, rgba(251, 191, 36, .28), transparent 26%);
  color: #fff;
  padding: 28px 16px 30px;
  box-shadow: 0 8px 24px rgba(23, 44, 64, .18);
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 28px;
  align-items: center;
}
.hero-kicker {
  color: #bdebdc;
  font-size: .86rem;
  font-weight: 700;
  margin-bottom: 8px;
}
.site-header h1 { font-size: 2.05rem; font-weight: 700; line-height: 1.25; }
.header-sub { margin-top: 8px; font-size: .98rem; opacity: .92; line-height: 1.7; max-width: 560px; }

.hero-visual {
  min-height: 170px;
  position: relative;
}
.hero-receipt {
  position: absolute;
  right: 72px;
  top: 0;
  width: 178px;
  min-height: 182px;
  padding: 22px 18px 18px;
  border-radius: 8px;
  background: #fff;
  color: #526070;
  box-shadow: 0 18px 36px rgba(10, 30, 50, .24);
  transform: rotate(-3deg);
}
.receipt-pin {
  position: absolute;
  top: 10px;
  left: 50%;
  width: 34px;
  height: 6px;
  transform: translateX(-50%);
  border-radius: 10px;
  background: #dfe7ef;
}
.receipt-title {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .12em;
  color: #2f6f73;
  margin-bottom: 12px;
  text-align: center;
}
.receipt-line,
.receipt-total,
.result-bar {
  height: 8px;
  border-radius: 10px;
  background: #e7edf3;
}
.receipt-line { margin-bottom: 9px; }
.receipt-line.strong { width: 78%; background: #c9d8e5; }
.receipt-row {
  display: grid;
  grid-template-columns: 1fr 42px;
  gap: 10px;
  align-items: center;
  margin: 11px 0;
}
.receipt-row span,
.receipt-row b {
  display: block;
  height: 7px;
  border-radius: 10px;
  background: #e6edf4;
}
.receipt-row b { background: #d4e5de; }
.receipt-total { width: 70%; margin-left: auto; margin-top: 14px; background: #62b58f; }
.hero-result {
  position: absolute;
  right: 0;
  bottom: 6px;
  width: 170px;
  padding: 16px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 14px 30px rgba(10, 30, 50, .2);
}
.result-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #35a56f;
  margin-bottom: 12px;
}
.result-bar { width: 70%; margin-bottom: 9px; }
.result-bar.wide { width: 100%; background: #cfe0e8; }
.result-chip {
  display: inline-flex;
  align-items: center;
  height: 24px;
  margin-top: 2px;
  padding: 0 10px;
  border-radius: 999px;
  background: #e9f7ef;
  color: #257a51;
  font-size: .72rem;
  font-weight: 700;
}

.container {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 16px 40px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

.card {
  background: #fff;
  border-radius: 10px;
  padding: 24px 20px;
  border: 1px solid #e2e9f2;
  box-shadow: 0 6px 18px rgba(35, 50, 70, .06);
  height: 100%;
  min-width: 0;
}
.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: #275477;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid #e4edf4;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.field-group { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: .82rem; font-weight: 700; color: #555; }

.date-input-row {
  display: grid;
  grid-template-columns: 1fr 44px;
  gap: 8px;
  position: relative;
}
.date-picker-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #cdd8ea;
  border-radius: 6px;
  background: #fff;
  color: #275477;
  cursor: pointer;
}
.date-picker-btn:hover {
  background: #edf6f3;
  border-color: #70b99d;
}
.date-picker-native {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.date-picker-icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.two-col-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  align-items: start;
  min-width: 0;
}
.upload-col,
.result-col {
  min-width: 0;
}
@media (min-width: 768px) {
  .two-col-grid.has-results {
    grid-template-columns: minmax(300px, 35%) minmax(0, 65%);
  }
}

.drop-area {
  display: block;
  border: 2px dashed #94b8c8;
  border-radius: 10px;
  background: #f1f7f8;
  text-align: center;
  padding: 28px 16px;
  cursor: pointer;
  margin-bottom: 16px;
  position: relative;
  min-height: 140px;
  overflow: hidden;
}
.drop-area:hover, .drop-area:focus-within { background: #e7f3ef; border-color: #3f9872; }
.drop-area:hover .drop-icon-img,
.drop-area:focus-within .drop-icon-img {
  opacity: .82;
  filter: drop-shadow(0 4px 14px rgba(47, 111, 115, .38));
  transform: scale(1.06) translateY(-2px);
}
.drop-area input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}
.drop-icon-img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  display: block;
  margin: 0 auto 12px;
  opacity: .55;
  filter: drop-shadow(0 2px 10px rgba(47, 111, 115, .20));
  transition: opacity .22s, filter .22s, transform .22s;
}
.drop-text { font-size: .95rem; color: #555; line-height: 1.6; overflow-wrap: anywhere; }
.drop-hint { font-size: .8rem; color: #888; }
.preview-wrap img {
  max-width: 100%;
  max-height: 360px;
  border-radius: 8px;
  object-fit: contain;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}

.alert {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: .88rem;
  margin-bottom: 14px;
  line-height: 1.5;
}
.alert-error { background: #fff0f0; border: 1px solid #f5c6cb; color: #c0392b; }
.alert-warning { background: #fff3e0; border: 1px solid #ffb74d; color: #7a4400; font-weight: 600; }
.alert-ai { background: #f7f4e7; border: 1px solid #dfca74; color: #685400; font-weight: 600; }
.alert-success { background: #e6f9ee; border: 1px solid #a9dfbf; color: #1e5c35; font-weight: 600; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: #2f6f73; color: #fff; }
.btn-primary:hover { background: #23565a; }
.btn-secondary { background: #edf4f6; color: #275477; border: 1px solid #c7d9e3; }
.btn-success { background: #2d8a57; color: #fff; }
.btn-success:hover { background: #236b44; }
.btn-candidate { background: #6b5a99; color: #fff; }
.btn-candidate:hover { background: #55477a; }
.btn-full { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: .88rem; }

.action-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

.btn-del {
  background: #fff;
  border: 1px solid #ddd;
  color: #999;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: .85rem;
  cursor: pointer;
}
.btn-del:hover { background: #fdecea; color: #c0392b; border-color: #f5c6cb; }

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.badge {
  font-size: .78rem;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 600;
}
.badge-ok { background: #e6f9ee; color: #257a51; border: 1px solid #a9dfbf; }

.table-wrap {
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 12px;
  border-radius: 8px;
  border: 1px solid #e0e8f5;
}
.result-table {
  width: 100%;
  min-width: 740px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: .88rem;
}
.result-table th {
  background: #edf4f6;
  color: #275477;
  font-weight: 700;
  padding: 10px 8px;
  text-align: left;
  border-bottom: 2px solid #cbdbe5;
  white-space: nowrap;
}
.result-table td {
  padding: 5px;
  border-bottom: 1px solid #eef0f5;
  vertical-align: middle;
}
.item-row:hover { background: #f7fbfa; }
.col-qty { width: 76px; }
.col-price { width: 126px; }
.col-memo { width: 120px; }
.col-del { width: 40px; }

.inp {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid #cdd8ea;
  border-radius: 6px;
  font-size: .9rem;
  font-family: inherit;
  background: #fafcff;
}
.inp:focus {
  outline: none;
  border-color: #2f6f73;
  box-shadow: 0 0 0 3px rgba(47,111,115,.14);
  background: #fff;
}
.inp-num {
  text-align: center;
  padding-left: 6px;
  padding-right: 6px;
  min-width: 0;
}
.inp-name { min-width: 0; }

.total-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #edf4f6;
  border: 1px solid #cbdbe5;
  border-radius: 8px;
  padding: 10px 16px;
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 12px;
  color: #275477;
}
.total-amount { font-size: 1.25rem; color: #2d8a57; }

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
  min-width: 560px;
}
.history-table th {
  background: #f2f4f8;
  color: #555;
  font-weight: 700;
  padding: 9px 10px;
  text-align: left;
  border-bottom: 2px solid #dde3ee;
  white-space: nowrap;
}
.history-row td {
  padding: 9px 10px;
  border-bottom: 1px solid #eef0f5;
}
.history-row--new td { background: #f0f9f4; font-weight: 600; }
.hist-date { color: #888; font-size: .82rem; white-space: nowrap; }
.hist-total { color: #2d8a57; font-weight: 700; white-space: nowrap; }
.history-note { margin-top: 10px; font-size: .78rem; color: #888; text-align: right; }
.history-empty { text-align: center; padding: 28px 16px; color: #888; }

.site-footer {
  text-align: center;
  padding: 16px;
  font-size: .78rem;
  color: #888;
  border-top: 1px solid #e8edf5;
  background: #fff;
}

@media (max-width: 600px) {
  body { overflow-x: hidden; }
  .container {
    padding-left: 10px;
    padding-right: 10px;
  }
  .site-header h1 { font-size: 1.5rem; }
  .site-header { padding: 22px 16px 24px; }
  .header-inner {
    grid-template-columns: 1fr;
    gap: 18px;
  }
  .header-sub { font-size: .9rem; }
  .hero-visual {
    min-height: 132px;
    max-width: 300px;
    width: 100%;
  }
  .hero-receipt {
    right: 82px;
    width: 142px;
    min-height: 138px;
    padding: 18px 14px 14px;
  }
  .hero-result {
    width: 138px;
    padding: 12px;
  }
  .card { padding: 18px 12px; width: 100%; }
  .meta-grid { grid-template-columns: 1fr; }
  .drop-area { padding: 24px 12px; }
  .drop-icon-img { width: 56px; height: 56px; }
  .result-table { min-width: 700px; font-size: .82rem; }
  .inp { padding: 6px 7px; }
  .btn { font-size: .95rem; padding: 11px 14px; }
  .action-btns { grid-template-columns: 1fr; }
  .col-qty { width: 72px; }
  .col-price { width: 116px; }
  .col-memo { width: 100px; }
  .inp-name { min-width: 0; }
}
