/**
 * ツール本体スタイル
 * かんたん請求書・領収書作成ツール by サプライコネクト
 */

/* ===== ツールヘッダー（固定） ===== */
.tool-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  z-index: var(--z-header);
  display: flex;
  align-items: center;
}

.tool-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0 var(--spacing-xl);
}

.tool-header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
  min-width: 0;
  overflow: hidden;
}

/* SCロゴ画像 */
.tool-header-logo-img {
  width: 32px;
  height: 32px;
  max-width: 32px;
  object-fit: contain;
  object-position: center;
  flex-shrink: 0;
  display: block;
  align-self: center;
}

/* ロゴテキスト */
.tool-header-logo-texts {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.tool-header-title {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--secondary);
  line-height: 1.2;
  white-space: nowrap;
}

.tool-header-sub {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: 400;
  white-space: nowrap;
}

.tool-header-brand {
  font-size: var(--text-xs);
  color: var(--text-muted);
  transition: color var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
  text-decoration: none;
}

.tool-header-brand:hover {
  color: var(--primary-light);
}

/* ===== タブナビゲーション ===== */
.tool-tabs {
  position: sticky;
  top: var(--header-height);
  z-index: calc(var(--z-header) - 1);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}

.tabs-inner {
  display: flex;
  gap: 0;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--spacing-xl);
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 16px 20px;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-muted);
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-subtle);
}

.tab-btn.active {
  color: var(--primary-light);
  border-bottom-color: var(--primary-light);
}

/* ===== ツールコンテンツ ===== */
.tool-content {
  margin-top: calc(var(--header-height));
  min-height: calc(100vh - var(--header-height));
  padding-top: var(--spacing-xl);
  padding-bottom: 120px; /* 固定アクションバーの高さ分 */
}

.tab-panel {
  display: none;
  animation: tabFadeIn 0.2s ease;
}

.tab-panel.active {
  display: block;
}

@keyframes tabFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== 作成タブ ===== */
.create-layout {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 var(--spacing-xl);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
}

/* 書類タイプ選択 */
.doc-type-selector {
  display: flex;
  background: var(--bg-subtle);
  border-radius: var(--radius);
  padding: 4px;
  gap: 4px;
}

.doc-type-btn {
  flex: 1;
  padding: 10px 16px;
  border-radius: calc(var(--radius) - 2px);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-muted);
  border: none;
  background: none;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
}

.doc-type-btn.active {
  background: white;
  color: var(--primary);
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

/* カードセクション */
.form-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.form-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-md) var(--spacing-xl);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
}

.form-section-header:hover {
  background: #E8EEF7;
}

.form-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--secondary);
}

.form-section-icon {
  width: 28px;
  height: 28px;
  background: var(--primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.form-section-toggle {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: transform var(--transition);
}

.form-section.collapsed .form-section-toggle {
  transform: rotate(-90deg);
}

.form-section-body {
  padding: var(--spacing-xl);
  display: block;
}

.form-section.collapsed .form-section-body {
  display: none;
}

/* フォームグリッド */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--spacing-md);
}

.form-grid.col-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.form-grid.col-4 {
  grid-template-columns: 1fr 1fr 1fr 1fr;
}

.col-span-2 {
  grid-column: span 2;
}

.col-span-3 {
  grid-column: span 3;
}

/* ロゴアップロード */
.logo-upload-area {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: var(--spacing-xl);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
}

.logo-upload-area:hover,
.logo-upload-area.drag-over {
  border-color: var(--primary-light);
  background: var(--bg-primary-subtle);
}

.logo-upload-icon {
  font-size: 32px;
  margin-bottom: var(--spacing-sm);
}

.logo-upload-text {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.logo-upload-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.logo-preview {
  display: none;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-md);
  background: var(--bg-subtle);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-top: var(--spacing-sm);
}

.logo-preview.visible {
  display: flex;
}

.logo-preview-img {
  width: 60px;
  height: 60px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: white;
  border: 1px solid var(--border);
}

.logo-preview-info {
  flex: 1;
}

