/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue-900: #1e3a5f;
  --blue-800: #1e429f;
  --blue-600: #1a56db;
  --blue-100: #e1effe;
  --blue-50:  #eff6ff;
  --green-600: #059669;
  --green-100: #d1fae5;
  --red-600:   #dc2626;
  --red-100:   #fee2e2;
  --yellow-600: #d97706;
  --yellow-100: #fef3c7;
  --gray-900: #111827;
  --gray-700: #374151;
  --gray-500: #6b7280;
  --gray-300: #d1d5db;
  --gray-100: #f3f4f6;
  --white:    #ffffff;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow:    0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
  --radius:    8px;
  --radius-lg: 12px;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Hiragino Kaku Gothic ProN', 'Meiryo', 'Yu Gothic', sans-serif;
  background: #f0f4f8;
  color: var(--gray-900);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
}

/* ===== Header ===== */
.site-header {
  background: linear-gradient(135deg, var(--blue-900) 0%, var(--blue-800) 100%);
  color: var(--white);
  padding: 0;
  box-shadow: var(--shadow-lg);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,.15);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.logo-text h1 { font-size: 18px; font-weight: 700; letter-spacing: -.3px; }
.logo-text p  { font-size: 11px; opacity: .75; margin-top: 2px; }

.header-badges {
  margin-left: auto;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.badge {
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.badge.green {
  background: rgba(5,150,105,.25);
  border-color: rgba(5,150,105,.4);
}

/* ===== Security Banner ===== */
.security-banner {
  background: var(--green-100);
  border-bottom: 1px solid #a7f3d0;
  padding: 10px 24px;
}

.security-banner-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.security-banner strong {
  color: var(--green-600);
  font-size: 13px;
}

.security-banner span {
  color: #065f46;
  font-size: 12px;
}

.security-items {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-left: 4px;
}

.security-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #065f46;
}

.security-item::before {
  content: '✓';
  color: var(--green-600);
  font-weight: 700;
}

/* ===== Main Layout ===== */
.main-container {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

/* ===== Step Indicator ===== */
.steps {
  display: flex;
  align-items: center;
  margin-bottom: 32px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 80px;
  opacity: .4;
  transition: opacity .2s;
}

.step.active  { opacity: 1; }
.step.done    { opacity: .85; }

.step-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--gray-300);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  background: var(--white);
  color: var(--gray-500);
  transition: all .2s;
}

.step.active .step-circle {
  border-color: var(--blue-600);
  background: var(--blue-600);
  color: var(--white);
  box-shadow: 0 0 0 4px var(--blue-100);
}

.step.done .step-circle {
  border-color: var(--green-600);
  background: var(--green-600);
  color: var(--white);
}

.step-label {
  font-size: 11px;
  color: var(--gray-500);
  text-align: center;
  white-space: nowrap;
}

.step.active .step-label { color: var(--blue-600); font-weight: 600; }
.step.done  .step-label  { color: var(--green-600); }

.step-connector {
  flex: 1;
  height: 2px;
  background: var(--gray-300);
  margin-top: -18px;
  min-width: 20px;
}

/* ===== Card ===== */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.card-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--gray-100);
}

.card-header h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-900);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-header p {
  font-size: 13px;
  color: var(--gray-500);
  margin-top: 4px;
}

.card-body { padding: 24px; }

/* ===== Upload Zone ===== */
.upload-zone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius-lg);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  background: var(--gray-100);
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--blue-600);
  background: var(--blue-50);
}

.upload-icon {
  font-size: 48px;
  margin-bottom: 12px;
  display: block;
}

.upload-zone h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.upload-zone p {
  font-size: 13px;
  color: var(--gray-500);
}

.upload-zone .btn-link {
  color: var(--blue-600);
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  background: none;
  border: none;
  font-size: 13px;
}

#file-input { display: none; }

/* ===== File Info ===== */
.file-info {
  background: var(--blue-50);
  border: 1px solid var(--blue-100);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

.file-info-icon { font-size: 24px; }
.file-info-name { font-weight: 600; color: var(--gray-900); }
.file-info-meta { font-size: 12px; color: var(--gray-500); }

/* ===== Mapping Table ===== */
.mapping-table {
  width: 100%;
  border-collapse: collapse;
}

.mapping-table th {
  background: var(--gray-100);
  padding: 10px 12px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-700);
  border-bottom: 1px solid var(--gray-300);
}

