/* ============================================================
   china/assets/invoice_import.css (v2)
   RC中国流通 請求書取込画面 スタイル
   変更点 (v1→v2):
     - KPIカード(プレビュー画面上部)を追加
     - 採番バッジ・採番カード装飾を追加
   ============================================================ */

* { box-sizing: border-box; }
body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN",
               "Yu Gothic UI", Meiryo, sans-serif;
  font-size: 14px;
  background: #f4f6f9;
  color: #1f2937;
  line-height: 1.6;
}

/* --------- 上部バー --------- */
.topbar {
  background: #1e3a5f;
  color: #fff;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  box-shadow: 0 2px 4px rgba(0,0,0,.08);
}
.topbar h1 { margin: 0; font-size: 18px; font-weight: 600; }
.topbar nav { display: flex; gap: 16px; margin-left: auto; }
.topbar nav a {
  color: #d6e4f0; text-decoration: none; font-size: 14px;
  padding: 4px 10px; border-radius: 4px;
}
.topbar nav a:hover { background: rgba(255,255,255,.08); }
.topbar nav a.current { background: rgba(255,255,255,.15); color: #fff; }

.container {
  max-width: 1200px;
  margin: 24px auto;
  padding: 0 16px;
}

/* --------- ステップインジケータ --------- */
.stepper {
  list-style: none;
  display: flex;
  gap: 0;
  padding: 0;
  margin: 0 0 24px 0;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.stepper li {
  flex: 1;
  padding: 14px 20px;
  text-align: center;
  background: #f8fafc;
  color: #94a3b8;
  border-right: 1px solid #e2e8f0;
  font-size: 13px;
  font-weight: 500;
}
.stepper li:last-child { border-right: none; }
.stepper li.current {
  background: #1e3a5f;
  color: #fff;
}
.stepper li.done {
  background: #ecfdf5;
  color: #059669;
}
.stepper li.done::before { content: "✓ "; }

/* --------- アラート --------- */
.alert {
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 14px;
}
.alert ul { margin: 4px 0 0 20px; padding: 0; }
.alert-error { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert-success { background: #ecfdf5; border: 1px solid #a7f3d0; color: #047857; }

/* --------- カード --------- */
.card {
  background: #fff;
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.card h2 {
  margin: 0 0 12px 0;
  font-size: 17px;
  color: #1e3a5f;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card .hint {
  color: #64748b;
  font-size: 13px;
  margin: 0 0 16px 0;
}
.hint-small { color: #94a3b8; font-size: 12px; margin: 4px 0 12px 0; }

/* --------- アップロードゾーン --------- */
.upload-form { max-width: 600px; }
.upload-zone {
  position: relative;
  border: 2px dashed #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  margin-bottom: 12px;
  transition: all .2s;
}
.upload-zone:hover { border-color: #3b82f6; background: #eff6ff; }
.upload-zone.dragover {
  border-color: #1e3a5f;
  background: #dbeafe;
  border-style: solid;
}
.upload-zone input[type=file] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer;
}
.upload-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  cursor: pointer;
  text-align: center;
}
.upload-label.has-file { padding: 32px 24px; opacity: .6; }
.upload-label .icon { font-size: 48px; margin-bottom: 12px; }
.upload-label .text { font-size: 14px; color: #475569; }
.upload-label .text small { color: #94a3b8; font-size: 12px; }

/* --------- 選択中ファイル情報 --------- */
.file-info {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 12px;
}
.file-info-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.file-info-label { font-size: 12px; color: #047857; font-weight: 500; }
.file-info-name {
  font-weight: 500;
  color: #064e3b;
  word-break: break-all;
  flex: 1 1 auto;
}
.file-info-size {
  font-family: monospace;
  font-size: 12px;
  color: #047857;
  background: rgba(255,255,255,0.5);
  padding: 2px 8px;
  border-radius: 4px;
}
.file-info-clear {
  background: none;
  border: none;
  color: #047857;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  border-radius: 4px;
}
.file-info-clear:hover { background: rgba(0,0,0,0.05); color: #991b1b; }

/* --------- プレビュー画面の取込元ファイル表示 --------- */
.source-file-info {
  background: #f0f9ff;
  border-left: 3px solid #3b82f6;
  padding: 8px 14px;
  margin-bottom: 16px;
  font-size: 13px;
  color: #1e40af;
}
.source-file-info strong { color: #1e3a5f; }
.source-file-info .size {
  font-family: monospace;
  font-size: 11px;
  color: #64748b;
  margin-left: 4px;
}

/* --------- 送信ボタン無効状態 --------- */
.btn-primary:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
}
.btn-primary:disabled:hover { background: #cbd5e1; }

/* --------- ボタン --------- */
.btn {
  display: inline-block;
  padding: 10px 20px;
  border-radius: 6px;
  border: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all .15s;
}
.btn-primary {
  background: #1e3a5f;
  color: #fff;
}
.btn-primary:hover { background: #2c4f7d; }
.btn-secondary {
  background: #fff;
  color: #475569;
  border: 1px solid #cbd5e1;
}
.btn-secondary:hover { background: #f1f5f9; }

/* --------- バッジ --------- */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  background: #e0e7ff;
  color: #3730a3;
}
.badge-dup { background: #fee2e2; color: #991b1b; }
.badge-new { background: #dcfce7; color: #166534; }
.badge-reuse { background: #fef3c7; color: #92400e; }
.badge-cat { letter-spacing: .03em; }
.badge-cat.cat-cn_food   { background: #fef3c7; color: #92400e; }
.badge-cat.cat-india_cosme { background: #fce7f3; color: #9d174d; }
.badge-cat.cat-teiban     { background: #dbeafe; color: #1e40af; }
.badge-office { background: #f1f5f9; color: #475569; }
.badge-tax { background: #f0fdfa; color: #0f766e; }

.invoice-date-text {
  color: #94a3b8;
  font-size: 12px;
  margin-left: 6px;
}

/* --------- 警告 --------- */
.warnings {
  padding: 10px 16px;
  background: #fffbeb;
  border-bottom: 1px solid #fde68a;
}
.warning-item {
  font-size: 12px;
  color: #92400e;
  margin: 2px 0;
}

/* --------- 連絡事項 --------- */
.invoice-note {
  padding: 8px 16px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  font-size: 12px;
  color: #475569;
  line-height: 1.5;
}
.invoice-note small { color: #94a3b8; }

/* --------- マッチステータス --------- */
.match-ok { color: #059669; font-weight: 600; }
.match-ng {
  display: inline-block;
  padding: 1px 6px;
  font-size: 10px;
  background: #fee2e2;
  color: #991b1b;
  border-radius: 3px;
}
.items-table small { color: #94a3b8; font-size: 10px; margin-left: 2px; }

.legend {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 3px;
  font-size: 11px;
  margin: 0 2px;
}
.legend.dup { background: #fee2e2; color: #991b1b; }
.legend.new { background: #dcfce7; color: #166534; }
.legend.reuse { background: #fef3c7; color: #92400e; }

/* --------- 請求書カード --------- */
.invoice-cards { display: flex; flex-direction: column; gap: 16px; }
.invoice-card {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
.invoice-card.is-duplicate { opacity: .65; background: #fafafa; }
.invoice-card.is-reuse { border-left: 3px solid #f59e0b; }

.invoice-card .card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  flex-wrap: wrap;
  gap: 8px;
}
.select-row {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}
.select-row input[type=checkbox] { width: 18px; height: 18px; cursor: pointer; }
.invoice-no { font-weight: 600; font-size: 15px; color: #1e3a5f; }
.invoice-date { color: #64748b; font-size: 13px; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; }

/* --------- 明細テーブル --------- */
.items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.items-table th, .items-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #f1f5f9;
  text-align: left;
}
.items-table th {
  background: #fcfcfd;
  color: #64748b;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.items-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.items-table tfoot td {
  background: #f8fafc;
  font-weight: 500;
}
.item-name { font-weight: 500; color: #1f2937; }
.item-code { font-size: 11px; color: #94a3b8; font-family: monospace; }

/* --------- スケジュール --------- */
.schedule {
  margin: 12px 16px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #fafbfc;
}
.schedule > summary {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: #475569;
}
.schedule[open] > summary { border-bottom: 1px solid #e2e8f0; }
.schedule-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.schedule-table th {
  padding: 6px 14px;
  text-align: left;
  font-weight: normal;
  color: #64748b;
  width: 50%;
  background: #fcfcfd;
}
.schedule-table td {
  padding: 6px 14px;
  font-variant-numeric: tabular-nums;
  color: #1f2937;
}
.schedule-table td.highlight {
  background: #fef3c7;
  font-weight: 600;
}

/* --------- 重複注意書き --------- */
.dup-note {
  padding: 8px 16px;
  background: #fef2f2;
  color: #991b1b;
  font-size: 12px;
  border-top: 1px solid #fecaca;
}

/* --------- アクションバー --------- */
.action-bar {
  display: flex;
  justify-content: space-between;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
}

/* --------- サマリー --------- */
.summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin-bottom: 16px;
}
.summary-table th {
  text-align: left;
  padding: 10px 16px;
  background: #f8fafc;
  color: #475569;
  font-weight: 500;
  width: 30%;
  border-bottom: 1px solid #e2e8f0;
}
.summary-table td {
  padding: 10px 16px;
  border-bottom: 1px solid #e2e8f0;
}
.success-card { border-left: 4px solid #10b981; }

/* --------- フッター --------- */
.footer {
  text-align: center;
  padding: 20px;
  color: #94a3b8;
  font-size: 12px;
}

/* --------- KPIカード (プレビュー画面上部) --------- */
.kpi-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 16px 0 18px;
}
.kpi-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  position: relative;
  min-height: 70px;
}
.kpi-card .kpi-label {
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 4px;
  letter-spacing: 0.02em;
}
.kpi-card .kpi-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  font-feature-settings: "tnum";
  color: #0f172a;
}
.kpi-card .kpi-unit {
  font-size: 11px;
  color: #64748b;
  margin-left: 4px;
  display: inline-block;
  vertical-align: bottom;
}
.kpi-card .kpi-note {
  font-size: 10px;
  color: #92400e;
  margin-top: 6px;
  line-height: 1.4;
}
.kpi-total { border-left: 3px solid #6366f1; }
.kpi-total .kpi-value { color: #4338ca; }
.kpi-new { border-left: 3px solid #10b981; }
.kpi-new .kpi-value { color: #047857; }
.kpi-reuse { border-left: 3px solid #f59e0b; }
.kpi-reuse .kpi-value { color: #b45309; }
.kpi-dup { border-left: 3px solid #ef4444; }
.kpi-dup .kpi-value { color: #b91c1c; }

@media (max-width: 768px) {
  .kpi-cards { grid-template-columns: repeat(2, 1fr); }
}