.logo-preview-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.logo-preview-size {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* ===== 明細テーブル ===== */
.items-table-wrapper {
  overflow-x: auto;
  margin: 0 -var(--spacing-md);
}

.items-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 700px;
}

.items-table thead th {
  padding: 10px 12px;
  background: var(--bg-subtle);
  border-bottom: 2px solid var(--border);
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-secondary);
  text-align: left;
  white-space: nowrap;
}

.items-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

.items-table tbody tr:last-child {
  border-bottom: none;
}

.items-table tbody tr:hover {
  background: var(--bg-subtle);
}

.items-table td {
  padding: 8px 10px;
  vertical-align: middle;
}

.items-table .col-description {
  min-width: 200px;
}

.items-table .col-qty {
  width: 90px;
}

.items-table .col-price {
  width: 130px;
}

.items-table .col-tax {
  width: 90px;
}

.items-table .col-amount {
  width: 130px;
  text-align: right;
  font-weight: 600;
  color: var(--secondary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.items-table .col-actions {
  width: 44px;
  text-align: center;
}

.items-table .btn-delete-row {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.items-table .btn-delete-row:hover {
  background: rgba(239,68,68,0.1);
  color: var(--danger);
}

.items-table input,
.items-table select {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--text-primary);
  background: white;
  transition: border-color var(--transition);
}

.items-table input:focus,
.items-table select:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 2px rgba(59,130,246,0.1);
}

.items-table .tax-select {
  padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  appearance: none;
}

.items-table .tax-8 {
  background: linear-gradient(90deg, rgba(245,158,11,0.08), transparent);
}

.add-item-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px var(--spacing-md);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  background: none;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  justify-content: center;
  transition: all var(--transition);
  margin-top: var(--spacing-sm);
}

.add-item-btn:hover {
  border-color: var(--primary-light);
  color: var(--primary-light);
  background: var(--bg-primary-subtle);
}

/* ===== 税・合計セクション ===== */
.tax-summary {
  background: var(--bg-subtle);
  border-radius: var(--radius);
  padding: var(--spacing-md);
}

.tax-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}

.tax-row:last-child {
  border-bottom: none;
}

.tax-row.total-row {
  padding: 12px 0;
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--secondary);
}

.tax-row.subtotal-row {
  font-weight: 600;
  color: var(--text-primary);
}

.tax-row.withholding-row {
  color: var(--warning);
}

.tax-row .amount-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.total-amount-large {
  background: var(--bg-primary-subtle);
  border: 2px solid rgba(59,130,246,0.15);
  border-radius: var(--radius);
  padding: var(--spacing-md) var(--spacing-lg);
  margin-top: var(--spacing-md);
}

.total-amount-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.total-amount-value {
  font-size: var(--text-3xl);
  font-weight: 800;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}

.total-amount-kanji {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: 4px;
}

/* 税計算方式 */
.tax-mode-group {
  display: flex;
  gap: var(--spacing-md);
}

.radio-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.radio-btn input[type="radio"] {
  accent-color: var(--primary-light);
  width: 15px;
  height: 15px;
}

.radio-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
}

/* 振込先 */
.bank-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--spacing-md);
}

/* ===== アクションバー（固定） ===== */
.action-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid var(--border);
  padding: var(--spacing-md) var(--spacing-xl);
  z-index: calc(var(--z-header) - 1);
  box-shadow: 0 -4px 12px rgba(0,0,0,0.06);
}

.action-bar-inner {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  gap: var(--spacing-sm);
  align-items: center;
}

.action-bar .btn-preview {
  flex: 1;
}

/* ===== プレビュータブ ===== */
.preview-layout {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 var(--spacing-xl);
}

.preview-actions {
  display: flex;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
  justify-content: flex-end;
  margin-bottom: var(--spacing-lg);
}