.mapping-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}

.mapping-table tr:last-child td { border-bottom: none; }

.field-label {
  font-weight: 600;
  font-size: 13px;
  color: var(--gray-900);
}

.field-desc {
  font-size: 11px;
  color: var(--gray-500);
  margin-top: 2px;
}

.required-badge {
  background: var(--red-100);
  color: var(--red-600);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: 6px;
}

.optional-badge {
  background: var(--gray-100);
  color: var(--gray-500);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: 6px;
}

.mapping-status {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}

.mapping-status.matched   { background: var(--green-100); color: var(--green-600); }
.mapping-status.unmatched { background: var(--gray-100);  color: var(--gray-500);  }
.mapping-status.required-missing { background: var(--red-100); color: var(--red-600); }

/* ===== Select ===== */
select, input[type="text"], input[type="number"], input[type="date"] {
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
  color: var(--gray-900);
  background: var(--white);
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}

select:focus, input:focus {
  outline: none;
  border-color: var(--blue-600);
  box-shadow: 0 0 0 3px rgba(26,86,219,.15);
}

/* ===== Form Grid ===== */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group { display: flex; flex-direction: column; gap: 5px; }

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-700);
  display: flex;
  align-items: center;
  gap: 4px;
}

.form-group .hint {
  font-size: 11px;
  color: var(--gray-500);
  margin-top: 2px;
}

.form-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--gray-700);
  padding: 12px 0 8px;
  border-bottom: 1px solid var(--gray-100);
  margin-bottom: 16px;
  grid-column: 1 / -1;
}

/* ===== Preview ===== */
.preview-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.summary-card {
  background: var(--gray-100);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-align: center;
}

.summary-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--blue-800);
}

.summary-label {
  font-size: 11px;
  color: var(--gray-500);
  margin-top: 2px;
}

.preview-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  max-height: 300px;
  overflow-y: auto;
}

.preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.preview-table th {
  background: var(--blue-900);
  color: var(--white);
  padding: 8px 10px;
  text-align: left;
  font-weight: 600;
  position: sticky;
  top: 0;
  white-space: nowrap;
}

.preview-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--gray-100);
  font-family: 'Courier New', monospace;
  white-space: nowrap;
}

.preview-table tr:nth-child(even) td { background: var(--gray-100); }
.preview-table .row-ok  td:first-child { border-left: 3px solid var(--green-600); }
.preview-table .row-err td:first-child { border-left: 3px solid var(--red-600); }

/* ===== Errors ===== */
.error-list {
  background: var(--red-100);
  border: 1px solid #fca5a5;
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-top: 12px;
}

.error-list h4 {
  color: var(--red-600);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}

.error-list ul {
  list-style: none;
  padding: 0;
}

.error-list li {
  font-size: 12px;
  color: #7f1d1d;
  padding: 2px 0;
}

.error-list li::before { content: '⚠ '; }

/* ===== Buttons ===== */
.btn-row {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
  flex-wrap: wrap;
}

.btn {
  padding: 10px 22px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
}

.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--blue-600);
  color: var(--white);
}
.btn-primary:hover:not(:disabled) {
  background: var(--blue-800);
  box-shadow: var(--shadow);
}

.btn-success {
  background: var(--green-600);
  color: var(--white);
}
.btn-success:hover:not(:disabled) {
  background: #047857;
  box-shadow: var(--shadow);
}

.btn-secondary {
  background: var(--white);
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--gray-100);
}

.btn-lg { padding: 14px 32px; font-size: 15px; }

/* ===== Download Section ===== */
.download-section {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border: 1px solid #bae6fd;
  border-radius: var(--radius-lg);
  padding: 28px;
  text-align: center;
  margin-top: 12px;
}

.download-section h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--blue-900);
  margin-bottom: 8px;
}

.download-section p {
  font-size: 13px;
  color: var(--gray-500);
  margin-bottom: 20px;
}

.download-options {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ===== Info Box ===== */
.info-box {
  background: var(--blue-50);
  border: 1px solid var(--blue-100);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 12px;
  color: #1e40af;
  margin-bottom: 16px;
}

.info-box strong { font-weight: 700; }

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .preview-summary { grid-template-columns: 1fr 1fr; }
  .header-badges { display: none; }
  .security-items { display: none; }
  .main-container { padding: 20px 16px 48px; }
}

