* { box-sizing: border-box; }

/* ─── デザイントークン（A案：落ち着いた配色・ブランド緑統一） ─────────── */
:root {
  /* ブランド緑（塗りつぶしCTA） */
  --brand: #3aa76d;
  --brand-d: #2e8f5b;
  /* 情報青（編集・PW初期化などのアクセント） */
  --blue: #2c7be5;
  --blue-d: #1a68d1;
  /* 危険赤（削除） */
  --danger: #c0392b;

  /* 淡色トーン（表内の操作ボタン用：地・文字・枠線・hover地） */
  --t-green-bg: #e7f4ec; --t-green-fg: #1f7a47; --t-green-bd: #bfe3cd; --t-green-bgh: #d6ecde;
  --t-blue-bg:  #e8f0fd; --t-blue-fg:  #1f5fc4; --t-blue-bd:  #c3d8f6; --t-blue-bgh:  #d8e6fb;
  --t-red-bg:   #fdecec; --t-red-fg:   #c0392b; --t-red-bd:   #f3c9c9; --t-red-bgh:   #f9dcdc;
  --t-gray-bg:  #f1f3f6; --t-gray-fg:  #5b6470; --t-gray-bd:  #dde2e8; --t-gray-bgh:  #e7ebf0;

  /* 無効状態 */
  --disabled-bg: #f1f3f6; --disabled-fg: #aab2bd; --disabled-bd: #e3e7ec;

  --radius: 6px;
  --btn-shadow: 0 1px 2px rgba(0,0,0,.10);
}

/* ヘッダー帯：design-share のデフォルト padding を縮め、画像（height:1.6em）の上下に少し余白を作って帯高さを約 2em にキープ */
.header-bar { padding: 0.2em 0; }
.header-bar h1 { margin: 0; }
.header-bar .mb-2 { margin-bottom: 0 !important; }
/* ヘッダー右端の「ひょっこりマスコット」：帯（~2em）より少し大きく、下にちょい乗せ（元 72px / margin-bottom:-22px） */
.header-bar .header-mascot { height: 2.5em; margin-bottom: -0.5em; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Yu Gothic UI", sans-serif;
  margin: 0;
  background: #f0f4f8;
  color: #222;
}

.app-card {
  max-width: 480px;
  margin: 24px auto 40px;
  background: #fff;
  padding: 32px 28px;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.app-card h1 {
  margin: 0 0 24px;
  font-size: 22px;
  font-weight: 600;
}

h2 {
  margin: 24px 0 12px;
  font-size: 16px;
  font-weight: 600;
}

label {
  display: block;
  margin: 12px 0 4px;
  font-size: 13px;
  color: #555;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 8px 10px;
  font-size: 15px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

/* 入力フォーカス：緑のフォーカスリング（操作中が分かりやすく・アクセシビリティ向上） */
input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  outline: none;
  box-shadow: 0 0 0 3px rgba(46,125,79,.15);
}

button {
  margin-top: 16px;
  padding: 10px 18px;
  font-size: 15px;
  background: var(--brand);
  color: #fff;
  border: 1px solid transparent;
  border-radius: var(--radius);
  box-shadow: var(--btn-shadow);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background .12s, border-color .12s, box-shadow .12s, transform .04s;
}

button:hover { background: var(--brand-d); }
button:active { transform: translateY(1px); }

button:disabled,
button:disabled:hover {
  background: var(--disabled-bg);
  color: var(--disabled-fg);
  border-color: var(--disabled-bd);
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

button.secondary {
  background: var(--t-gray-bg);
  color: var(--t-gray-fg);
  border-color: var(--t-gray-bd);
  box-shadow: none;
}

button.secondary:hover { background: var(--t-gray-bgh); }

/* Bootstrap の btn-primary（ログイン送信ボタン）をブランド緑へ統一 */
.btn.btn-primary {
  background-color: var(--brand);
  border-color: var(--brand);
}
.btn.btn-primary:hover,
.btn.btn-primary:focus,
.btn.btn-primary:active {
  background-color: var(--brand-d);
  border-color: var(--brand-d);
  box-shadow: none;
}

.error {
  color: #c0392b;
  margin: 12px 0 0;
  font-size: 13px;
  min-height: 1.2em;
}

.success {
  color: #1c7a3a;
  margin: 12px 0 0;
  font-size: 13px;
  min-height: 1.2em;
}

.warning-banner {
  background: #fff5e6;
  border: 1px solid #f0b86d;
  color: #6b3a05;
  padding: 12px 14px;
  border-radius: 4px;
  margin: 0 0 20px;
  font-size: 14px;
}

.info-row {
  display: flex;
  padding: 6px 0;
  border-bottom: 1px solid #eee;
  font-size: 14px;
}

.info-row .label {
  width: 110px;
  color: #666;
}

.role-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  background: #e2efff;
  color: #2c7be5;
}

.role-badge.master   { background: #ffe1e1; color: #b03030; }
.role-badge.producer { background: #e2f3e2; color: #2a7a3a; }
.role-badge.union    { background: #fff5d6; color: #8a6b13; }

/* ─── メニュー（index.html） ────────────────────────────────────── */
.menu-link {
  display: inline-block;
  padding: 12px 18px;
  background: var(--brand);
  color: #fff;
  border-radius: var(--radius);
  text-decoration: none;
  font-size: 15px;
  margin-top: 4px;
}
.menu-link:hover { background: var(--brand-d); }

.info-note {
  padding: 10px 14px;
  background: #f0f4fa;
  border-left: 3px solid #2c7be5;
  color: #444;
  font-size: 13px;
}

/* ─── 入荷チェック入力（iPad 想定） ──────────────────────────── */
.app-card.wide {
  max-width: 920px;
}

.page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px;
  flex-wrap: wrap;
}
.page-header h1 { margin: 0; }
.back-link {
  color: #2c7be5;
  text-decoration: none;
  font-size: 14px;
}
.back-link:hover { text-decoration: underline; }

/* ヘッダー右側のユーザー情報＋ログアウトボタン */
.page-header-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: #555;
}
.page-header-user .user-name {
  white-space: nowrap;
}
.page-header-user .logout-btn {
  margin: 0;
  padding: 6px 12px;
  font-size: 13px;
  background: var(--t-gray-bg);
  color: var(--t-gray-fg);
  border-color: var(--t-gray-bd);
  box-shadow: none;
}
.page-header-user .logout-btn:hover { background: var(--t-gray-bgh); }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 18px;
  margin-top: 8px;
}
.form-grid .field { display: flex; flex-direction: column; }
.form-grid .field.full { grid-column: 1 / -1; }

.form-grid label {
  margin: 0 0 4px;
}
.req { color: #c0392b; }

.form-grid input[type="text"],
.form-grid input[type="number"],
.form-grid input[type="date"],
.form-grid select,
.form-grid textarea {
  width: 100%;
  padding: 8px 10px;
  font-size: 15px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
}
.form-grid textarea { resize: vertical; }

.radio-row {
  display: flex;
  gap: 24px;
  padding: 6px 0;
}
.radio-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  color: #222;
  margin: 0;
}

.defect-codes {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  padding: 6px 0;
}
.defect-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: #f8f8f8;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
  margin: 0;
  cursor: pointer;
}
.defect-item input { margin: 0; }
.defect-mark {
  font-weight: 600;
  color: #c0392b;
}

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