/* A4書類エリア */
.document-wrapper {
  background: var(--bg-subtle);
  padding: var(--spacing-xl);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.document-paper {
  background: white;
  width: 100%;
  max-width: 794px; /* A4幅（96dpi換算） */
  margin: 0 auto;
  padding: 32px 36px; /* A4余白に相当するコンパクトなパディング */
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
  border-radius: 2px;
  font-size: 12px;   /* 少し小さくしてA4 1ページ収納を促進 */
  line-height: 1.5;
  color: var(--secondary);
  min-height: 1060px; /* A4縦（297mm×96/25.4≒1122px）相当、padding込みで調整 */
  position: relative;
  display: flex;
  flex-direction: column;
}

/* =====================================================
   書類プレビュー レイアウト（参考画像準拠）
   ===================================================== */

/* 振込先・備考を最下部に表示 */
.doc-footer-section {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* ① 右上：発行日・書類番号エリア */
.doc-meta-top {
  text-align: right;
  margin-bottom: 4px;
}

.doc-meta-date,
.doc-meta-number,
.doc-meta-due {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.8;
}

.doc-meta-due {
  font-weight: 600;
  color: var(--primary);
}

/* ② タイトル（中央揃え） */
.doc-title {
  font-size: 26px;
  font-weight: 800;
  color: var(--primary);
  text-align: center;
  letter-spacing: 0.2em;
  margin: 10px 0 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--primary);
}

/* ③ 左：取引先 ／ 右：発行者 の2カラムレイアウト */
.doc-parties {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

/* 左カラム：取引先＋請求金額 */
.doc-buyer-col {
  flex: 1;
  min-width: 0;
}

.doc-buyer-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--secondary);
  border-bottom: 2px solid var(--secondary);
  display: inline-block;
  padding-bottom: 2px;
  margin-bottom: 4px;
}

.doc-buyer-sub {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.7;
  display: block;
}

/* ご請求金額ブロック */
.doc-request-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 12px;
  margin-bottom: 4px;
}

.doc-request-amount-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.doc-request-amount-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--secondary);
  white-space: nowrap;
}

.doc-request-amount-val {
  font-size: 22px;
  font-weight: 800;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}

.doc-request-amount-dash {
  font-size: 14px;
  font-weight: 400;
  margin-left: 2px;
}

.doc-request-kanji {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* 右カラム：発行者情報 */
.doc-seller-col {
  flex-shrink: 0;
  max-width: 280px;
}

/* 発行者情報＋社印の横並び */
.doc-seller-inner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.doc-seller-texts {
  text-align: left;
  flex: 1;
}

.doc-seller-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--secondary);
  margin-bottom: 2px;
}

.doc-seller-info {
  font-size: 10px;
  color: var(--text-secondary);
  line-height: 1.7;
}

/* 社印（角印）：テキストの右横に表示 */
.doc-seller-stamp {
  flex-shrink: 0;
  width: 72px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.doc-seller-logo {
  width: 72px;
  height: 72px;
  object-fit: contain;
  object-position: center;
}

/* ④ 明細テーブル */
.doc-items-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 12px;
  font-size: 12px;
}

.doc-items-table th {
  padding: 7px 8px;
  background: var(--primary);
  color: white;
  font-size: 11px;
  font-weight: 700;
  text-align: left;
  white-space: nowrap;
}

.doc-items-table th.text-right {
  text-align: right;
}

.doc-items-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

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

.doc-items-table tr:nth-child(even) td {
  background: #F8FAFC;
}

.doc-items-table .amount-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.doc-items-table .tax-8-badge {
  display: inline-block;
  padding: 1px 4px;
  background: rgba(245,158,11,0.12);
  color: var(--warning);
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  margin-left: 4px;
}

/* ⑤ 合計エリア（右揃え） */
.doc-totals {
  width: 300px;
  margin-left: auto;
  margin-bottom: 16px;
}

.doc-total-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 11px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}

.doc-total-row:last-child {
  border-bottom: none;
}

.doc-total-row.grand-total {
  padding: 8px 10px;
  background: var(--bg-primary-subtle);
  border-radius: var(--radius-sm);
  margin-top: 6px;
  font-size: 13px;
  font-weight: 800;
  color: var(--primary);
}

.doc-total-row .val {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ⑥ 振込先（最下部） */
.doc-bank-info {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 10px;
  background: #FAFBFF;
}

.doc-bank-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
  letter-spacing: 0.05em;
}