/* ===== 振込元自動検出バナー ===== */
.sender-detect-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: linear-gradient(to right, #f0fdf4, #dcfce7);
  border: 1px solid #86efac;
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
}

.sender-detect-icon { font-size: 20px; flex-shrink: 0; margin-top: 1px; }

.sender-detect-body strong { font-weight: 700; color: var(--gray-900); }
.sender-detect-body p { color: var(--gray-600); margin-top: 2px; font-size: 12px; }

.sender-detect-detail {
  font-size: 11px;
  color: #166534;
  background: rgba(255,255,255,.6);
  border-radius: 4px;
  padding: 4px 8px;
  margin-top: 4px !important;
  font-family: 'Courier New', monospace;
  word-break: break-all;
}

/* ===== 支店検索 ===== */
.branch-loading {
  padding: 10px 14px;
  font-size: 13px;
  color: var(--gray-500);
  background: var(--gray-100);
  border-radius: var(--radius);
  border: 1px solid var(--gray-300);
}

.branch-load-error {
  padding: 10px 14px;
  font-size: 12px;
  color: var(--red-600);
  background: var(--red-100);
  border-radius: var(--radius);
  border: 1px solid #fca5a5;
}

#branch-search-container .bank-search-input-wrap { margin-bottom: 6px; }

/* ===== 統廃合警告 ===== */
.merger-warning-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--yellow-100);
  border: 1px solid #fcd34d;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 12px 16px;
  font-size: 13px;
}

.merger-warning-container {
  border: 1px solid #fcd34d;
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
}

.merger-card {
  padding: 12px 16px;
  background: var(--white);
  border-top: 1px solid #fef3c7;
}

.merger-card:first-child { border-top: none; }

.merger-card-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.merger-icon { font-size: 20px; flex-shrink: 0; margin-top: 1px; }

.merger-card-header strong { font-size: 13px; font-weight: 700; color: var(--gray-900); }

.merger-detail {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 3px;
}

.merger-fix-btn {
  margin-left: auto;
  flex-shrink: 0;
  white-space: nowrap;
  font-size: 12px !important;
  padding: 6px 14px !important;
}

.btn-sm { padding: 6px 12px !important; font-size: 12px !important; }

/* ===== サンプルダウンロードバナー ===== */
.sample-download-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  background: linear-gradient(to right, #f0fdf4, #dcfce7);
  border: 1px solid #bbf7d0;
  border-radius: var(--radius);
  padding: 16px 20px;
}

.sample-download-icon { font-size: 32px; flex-shrink: 0; }

.sample-download-text { flex: 1; }
.sample-download-text strong { font-size: 14px; font-weight: 700; color: var(--gray-900); }
.sample-download-text p { font-size: 12px; color: var(--gray-500); margin-top: 4px; line-height: 1.5; }

@media (max-width: 580px) {
  .sample-download-banner { flex-direction: column; text-align: center; }
}

/* ===== 銀行検索ウィジェット ===== */
.bank-search-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bank-search-input-wrap {
  position: relative;
}

.bank-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  pointer-events: none;
  z-index: 1;
}

.bank-search-input-wrap input {
  padding-left: 32px;
}

.bank-search-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  max-height: 280px;
  overflow-y: auto;
}

.bank-group-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--gray-500);
  padding: 6px 12px 2px;
  text-transform: uppercase;
  letter-spacing: .5px;
  background: var(--gray-100);
  border-top: 1px solid var(--gray-200);
  position: sticky;
  top: 0;
}

.bank-item {
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background .1s;
  border-bottom: 1px solid var(--gray-100);
}

.bank-item:hover,
.bank-item-active { background: var(--blue-50); }

.bank-item-empty {
  padding: 12px;
  color: var(--gray-500);
  font-style: italic;
  font-size: 12px;
  cursor: default;
}

.bank-code-badge {
  background: var(--blue-100);
  color: var(--blue-800);
  font-size: 11px;
  font-weight: 700;
  font-family: 'Courier New', monospace;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
  min-width: 36px;
  text-align: center;
}

.bank-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-900);
}

.bank-kana {
  font-size: 11px;
  color: var(--gray-500);
  margin-left: auto;
}

.bank-selected {
  font-size: 12px;
  color: var(--gray-500);
  padding: 5px 0;
}