/* ─── 直近の入荷チェック表 ──────────────────────────────────── */
.recent-list { overflow-x: auto; }
.recent-list table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.recent-list th,
.recent-list td {
  border: 1px solid #e3e3e3;
  padding: 6px 8px;
  text-align: left;
  vertical-align: middle;
}
.recent-list th {
  background: #f5f7fa;
  font-weight: 600;
  color: #555;
}
.recent-list td.muted { color: #999; text-align: center; }

.badge-good,
.badge-defect {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
}
.badge-good   { background: #e2f3e2; color: #2a7a3a; }
.badge-defect { background: #ffe1e1; color: #b03030; }

/* ─── ダッシュボード サマリカード ─────────────────────────────── */
.summary-cards {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 16px;
  margin: 16px 0 8px;
}
.summary-card {
  background: #fff;
  border: 1px solid #e8eae8;
  border-radius: 8px;
  padding: 14px 16px 10px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.summary-card h3 {
  margin: 0 0 8px;
  font-size: 13px;
  color: #3aa76d;
  font-weight: 600;
}
.summary-card .chart-wrap {
  position: relative;
  height: 200px;
}
@media (max-width: 768px) {
  .summary-cards { grid-template-columns: 1fr; }
  .summary-card .chart-wrap { height: 180px; }
}

/* ─── ダッシュボード（producer / union） ──────────────────────── */
.dashboard-filter {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  padding: 12px 14px;
  background: #f5f7fa;
  border-radius: 4px;
  margin: 12px 0 16px;
}
.dashboard-filter .filter-field {
  display: flex;
  flex-direction: column;
  min-width: 140px;
}
.dashboard-filter label {
  margin: 0 0 4px;
  font-size: 12px;
  color: #555;
}
.dashboard-filter input[type="date"],
.dashboard-filter select {
  padding: 7px 9px;
  font-size: 14px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
}
.dashboard-filter .filter-buttons {
  display: flex;
  gap: 8px;
}
.dashboard-filter button {
  margin: 0;
  padding: 8px 14px;
  font-size: 14px;
}

.data-table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th,
.data-table td {
  border: 1px solid #e3e3e3;
  padding: 6px 8px;
  text-align: left;
  vertical-align: middle;
}
.data-table th {
  background: #f5f7fa;
  font-weight: 600;
  color: #555;
  white-space: nowrap;
}
.data-table td.muted { color: #999; text-align: center; }
.data-table tr.clickable { cursor: pointer; }
.data-table tr.clickable:hover { background: #f0f6ff; }

.small { font-size: 12px; margin: 6px 0 0; }

/* ─── 詳細モーダル ────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.modal-content {
  background: #fff;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  border-radius: 8px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid #e3e3e3;
}
.modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}
.modal-close {
  margin: 0;
  padding: 0;
  width: 32px;
  height: 32px;
  font-size: 22px;
  line-height: 1;
  background: transparent;
  color: #666;
  border: none;
  cursor: pointer;
}
.modal-close:hover { color: #222; background: transparent; }
.modal-body {
  padding: 14px 18px 18px;
  overflow-y: auto;
}
/* モーダル内フォームの select / email / number をテキスト入力と揃える */
.modal-body select,
.modal-body input[type="email"],
.modal-body input[type="number"] {
  width: 100%;
  padding: 8px 10px;
  font-size: 15px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  margin: 0;
}
/* ラベルと入力の間隔を均一に */
.modal-body form label {
  display: block;
  margin: 12px 0 4px;
  font-size: 13px;
  color: #555;
}
.modal-body form label:first-child { margin-top: 0; }
.modal-row {
  display: flex;
  padding: 6px 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 14px;
}
.modal-row .modal-label {
  width: 96px;
  flex-shrink: 0;
  color: #666;
}
.modal-row .modal-value {
  flex: 1;
  word-break: break-word;
}
.modal-body .muted { color: #aaa; }

/* モーダル編集 UI */
.modal-content-wide { max-width: 760px; }
.modal-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-edit-btn {
  margin: 0;
  padding: 4px 12px;
  height: 30px;
  font-size: 13px;
  background: var(--brand);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.modal-edit-btn:hover { background: var(--brand-d); }

.edit-form .form-grid {
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
}
.edit-form .form-grid .field.full { grid-column: 1 / -1; }
.edit-form .form-grid label,
.edit-form .section-label {
  margin: 0 0 2px;
  font-size: 13px;
  color: #555;
}
.edit-form .section-label {
  display: block;
  margin: 14px 0 6px;
  font-weight: 600;
  color: #3aa76d;
}
.edit-form input[type="text"],
.edit-form input[type="number"],
.edit-form input[type="date"],
.edit-form select {
  width: 100%;
  padding: 5px 8px;
  height: 36px;
  font-size: 14px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
}
.edit-form .form-section { margin-top: 10px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}
.modal-actions button { margin: 0; }
.edit-form .submit-btn {
  background: var(--brand);
}
.edit-form .submit-btn:hover { background: var(--brand-d); }

@media (max-width: 768px) {
  .edit-form .form-grid { grid-template-columns: 1fr; }
}

.defect-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.defect-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: #fff5f0;
  border: 1px solid #f3c8b3;
  border-radius: 10px;
  font-size: 12px;
}

@media (max-width: 768px) {
  .dashboard-filter { flex-direction: column; align-items: stretch; }
  .dashboard-filter .filter-field { min-width: 0; }
  .dashboard-filter .filter-buttons { justify-content: flex-end; }
  .modal-row { flex-direction: column; }
  .modal-row .modal-label { width: auto; font-size: 12px; }
}

/* ─── 分析画面 KPI 行 ─────────────────────────────────────────── */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 12px 0 8px;
}
.kpi {
  background: #fff;
  border: 1px solid #e8eae8;
  border-radius: 8px;
  padding: 12px 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.kpi-row.kpi-4 { grid-template-columns: repeat(4, 1fr); }
.kpi-label { font-size: 12px; color: #6b6b6b; }
.kpi-value { font-size: 22px; font-weight: 700; color: #3aa76d; margin-top: 4px; }
@media (max-width: 768px) {
  .kpi-row { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .kpi-row.kpi-4 { grid-template-columns: repeat(2, 1fr); }
  .kpi { padding: 8px 10px; }
  .kpi-value { font-size: 16px; }
}

/* ─── 圃場別 品質比較テーブル（分析画面） ─────────────────────── */
.field-table-card {
  background: #fff;
  border: 1px solid #e8eae8;
  border-radius: 8px;
  padding: 14px 16px 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  margin: 16px 0 8px;
}
.field-table-card h3 {
  margin: 0 0 10px;
  font-size: 13px;
  color: #3aa76d;
  font-weight: 600;
}
.field-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.field-table th,
.field-table td {
  padding: 7px 9px;
  border-bottom: 1px solid #eef0ee;
  text-align: center;
  white-space: nowrap;
}
.field-table th {
  background: #f5f7fa;
  color: #555;
  font-weight: 600;
  font-size: 12px;
}
.field-table td.field-name { text-align: left; font-weight: 600; }
.field-table td.field-conditions { text-align: left; white-space: normal; color: #6b6b6b; }
.field-table tbody tr:hover { background: #f0f7f1; }
.field-table .rate-high { color: var(--danger); font-weight: 700; }
.field-table .rate-mid { color: #d98b3b; font-weight: 600; }
.field-table tfoot td { font-weight: 700; background: #f5f7fa; border-top: 2px solid #dde2e8; }
@media (max-width: 768px) {
  .field-table-card { overflow-x: auto; }
}

/* ─── 設定画面（タブ＆セル入力） ──────────────────────────────── */
.settings-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid #e8eae8;
  margin: 16px 0 12px;
}
.settings-tab {
  margin: 0;
  padding: 8px 16px;
  background: transparent;
  color: #555;
  border: none;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  font-size: 14px;
  cursor: pointer;
}
.settings-tab:hover { background: #f0f7f1; color: #3aa76d; }
.settings-tab.active {
  color: #3aa76d;
  border-bottom-color: #3aa76d;
  font-weight: 600;
  background: transparent;
}
.panel-toolbar {
  display: flex;
  justify-content: flex-end;
  margin: 8px 0;
}
.panel-toolbar button {
  margin: 0;
  padding: 6px 12px;
  font-size: 13px;
  background: var(--brand);
}
.panel-toolbar button:hover { background: var(--brand-d); }

/* ─── 設定画面：上部（見出し・タブ・ツールバー）を固定し、一覧だけスクロール ───
   カードの高さをビューポート内に収め、テーブルの中身（行）だけを縦スクロールさせる。
   見出し・説明文・タブ・追加ボタン・テーブルヘッダーは常に見える状態を保つ。
   サイドバーが常時出る広い画面（PC・iPad 横）のみ適用。狭幅（iPad 縦・スマホ）は
   一覧領域が潰れて使いづらいため、従来どおりページ全体を自然スクロールさせる。 */
@media (min-width: 1025px) {
  .app-card.wide.settings-page {
    display: flex;
    flex-direction: column;
    /* ヘッダー帯(50px)＋カード上下マージン(24+40px)＋余白を確実に差し引き、
       ページ全体（body）側に縦スクロールバーが出ないようにする */
    max-height: calc(100vh - 130px);
  }
  /* 表示中のパネルだけを伸縮させ、中の一覧スクロール領域を確保する（hidden は対象外） */
  .settings-page .settings-panel:not([hidden]) {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;          /* flex 子要素のスクロールを効かせるために必須 */
  }
  .settings-page .data-table-wrap {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;       /* ← 一覧データだけがここで縦スクロールする */
  }
  /* テーブルヘッダーをスクロール領域の上端に貼り付けて常時表示 */
  .settings-page .data-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
  }
}

.cell-input {
  width: 100%;
  padding: 4px 6px;
  font-size: 13px;
  border: 1px solid #ccc;
  border-radius: 4px;
}
.cell-input.narrow { width: 80px; }
.data-table select.cell-input { padding: 4px 6px; background: #fff; }

/* テーブル行内のボタン：A案の淡色トーン（地＋色文字＋枠線）＋アイコン */
.data-table .row-edit,
.data-table .row-pw,
.data-table .row-copy,
.data-table .row-delete {
  margin: 0 5px 0 0;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius);
  box-shadow: none;
  vertical-align: middle;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.data-table .row-edit .bi,
.data-table .row-pw .bi,
.data-table .row-copy .bi,
.data-table .row-delete .bi { font-size: 13px; }

/* 共有文コピー：緑tinted */
.data-table .row-copy {
  background: var(--t-green-bg); color: var(--t-green-fg); border-color: var(--t-green-bd);
}
.data-table .row-copy:hover { background: var(--t-green-bgh); }

/* 編集・PW初期化：青tinted */
.data-table .row-edit,
.data-table .row-pw {
  background: var(--t-blue-bg); color: var(--t-blue-fg); border-color: var(--t-blue-bd);
}
.data-table .row-edit:hover,
.data-table .row-pw:hover { background: var(--t-blue-bgh); }

/* 削除：赤tinted（.secondary より詳細度が高く赤が勝つ） */
.data-table .row-delete {
  background: var(--t-red-bg); color: var(--t-red-fg); border-color: var(--t-red-bd);
}
.data-table .row-delete:hover { background: var(--t-red-bgh); }

.data-table td button:last-child { margin-right: 0; }
/* 生産者の操作列：編集・削除ボタンを横並び固定（列幅不足での折り返し防止） */
#producers-table td:last-child { white-space: nowrap; }
.data-table button:disabled,
.data-table button:disabled:hover {
  background: var(--disabled-bg);
  color: var(--disabled-fg);
  border-color: var(--disabled-bd);
  cursor: not-allowed;
}

/* ドラッグ並び替えハンドル */
.data-table td.drag-handle {
  text-align: center;
  color: #9ca3af;
  cursor: grab;
  user-select: none;
  touch-action: none;
}
.data-table td.drag-handle:active { cursor: grabbing; }
.data-table tr.sortable-chosen { background: #eef7f0; }
.data-table tr.sortable-ghost { background: #d8ecdf; opacity: 0.6; }

/* アカウント付与の表示（生産者・農協タブ） */
.account-cell { line-height: 1.8; }
.account-chip {
  display: inline-block;
  padding: 1px 8px;
  margin: 1px 2px 1px 0;
  background: #e7f1ff;
  border: 1px solid #c5dbf5;
  color: #1a56db;
  border-radius: 10px;
  font-size: 12px;
}
.account-none { font-size: 12px; color: #9ca3af; }

/* ─── パスワード変更モーダル ──────────────────────────────────── */
.pw-modal .info-note {
  margin: 0 0 12px;
}
.pw-modal label {
  display: block;
  margin: 10px 0 4px;
  font-size: 13px;
  color: #555;
}
.pw-modal input[type="password"] {
  width: 100%;
  padding: 8px 10px;
  font-size: 15px;
  border: 1px solid #ccc;
  border-radius: 4px;
}
.pw-modal-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
}
.pw-modal-actions button {
  margin: 0;
}

/* ─── 入荷チェック（receipt-form コンパクト UI） ─────────────────── */
.receipt-form .form-grid {
  gap: 8px 14px;
  margin-top: 4px;
}
.receipt-form .form-grid label,
.receipt-form .section-label {
  margin: 0 0 2px;
  font-size: 13px;
  color: #555;
}
.receipt-form .section-label {
  display: block;
  margin: 14px 0 6px;
  font-weight: 600;
  color: #3aa76d;
}
.receipt-form input[type="text"],
.receipt-form input[type="number"],
.receipt-form input[type="date"],
.receipt-form select,
.receipt-form textarea {
  width: 100%;
  padding: 5px 8px;
  height: 36px;
  font-size: 14px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
}
.receipt-form input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
  text-align: left;
  min-height: 36px;
  display: block;
}
.receipt-form input[type="date"]::-webkit-date-and-time-value {
  text-align: left;
}
.receipt-form .form-section { margin-top: 12px; }

/* 状態確認 グリッド（4×3 / モバイル 2×6） */
.conditions-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.condition-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: #f8f8f8;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  margin: 0;
  user-select: none;
}
.condition-item input { margin: 0; }
.condition-item input:disabled + .condition-label { color: #aaa; }
.custom-note-row { margin-top: 6px; }
.custom-note-row input {
  width: 100%;
  padding: 5px 8px;
  height: 36px;
  font-size: 14px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

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

/* ランク行 / 収穫日行 */
.rank-row, .harvest-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  margin: 6px 0;
  align-items: center;
}
.row-add-btn {
  margin: 6px 0 0;
  padding: 4px 14px;
  height: 32px;
  font-size: 13px;
  background: var(--brand);
}
.row-add-btn:hover { background: var(--brand-d); }
.row-del-btn {
  margin: 0;
  padding: 4px 10px;
  height: 36px;
  font-size: 14px;
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
}
.row-del-btn:hover { background: #962d22; }

/* 写真セクション */
.photo-input-area {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.photo-input-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--brand);
  color: #fff;
  border-radius: var(--radius);
  font-size: 14px;
  cursor: pointer;
  margin: 0;
}
.photo-input-label:hover { background: var(--brand-d); }
.photo-hint { font-size: 12px; color: #888; }

.photos-preview {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.photo-thumb {
  position: relative;
  width: 96px;
  height: 96px;
  border: 1px solid #ddd;
  border-radius: 4px;
  overflow: hidden;
  background: #f0f0f0;
}
.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.photo-thumb-del {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 22px;
  height: 22px;
  padding: 0;
  margin: 0;
  font-size: 14px;
  line-height: 18px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
}
.photo-thumb-del:hover { background: rgba(0, 0, 0, 0.85); }

/* lightbox */
.photo-lightbox {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}
.photo-lightbox-bg {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  cursor: zoom-out;
}
.photo-lightbox img {
  position: relative;
  max-width: 92vw;
  max-height: 88vh;
  border-radius: 6px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.6);
}
.photo-lightbox-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  padding: 0;
  margin: 0;
  font-size: 22px;
  line-height: 32px;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  cursor: pointer;
}
.photo-lightbox-close:hover { background: rgba(255, 255, 255, 0.4); }

/* 保存ボタン・直近一覧の操作 */
.receipt-form .submit-btn {
  margin-top: 16px;
  padding: 10px 22px;
  font-size: 15px;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
}
.receipt-form .submit-btn:hover { background: var(--brand-d); }
.recent-title { margin-top: 24px; }
.btn-detail {
  margin: 0;
  padding: 3px 10px;
  font-size: 12px;
  background: var(--t-blue-bg);
  color: var(--t-blue-fg);
  border-color: var(--t-blue-bd);
  box-shadow: none;
}
.btn-detail:hover { background: var(--t-blue-bgh); }

/* 詳細モーダル：状態 chips / ランク・収穫日リスト / 写真ギャラリー */
.condition-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.condition-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
}
.condition-chip.good {
  background: #e2f3e2;
  border: 1px solid #b6dab6;
  color: #2a7a3a;
}
.condition-chip.issue {
  background: #fff5f0;
  border: 1px solid #f3c8b3;
  color: #b03030;
}
.modal-photos { display: flex; flex-wrap: wrap; gap: 8px; }
.modal-photo {
  width: 84px;
  height: 84px;
  border: 1px solid #ddd;
  border-radius: 4px;
  overflow: hidden;
  cursor: zoom-in;
  background: #f0f0f0;
}
.modal-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ─── 入荷チェック 任意項目のアコーディオン ─────────────────── */
.optional-accordion { margin-top: 12px; }
.optional-accordion summary {
  cursor: pointer;
  padding: 8px 12px;
  background: #f5f7fa;
  border: 1px solid #d8e0e8;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  color: #3a6280;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}
.optional-accordion summary::-webkit-details-marker { display: none; }
.optional-accordion summary::before {
  content: "＋";
  font-size: 16px;
  color: #5a7a9a;
  transition: transform 0.15s ease;
}
.optional-accordion[open] summary::before {
  content: "−";
}
.optional-accordion[open] summary {
  background: #e8eff5;
}
.optional-accordion .acc-body {
  padding: 10px 0 4px;
}

/* ─── iPad 縦 (810px) でフォームをコンパクト寄せ ─────────────── */
@media (max-width: 1024px) {
  /* タイトル下のハンバーガー (top:56px, h:36px → bottom:92px) と h1 が
     視覚的に近接しないよう、コンテンツの上余白を 56px に。
     ヘッダー帯 50px + ハンバーガー余白で合計 約 106px 以上空ける */
  .app-card.wide { max-width: 100%; margin: 56px 14px 24px; padding: 18px 16px; }
  .app-card.wide > h1:first-of-type { padding-left: 40px; }  /* h1 をハンバーガーから離す */
  .receipt-form .form-section { margin-top: 10px; }
  /* タブレット以下では receipt-col-form の h1 にも左パディング必要 */
  .receipt-page .receipt-col-form > h1:first-of-type { padding-left: 40px; }
}

/* ─── 入荷チェック PC レイアウト（≥1025px で 2 カラム） ─────────── */
.receipt-layout { display: block; }
.recent-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 24px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.recent-header .recent-title { margin: 0; }
.recent-header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.recent-date-input {
  height: 32px;
  padding: 4px 8px;
  font-size: 13px;
  border: 1px solid #ccc;
  border-radius: 4px;
}
.print-btn {
  height: 32px;
  margin: 0;
  padding: 4px 12px;
  font-size: 13px;
  background: var(--brand);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}
.print-btn:hover { background: var(--brand-d); }

/* 印刷専用要素は通常は非表示 */
.print-only { display: none; }

@media (min-width: 1025px) {
  /* タブ式（フェーズ 8-12 で 2 カラム grid を廃止）。1280px 上限で左右余白を確保 */
  .app-card.wide.receipt-page { max-width: 1280px; }
  .receipt-page .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 14px;
  }
}

/* ─── 印刷用スタイル ─────────────────────────────────────────── */
/* 印刷専用テーブルは通常時は非表示 */
.print-only-table { display: none; }

@media print {
  /* 不要要素を消す */
  .header-bar,
  .app-sidebar,
  .sb-hamburger,
  .sb-overlay,
  .tab-bar,
  #panel-form,
  .recent-header,
  .recent-list,
  .screen-only,
  #photo-lightbox,
  .photo-modal,
  .save-toast,
  .pw-modal-overlay {
    display: none !important;
  }
  /* 入荷記録パネルが hidden でも印刷時は強制表示 */
  #panel-list { display: block !important; }
  #panel-list[hidden] { display: block !important; }
  html, body {
    background: #fff !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
  }
  /* カード等の幅制約を完全に解除 */
  .app-card,
  .app-card.wide,
  .app-card.wide.receipt-page {
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    background: #fff !important;
    border: none !important;
  }
  .tab-panel { display: block !important; width: 100% !important; max-width: 100% !important; }
  .print-only { display: block !important; }
  .print-title {
    font-size: 14px;
    font-weight: 700;
    margin: 0 0 8px;
    text-align: center;
  }
  /* 印刷専用フラット表のみ表示。
     用紙端ぎりぎりに当たらないよう左右に 2% の余白を残す（Chrome のデフォルトマージン設定で
     表幅が印刷可能領域をはみ出して右端が欠ける現象を回避） */
  .print-only-table {
    display: table !important;
    width: 96% !important;
    max-width: 96% !important;
    border-collapse: collapse !important;
    font-size: 9px !important;
    table-layout: fixed !important;
    margin: 0 auto !important;
  }
  .print-only-table th,
  .print-only-table td {
    border: 1px solid #555 !important;
    padding: 2px 3px !important;
    vertical-align: top;
    word-wrap: break-word;
    word-break: break-all;
    overflow-wrap: anywhere;
    box-sizing: border-box;
  }
  .print-only-table thead th {
    background: #eee !important;
    font-weight: 600;
    text-align: center;
    font-size: 9px;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .print-only-table tbody tr { page-break-inside: avoid; }
  /* 列幅（A4 縦 ≒ 190mm 印刷可能領域を % 配分。1 入荷（車番）= 1 行。基数・ランク集計列ぶん再配分） */
  .print-only-table col.col-vehicle    { width: 6%; }
  .print-only-table col.col-producer   { width: 12%; }
  .print-only-table col.col-sub        { width: 5%; }
  .print-only-table col.col-variety    { width: 9%; }
  .print-only-table col.col-baseno     { width: 4%; }
  .print-only-table col.col-rank       { width: 9%; }
  .print-only-table col.col-state      { width: 18%; }
  .print-only-table col.col-warehouse  { width: 8%; }
  .print-only-table col.col-note       { width: 15%; }
  .print-only-table col.col-harvest    { width: 14%; }
  @page { size: A4 portrait; margin: 12mm 10mm; }
}

@media (max-width: 768px) {
  /* ヘッダー帯の右側がスマホ幅で 2 行に折り返してヘッダー高さが膨らむのを防ぐ */
  .header-bar #header-user-name,
  .header-bar .header-mascot { display: none !important; }
}

/* ─── フェーズ 8：基ごと再設計 ─────────────────────────────────── */
/* 基テーブル：1 入荷 = N 行。⑥ 入荷基数で動的展開。 */
.bases-section { margin-top: 16px; }
.bases-table-wrap { overflow-x: auto; position: relative; }
.bases-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  min-width: 780px;
  table-layout: fixed;
}
.bases-table thead th {
  background: #e8f0ff;
  color: #1a56db;
  font-weight: 600;
  font-size: 12px;
  padding: 6px 6px;
  border: 1px solid #cfd8e0;
  text-align: center;
}
.bases-table tbody td {
  border: 1px solid #cfd8e0;
  padding: 4px 6px;
  vertical-align: middle;
  background: #fafcff;
}
.bases-table .col-baseno { width: 36px; text-align: center; font-weight: 700; color: #1a56db; }
.bases-table .col-rank { width: 80px; }
.bases-table .col-warehouse { width: 120px; }
.bases-table .col-harvest { width: 120px; }
.bases-table .col-photo { width: 76px; text-align: center; }
.bases-table .col-action { width: 108px; }
.bases-table .col-note { min-width: 90px; }
.bases-table .col-conditions { min-width: 150px; }

.bases-table input[type="text"],
.bases-table input[type="date"],
.bases-table input[type="number"],
.bases-table select {
  width: 100%;
  height: 30px;
  padding: 3px 6px;
  font-size: 13px;
  border: 1px solid #c0c8d0;
  border-radius: 3px;
  background: #fff;
}

/* 状態確認マルチセレクト（自前ドロップダウン） */
.condition-multi { position: relative; width: 100%; }
.condition-multi-display {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  min-height: 30px;
  padding: 3px 24px 3px 6px;
  border: 1px solid #c0c8d0;
  border-radius: 3px;
  background: #fff;
  cursor: pointer;
  position: relative;
  font-size: 12px;
}
.condition-multi-display:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
.ms-chips { display: inline-flex; gap: 3px; flex-wrap: wrap; }
.ms-chip {
  display: inline-block;
  padding: 1px 6px;
  background: #1a56db;
  color: #fff;
  border-radius: 9px;
  font-size: 11px;
  white-space: nowrap;
}
.ms-chip-custom { background: #6c757d; }
.ms-placeholder { color: #8a98a8; font-size: 12px; }
.ms-arrow { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); color: #5e6f80; pointer-events: none; }
.condition-multi-popup {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 100;
  min-width: 220px;
  max-width: 320px;
  background: #fff;
  border: 1px solid #c0c8d0;
  border-radius: 4px;
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  padding: 8px 10px;
  margin-top: 2px;
}
.condition-multi-popup[hidden] { display: none; }
.ms-items {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 10px;
  max-height: 240px;
  overflow-y: auto;
}
.ms-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  margin: 0;
  padding: 2px 0;
  cursor: pointer;
  white-space: nowrap;
}
.ms-item input[type="checkbox"] { margin: 0; }
.ms-item input:disabled + * { color: #aaa; }
.ms-custom { margin-top: 6px; border-top: 1px solid #e3e3e3; padding-top: 6px; }
.ms-custom-input {
  width: 100%;
  padding: 4px 6px;
  font-size: 12px;
  border: 1px solid #c0c8d0;
  border-radius: 3px;
}

/* 写真セルボタン（淡色アウトライン：主役CTAと差をつける） */
.photo-cell-btn {
  margin: 0;
  padding: 4px 10px;
  height: 30px;
  font-size: 12px;
  background: #ffffff;
  color: var(--brand);
  border: 1.5px solid var(--brand);
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
}
.photo-cell-btn:hover { background: #f0faf4; }
.photo-count-label { font-weight: 600; }

/* 「以下へ反映」ボタン（淡色アウトライン） */
.copy-down-btn {
  margin: 0;
  padding: 4px 8px;
  height: 30px;
  font-size: 11px;
  background: #ffffff;
  color: var(--brand);
  border: 1.5px solid var(--brand);
  border-radius: var(--radius);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.copy-down-btn:hover { background: #f0faf4; }

/* 写真モーダル（基ごと） */
.photo-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1500;
}
.photo-modal[hidden] { display: none; }
.photo-modal-bg {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.45);
  cursor: pointer;
}
.photo-modal-content {
  position: relative;
  background: #fff;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  border-radius: 8px;
  box-shadow: 0 4px 24px rgba(0,0,0,.18);
  display: flex;
  flex-direction: column;
}
.photo-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid #e3e3e3;
}
.photo-modal-header h3 { margin: 0; font-size: 15px; }
.photo-modal-close {
  width: 32px; height: 32px;
  margin: 0; padding: 0;
  font-size: 22px; line-height: 1;
  background: transparent; color: #666;
  border: none; cursor: pointer;
}
.photo-modal-close:hover { color: #222; background: transparent; }
.photo-modal-body { padding: 14px 18px; overflow-y: auto; }
.photo-modal-footer {
  display: flex; justify-content: flex-end;
  padding: 10px 16px; border-top: 1px solid #e3e3e3;
}
.photo-modal-footer .submit-btn { margin: 0; padding: 6px 18px; font-size: 14px; }

/* スマホ：基テーブルは横スクロール許容＋セル内コンパクト維持 */
@media (max-width: 768px) {
  .bases-table { min-width: 820px; font-size: 12px; }
  .bases-table thead th { font-size: 11px; padding: 4px; }
  .bases-table tbody td { padding: 3px 4px; }
}

/* 詳細モーダル閲覧モード：基ブロック縦展開 */
.detail-view .detail-section { margin-bottom: 18px; }
.detail-view .detail-section-title {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 600;
  color: #3aa76d;
  border-bottom: 1px solid #cfd8e0;
  padding-bottom: 4px;
}
.base-detail-block {
  border: 1px solid #cfd8e0;
  border-radius: 6px;
  margin-bottom: 8px;
  background: #fafcff;
}
.base-detail-title {
  background: #e8f0ff;
  color: #1a56db;
  font-weight: 600;
  font-size: 13px;
  padding: 5px 10px;
  border-bottom: 1px solid #cfd8e0;
  border-radius: 6px 6px 0 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.base-rank-pill {
  display: inline-block;
  padding: 1px 8px;
  background: #1a56db;
  color: #fff;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 600;
}
.base-detail-grid { padding: 6px 10px; }
.base-detail-grid .modal-row {
  padding: 4px 0;
  border-bottom: 1px dashed #e3e8ee;
  font-size: 13px;
}
.base-detail-grid .modal-row:last-child { border-bottom: none; }
.base-detail-grid .modal-label { width: 80px; font-size: 12px; }

/* ─── スマホ（768px 以下）: アコーディオン中身のスペース詰め ── */
@media (max-width: 768px) {
  .app-card.wide { margin: 8px 10px 20px; padding: 14px 12px; }
  .app-card.wide h1 { font-size: 18px; margin-bottom: 12px; }
  .receipt-form input[type="text"],
  .receipt-form input[type="number"],
  .receipt-form input[type="date"],
  .receipt-form select { height: 38px; font-size: 15px; padding: 6px 8px; }
  .receipt-form input[type="date"] { min-height: 38px; }
  .receipt-form .form-grid { gap: 6px 10px; }
  .receipt-form .form-section { margin-top: 8px; }
  .receipt-form .section-label { margin: 8px 0 4px; }
  .recent-title { margin-top: 18px; font-size: 15px; }

  /* 直近一覧をスマホでカード形式に */
  .recent-list table,
  .recent-list thead,
  .recent-list tbody,
  .recent-list tr,
  .recent-list th,
  .recent-list td { display: block; width: 100%; box-sizing: border-box; }
  .recent-list thead { display: none; }
  .recent-list tr {
    border: 1px solid #d8e0e8;
    border-radius: 6px;
    margin-bottom: 10px;
    padding: 8px 10px;
    background: #fff;
  }
  .recent-list td {
    border: none;
    padding: 4px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    font-size: 13px;
  }
  .recent-list td::before {
    content: attr(data-label);
    font-weight: 600;
    color: #6b6b6b;
    font-size: 12px;
    flex-shrink: 0;
  }
  .recent-list td.muted { display: block; text-align: center; padding: 12px 0; }
  .recent-list td.muted::before { display: none; }
}

/* ─── フェーズ 8-12：タブ切替 + スマホ用基カード + 保存トースト ──── */

.tab-bar {
  display: flex;
  gap: 6px;
  border-bottom: 2px solid var(--brand);
  margin: 0 0 16px;
  padding: 0;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 50;
}
.tab-btn {
  margin: 0;
  padding: 10px 22px;
  background: transparent;
  color: #555;
  border: 2px solid transparent;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s, color 0.15s;
}
.tab-btn:hover { background: #eef7f0; color: var(--brand); }
.tab-btn.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}
.tab-btn.active:hover { background: var(--brand-d); color: #fff; }

.tab-panel { display: block; }
.tab-panel[hidden] { display: none !important; }

/* 保存・コピー完了トースト（濃紺グレー地＋緑チェック） */
.save-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1f2937;
  color: #f3f5f8;
  padding: 13px 20px;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.28);
  font-size: 14px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.3s, transform 0.3s;
  z-index: 3000;
  pointer-events: none;
}
.save-toast .bi { color: #4ade80; font-size: 18px; }
.save-toast.show { opacity: 1; transform: translateY(0); }
.save-toast[hidden] { display: none; }

/* スマホ（≤768px）: 基テーブルを 1 基 = 1 カード縦積みに変形（CSS だけで切替） */
@media (max-width: 768px) {
  .bases-table,
  .bases-table thead,
  .bases-table tbody,
  .bases-table tr,
  .bases-table td { display: block; width: 100%; }
  .bases-table thead { display: none; }
  .bases-table { min-width: 0; table-layout: auto; border: none; }

  .bases-table tr.base-row {
    border: 1px solid #cfd8e0;
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: 12px;
    background: #fafcff;
    position: relative;
  }
  .bases-table tr.base-row::before {
    content: "基 " attr(data-base-index);
    display: block;
    font-weight: 700;
    color: #1a56db;
    font-size: 13px;
    border-bottom: 1px dashed #cfd8e0;
    padding-bottom: 4px;
    margin-bottom: 6px;
  }
  .bases-table tbody td {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
    border: none;
    background: transparent;
  }
  .bases-table td.col-baseno { display: none; }   /* ::before で代替済み */
  .bases-table td::before {
    content: attr(data-label);
    width: 78px;
    flex-shrink: 0;
    font-weight: 600;
    color: #555;
    font-size: 12px;
  }
  .bases-table .col-conditions,
  .bases-table .col-rank,
  .bases-table .col-warehouse,
  .bases-table .col-note,
  .bases-table .col-harvest { min-width: 0; width: auto; }
  .bases-table td .base-rank,
  .bases-table td .base-warehouse,
  .bases-table td .base-note,
  .bases-table td .base-harvest,
  .bases-table td .condition-multi { flex: 1; min-width: 0; }
  .bases-table td.col-action {
    margin-top: 4px;
    padding-top: 6px;
    border-top: 1px dashed #cfd8e0;
  }
  .bases-table td.col-action::before { display: none; }
  .bases-table td.col-action .copy-down-btn { width: 100%; padding: 8px; }

  /* スマホでマルチセレクト popup が画面端で切れないよう、コンテンツに合わせて幅自動 */
  .condition-multi-popup { left: 0; right: auto; min-width: 200px; max-width: 90vw; }

  /* タブバーをスマホでもタップしやすく */
  .tab-btn { padding: 9px 16px; font-size: 14px; }

  .save-toast { bottom: 16px; right: 16px; left: 16px; justify-content: center; }
}