.doc-bank-detail {
  font-size: 12px;
  font-weight: 600;
  color: var(--secondary);
  line-height: 1.6;
}

/* 備考 */
.doc-notes {
  padding-top: 10px;
}

.doc-notes-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 4px;
  letter-spacing: 0.05em;
}

.doc-notes-content {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.7;
  white-space: pre-wrap;
}

/* インボイス番号（非表示） */
.doc-invoice-number {
  display: none;
}

/* ===== 履歴タブ ===== */
.history-layout {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 var(--spacing-xl);
}

.history-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-md);
}

.history-count {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.history-empty {
  text-align: center;
  padding: var(--spacing-4xl) var(--spacing-xl);
  color: var(--text-muted);
}

.history-empty-icon {
  margin-bottom: var(--spacing-md);
  color: var(--text-muted);
  opacity: 0.5;
  display: flex;
  justify-content: center;
}

.history-empty-text {
  font-size: var(--text-base);
  margin-bottom: var(--spacing-sm);
}

.history-empty-hint {
  font-size: var(--text-sm);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

/* ===== 履歴カード ===== */
.history-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px var(--spacing-md);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all var(--transition);
}

.history-item:hover {
  box-shadow: var(--shadow-hover);
  border-color: var(--border-strong);
}

/* 上段：バッジ ＋ 取引先名 ＋ 金額 */
.history-row-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.history-type-badge {
  flex-shrink: 0;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.history-type-badge.invoice {
  background: rgba(59,130,246,0.12);
  color: var(--primary-light);
}

.history-type-badge.receipt {
  background: rgba(16,185,129,0.12);
  color: var(--accent);
}

.history-buyer {
  flex: 1;
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-amount {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
}

/* 下段：書類番号 / 発行日 / 保存日時 */
.history-row-bottom {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 6px;
}

.history-detail-item {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.history-detail-item svg {
  flex-shrink: 0;
  opacity: 0.6;
}

.history-detail-sep {
  font-size: 11px;
  color: var(--border-strong);
}

/* アクションボタン行 */
.history-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.history-action-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: white;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
}

.history-action-btn:hover {
  background: var(--bg-subtle);
  border-color: var(--border-strong);
  color: var(--primary);
}

.history-action-btn.danger:hover {
  background: rgba(239,68,68,0.08);
  border-color: var(--danger);
  color: var(--danger);
}

/* ===== レスポンシブ ===== */
@media (max-width: 767px) {
  .tool-header-inner {
    padding: 0 var(--spacing-md);
  }
  .tool-header-logo-img {
    width: 28px;
    height: 28px;
  }
  .tool-header-title {
    font-size: 12px;
  }
  .tool-header-sub {
    font-size: 10px;
  }
  .tool-header-brand {
    font-size: 10px;
  }

  .tabs-inner {
    padding: 0;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .tabs-inner::-webkit-scrollbar {
    display: none;
  }

  .tab-btn {
    padding: 14px 16px;
    font-size: var(--text-xs);
  }

  .create-layout,
  .preview-layout,
  .history-layout {
    padding: 0 var(--spacing-md);
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-grid.col-3,
  .form-grid.col-4 {
    grid-template-columns: 1fr 1fr;
  }

  .col-span-2,
  .col-span-3 {
    grid-column: span 1;
  }

  .items-table-wrapper {
    overflow-x: auto;
  }

  .action-bar {
    padding: var(--spacing-sm) var(--spacing-md);
  }

  .action-bar-inner {
    flex-wrap: wrap;
  }

  .action-bar .btn-preview {
    width: 100%;
  }

  /* 履歴カードはすでに縦並びなのでモバイルでも崩れない */
  .history-row-bottom {
    gap: 3px 4px;
  }

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

  .document-paper {
    padding: 20px;
    font-size: 11px;
  }

  .doc-header {
    flex-direction: column;
    gap: var(--spacing-md);
  }

  .doc-seller-area {
    text-align: left;
    max-width: 100%;
  }

  .doc-totals {
    width: 100%;
  }

  .preview-actions {
    justify-content: flex-start;
  }

  .bank-grid {
    grid-template-columns: 1fr;
  }
}