.bank-selected-ok {
  color: var(--green-600);
  font-weight: 600;
}

.bank-direct-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 4px;
  padding: 12px;
  background: var(--gray-100);
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
}

/* ===== エラー行詳細 ===== */
.error-section-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--red-100);
  border: 1px solid #fca5a5;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 12px 16px;
  font-size: 13px;
}

.error-section-icon { font-size: 18px; flex-shrink: 0; }

.error-rows-container {
  border: 1px solid #fca5a5;
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
}

.error-row-card {
  border-top: 1px solid #fecaca;
  background: var(--white);
}

.error-row-card:first-child { border-top: none; }

.error-row-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: #fff5f5;
}

.error-row-badge {
  background: var(--red-600);
  color: var(--white);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}

.error-row-msg {
  font-size: 13px;
  color: #7f1d1d;
  font-weight: 600;
}

.error-row-table-wrap {
  overflow-x: auto;
  padding: 0 14px 12px;
}

.error-row-table {
  border-collapse: collapse;
  font-size: 12px;
  width: 100%;
  min-width: 600px;
  margin-top: 6px;
}

.error-row-table th {
  background: var(--gray-100);
  padding: 5px 10px;
  text-align: left;
  font-weight: 600;
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
  white-space: nowrap;
}

.error-row-table td {
  padding: 6px 10px;
  border: 1px solid var(--gray-200);
  font-family: 'Courier New', monospace;
  background: var(--white);
  white-space: nowrap;
}

.error-row-table .err-row-label {
  background: var(--gray-100);
  font-family: inherit;
  font-weight: 600;
  color: var(--gray-700);
}

/* エラー起因フィールドのハイライト */
.error-row-table .err-cell-hilit {
  background: #fef2f2 !important;
  border: 2px solid var(--red-600) !important;
  color: var(--red-600);
  font-weight: 700;
}

/* 空セル */
.error-row-table .err-cell-empty em {
  color: var(--gray-300);
  font-style: italic;
  font-size: 11px;
}

/* プレビューのエラーフラグ */
.err-flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  background: var(--red-600);
  color: var(--white);
  font-size: 10px;
  font-weight: 700;
  border-radius: 50%;
  margin-left: 4px;
  vertical-align: middle;
}

/* ===== 検出バナー ===== */
.detect-banner {
  background: linear-gradient(to right, #f0f9ff, #e0f2fe);
  border: 1px solid #bae6fd;
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.detect-icon { font-size: 24px; line-height: 1; flex-shrink: 0; margin-top: 2px; }

.detect-text { flex: 1; font-size: 13px; color: var(--blue-900); }
.detect-text strong { font-size: 14px; }

.detect-score {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--gray-700);
}

.score-bar {
  display: inline-block;
  width: 80px;
  height: 8px;
  background: var(--gray-300);
  border-radius: 4px;
  overflow: hidden;
  vertical-align: middle;
}

.score-fill {
  display: block;
  height: 100%;
  background: linear-gradient(to right, var(--blue-600), var(--green-600));
  border-radius: 4px;
  transition: width .4s ease;
}

/* ===== 行プレビューテーブル ===== */
.row-preview-wrap {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 360px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
}

.row-preview-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.row-preview-table thead th {
  background: var(--gray-100);
  color: var(--gray-700);
  padding: 6px 10px;
  text-align: center;
  font-weight: 700;
  border-bottom: 1px solid var(--gray-300);
  position: sticky;
  top: 0;
  min-width: 60px;
  white-space: nowrap;
}

.row-preview-table .rp-rownum {
  background: var(--gray-100);
  color: var(--gray-500);
  font-weight: 700;
  text-align: right;
  width: 80px;
  min-width: 80px;
  padding: 6px 8px;
  border-right: 1px solid var(--gray-300);
  position: sticky;
  left: 0;
  white-space: nowrap;
}

.row-preview-table tbody tr {
  cursor: pointer;
  transition: background .1s;
}

.row-preview-table tbody tr:hover td { background: var(--blue-50); }

.row-preview-table td {
  padding: 5px 10px;
  border-bottom: 1px solid var(--gray-100);
  white-space: nowrap;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--gray-700);
}

/* ヘッダー行ハイライト */
.row-preview-table .rp-header-row td {
  background: #fef9c3 !important;
  font-weight: 700;
  color: var(--gray-900);
  border-top: 2px solid var(--yellow-600);
  border-bottom: 2px solid var(--yellow-600);
}

.row-preview-table .rp-header-row .rp-rownum {
  background: var(--yellow-600) !important;
  color: var(--white);
}

/* 空行は薄く表示 */
.row-preview-table .rp-empty-row td { color: var(--gray-300); }

.rp-indicator {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 4px;
  vertical-align: middle;
  white-space: nowrap;
}

.rp-indicator-header {
  background: var(--yellow-600);
  color: var(--white);
}

.rp-more {
  color: var(--gray-500);
  font-style: italic;
  padding: 8px !important;
  text-align: center !important;
}

/* ===== Utility ===== */
.hidden { display: none !important; }
.text-sm { font-size: 12px; }
.text-muted { color: var(--gray-500); }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }

/* ==================== Pro バッジ ==================== */
.pro-badge {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  white-space: nowrap;
  text-decoration: none;
  transition: opacity .15s;
}
.pro-badge:hover { opacity: .85; }
.pro-badge.active {
  background: linear-gradient(135deg, #10b981, #059669);
}

/* ==================== テンプレートライブラリ ==================== */
.template-library {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--gray-100);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  padding: 10px 14px;
}
.template-library-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-700);
  white-space: nowrap;
}
.template-chips { display: flex; flex-wrap: wrap; gap: 6px; }

.template-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--gray-300);
  border-radius: 20px;
  background: #fff;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  white-space: nowrap;
}
.template-chip:hover:not(.locked) {
  background: var(--blue-50);
  border-color: var(--blue-600);
  color: var(--blue-600);
}
.template-chip.locked {
  opacity: .7;
  cursor: pointer;
}
.lock-badge {
  display: inline-block;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 10px;
  margin-left: 2px;
}

/* ==================== アップグレードモーダル ==================== */
.upgrade-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.upgrade-modal {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  padding: 36px 32px 28px;
  max-width: 520px;
  width: 100%;
  position: relative;
}
.upgrade-modal-close {
  position: absolute;
  top: 14px; right: 16px;
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--gray-500);
  line-height: 1;
}
.upgrade-modal-close:hover { color: var(--gray-900); }
.upgrade-modal-header { text-align: center; margin-bottom: 24px; }
.upgrade-modal-icon { font-size: 40px; margin-bottom: 8px; }
.upgrade-modal-header h2 { font-size: 22px; font-weight: 700; color: var(--blue-900); }
.upgrade-modal-msg { color: var(--gray-500); font-size: 13px; margin-top: 6px; }

.upgrade-plans {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}
.upgrade-plan {
  border: 2px solid var(--gray-300);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  position: relative;
}
.upgrade-plan.featured {
  border-color: var(--green-600);
  background: #f0fdf4;
}
.plan-badge {
  position: absolute;
  top: -11px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--green-600);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 20px;
  white-space: nowrap;
}
.plan-name { font-size: 13px; font-weight: 600; color: var(--gray-700); margin-bottom: 6px; }
.plan-price { font-size: 26px; font-weight: 800; color: var(--blue-900); margin-bottom: 4px; }
.plan-price span:first-child { font-size: 16px; vertical-align: super; }
.plan-unit { font-size: 13px; font-weight: 400; color: var(--gray-500); }
.plan-saving { font-size: 11px; color: var(--green-600); font-weight: 600; margin-bottom: 10px; }
.upgrade-plan .btn { width: 100%; margin-top: 10px; font-size: 13px; }

.upgrade-features {
  list-style: none;
  padding: 0;
  margin: 0 0 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.upgrade-features li { font-size: 13px; color: var(--gray-700); }

.license-activate-section {
  border-top: 1px solid var(--gray-300);
  padding-top: 16px;
  font-size: 12px;
  color: var(--gray-600);
}
.license-activate-section p { margin-bottom: 8px; }
.license-input-row { display: flex; gap: 8px; }
.license-input-row input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 12px;
  font-family: monospace;
}
.license-status { margin-top: 8px; font-size: 12px; min-height: 18px; }
.license-status.ok  { color: var(--green-600); font-weight: 600; }
.license-status.err { color: var(--red-600); }

/* ==================== アフィリエイトセクション ==================== */
.affiliate-header { margin-bottom: 16px; }
.affiliate-header h3 { font-size: 15px; font-weight: 700; color: var(--blue-900); }

.affiliate-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 640px) { .affiliate-cards { grid-template-columns: 1fr; } }

.affiliate-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--gray-300);
  border-radius: 10px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: box-shadow .15s, transform .15s;
}
.affiliate-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.affiliate-card-icon { font-size: 24px; padding: 14px 14px 0; }
.affiliate-card-body { padding: 8px 14px 10px; flex: 1; }
.affiliate-card-name { font-size: 13px; font-weight: 700; color: var(--blue-900); }
.affiliate-card-desc { font-size: 11px; color: var(--gray-600); margin-top: 4px; line-height: 1.5; }
.affiliate-card-cta {
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  text-align: center;
}
.affiliate-disclaimer {
  margin-top: 10px;
  font-size: 10px;
  color: var(--gray-500);
}

/* ==================== ヒーロー解説セクション ==================== */
.hero-explain-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--blue-900);
  margin-bottom: 10px;
}
.hero-explain-lead {
  font-size: 13px;
  color: var(--gray-700);
  line-height: 1.8;
  margin-bottom: 18px;
}
.hero-explain-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
@media (max-width: 640px) {
  .hero-explain-grid { grid-template-columns: repeat(2, 1fr); }
}
.hero-explain-item {
  background: var(--blue-50);
  border: 1px solid var(--blue-100);
  border-radius: var(--radius);
  padding: 14px 12px;
  text-align: center;
}
.hei-icon  { font-size: 24px; margin-bottom: 6px; }
.hei-title { font-size: 13px; font-weight: 700; color: var(--blue-900); margin-bottom: 4px; }
.hei-desc  { font-size: 11px; color: var(--gray-600); line-height: 1.5; }

/* ==================== Pro ラベル ==================== */
.pro-label {
  display: inline-block;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  vertical-align: middle;
  margin-left: 4px;
}

/* ==================== カスタムテンプレート ==================== */
.custom-chip { background: #fef9c3; border-color: #f59e0b; }
.custom-chip:hover { background: #fef08a; border-color: #d97706; }
.chip-del {
  display: inline-block;
  margin-left: 4px;
  font-size: 10px;
  color: var(--gray-500);
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}
.chip-del:hover { color: var(--red-600); }
.save-chip { background: #f0fdf4; border-color: var(--green-600); color: var(--green-600); }
.save-chip:hover { background: #dcfce7; }

/* ==================== 振込元プリセット ==================== */
.sender-preset-bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  padding: 10px 14px; background: #f8fafc;
  border: 1px solid var(--gray-200); border-radius: 9px; margin-bottom: 16px;
  font-size: 13px;
}
.sender-preset-bar.locked-bar { opacity: 0.8; }
.preset-label { font-weight: 700; color: var(--gray-700); white-space: nowrap; }
.preset-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.preset-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: #fff; border: 1px solid var(--gray-300); border-radius: 20px;
  padding: 4px 12px; font-size: 12px; font-weight: 600; color: var(--gray-700);
  cursor: pointer; transition: background 0.15s, border-color 0.15s;
}
.preset-chip:hover { background: #eff6ff; border-color: var(--blue-500); }
.save-preset-chip { background: #f0fdf4; border-color: var(--green-600); color: var(--green-600); }
.save-preset-chip:hover { background: #dcfce7; }
.link-btn {
  background: none; border: none; padding: 0; color: var(--blue-600);
  cursor: pointer; font-size: inherit; font-weight: 600; text-decoration: underline;
}

/* ==================== 変換履歴パネル ==================== */
#history-panel .mapping-table td { font-size: 12px; }
.history-reuse-btn, .history-del-btn { font-size: 11px; padding: 2px 8px; }

/* ==================== Coming Soon モーダル ==================== */
.coming-soon-box {
  text-align: center;
  background: linear-gradient(135deg, #fef9c3, #fef3c7);
  border: 2px solid #f59e0b;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}
.coming-soon-badge {
  display: inline-block;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .08em;
  padding: 4px 16px;
  border-radius: 20px;
  margin-bottom: 10px;
}
.coming-soon-text {
  font-size: 13px;
  color: #92400e;
  line-height: 1.7;
  margin: 0;
}
.coming-soon-notify {
  border-top: 1px solid var(--gray-300);
  padding-top: 16px;
  font-size: 12px;
  color: var(--gray-600);
}
.coming-soon-notify p { margin-bottom: 8px; font-weight: 600; }
.notify-input-row { display: flex; gap: 8px; }
.notify-input-row input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 13px;
}

/* ==================== 決済完了モーダル ==================== */
.purchase-success-icon { font-size: 52px; text-align: center; margin-bottom: 12px; }
.purchase-loading { text-align: center; padding: 24px 0; color: var(--gray-600); font-size: 14px; }
.purchase-spinner {
  width: 36px; height: 36px; border: 3px solid var(--gray-200);
  border-top-color: var(--blue-600); border-radius: 50%;
  animation: spin 0.8s linear infinite; margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.purchase-key-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--gray-100); border: 2px solid var(--blue-600);
  border-radius: 10px; padding: 14px 16px; margin-bottom: 8px;
}
.purchase-key-text {
  flex: 1; font-family: monospace; font-size: 18px; font-weight: 700;
  letter-spacing: 2px; color: var(--blue-900); word-break: break-all;
}
.purchase-copy-btn { padding: 6px 14px; font-size: 13px; white-space: nowrap; }
.purchase-copy-status { font-size: 12px; color: var(--green-600); font-weight: 600; min-height: 18px; }

/* ==================== 認証モーダル ==================== */

.badge-btn {
  background: var(--gray-100);
  color: var(--gray-700);
  font-size: 12px;
  font-weight: 600;
  border-radius: 20px;
  padding: 4px 12px;
  transition: background 0.15s;
}
.badge-btn:hover { background: var(--gray-300); }
.badge-btn.logged-in {
  background: var(--blue-100);
  color: var(--blue-800);
}

.auth-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  padding: 16px;
}
.auth-modal {
  background: #fff;
  border-radius: 16px;
  padding: 32px 28px;
  max-width: 440px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.auth-modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--gray-500);
  line-height: 1;
  padding: 4px 6px;
}
.auth-modal-close:hover { color: var(--gray-900); }

.auth-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--blue-900);
  margin-bottom: 20px;
}
.auth-desc {
  font-size: 13px;
  color: var(--gray-600);
  margin-bottom: 16px;
  line-height: 1.7;
}
.auth-hint {
  font-size: 11px;
  color: var(--gray-500);
  margin-left: 6px;
}
.auth-field {
  margin-bottom: 14px;
}
.auth-field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 5px;
}
.required {
  background: var(--red-100);
  color: var(--red-600);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 4px;
}
.auth-field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.15s;
}
.auth-field input:focus {
  outline: none;
  border-color: var(--blue-600);
  box-shadow: 0 0 0 3px rgba(26,86,219,0.15);
}
.auth-submit {
  width: 100%;
  padding: 12px;
  font-size: 15px;
  margin-top: 8px;
}
.auth-switch {
  text-align: center;
  margin-top: 16px;
  font-size: 13px;
  color: var(--gray-600);
}
.auth-link {
  color: var(--blue-600);
  text-decoration: none;
  font-weight: 600;
}
.auth-link:hover { text-decoration: underline; }
.auth-terms {
  font-size: 13px;
  color: var(--gray-700);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.auth-error {
  background: var(--red-100);
  color: var(--red-600);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 14px;
  font-weight: 600;
}
.auth-status {
  font-size: 13px;
  margin-top: 8px;
  min-height: 18px;
}
.auth-status.ok  { color: var(--green-600); font-weight: 600; }
.auth-status.err { color: var(--red-600); font-weight: 600; }
.auth-resend {
  width: 100%;
  font-size: 13px;
  padding: 8px;
}

/* アカウント設定内セクション */
.account-section {
  border-top: 1px solid var(--gray-200);
  padding-top: 20px;
  margin-top: 20px;
}
.account-section:first-child { border-top: none; padding-top: 0; margin-top: 0; }
.account-section h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--blue-900);
  margin-bottom: 14px;
}
.account-section-danger {
  border-top: 1px solid var(--gray-200);
  padding-top: 16px;
  margin-top: 8px;
  text-align: right;
}

/* TOTP QRコード */
#totp-qr {
  text-align: center;
  margin: 12px 0;
}
#totp-qr canvas, #totp-qr img {
  border: 4px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  border-radius: 8px;
}

/* 危険ボタン */
.btn-danger {
  background: var(--red-600);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn-danger:hover { background: #b91c1c; }
