/* ============================================
   eBay Export Manager - Stylesheet
   ============================================ */

/* 出品モーダルの必須フィールド可視化 */
.req-missing {
  border: 2px solid #ef4444 !important;
  background: #fef2f2 !important;
  box-shadow: inset 0 0 0 1px rgba(239,68,68,0.15) !important;
}
.req-filled {
  border: 2px solid #10b981 !important;
  background: #ecfdf5 !important;
}
.req-missing-label {
  color: #dc2626 !important;
  font-weight: bold;
}
.req-missing-label::after {
  content: ' *必須';
  color: #dc2626;
  font-size: 0.75rem;
}
#list-req-summary {
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.85rem;
  margin: 6px 0;
}
#list-req-summary.ok {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #10b981;
}
#list-req-summary.ng {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #ef4444;
}

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

html {
  font-size: 14px;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0f2f5;
  color: #333;
  line-height: 1.6;
}

/* App Layout */
.app {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  width: 220px;
  min-width: 220px;
  background: #1a1a2e;
  color: #ccc;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-header {
  padding: 24px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo {
  font-size: 1.3rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.5px;
}

.sidebar-subtitle {
  font-size: 0.8rem;
  color: #7f8c9b;
  margin-top: 2px;
}

.sidebar-menu {
  list-style: none;
  padding: 12px 0;
  flex: 1;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 22px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff !important;
  border-left: 3px solid transparent;
}

.menu-item:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
}

.menu-item.active {
  background: rgba(255,255,255,0.1);
  color: #fff;
  border-left-color: #4a9eff;
}

.menu-icon {
  font-size: 1.4rem;
  width: 28px;
  text-align: center;
}

.sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-version {
  font-size: 0.75rem;
  color: #555;
}

/* Sidebar toggle */
.sidebar-toggle {
  background: none;
  border: none;
  color: rgba(255,255,255,0.6);
  font-size: 0.9rem;
  cursor: pointer;
  position: absolute;
  top: 16px;
  right: 8px;
  padding: 4px;
}

.sidebar-toggle:hover { color: #fff; }

.sidebar.collapsed {
  width: 60px;
  min-width: 60px;
}

.sidebar.collapsed .sidebar-logo,
.sidebar.collapsed .sidebar-subtitle,
.sidebar.collapsed .menu-label,
.sidebar.collapsed .sidebar-version { display: none; }

.sidebar.collapsed .sidebar-header { padding: 16px 10px; text-align: center; }
.sidebar.collapsed .menu-item { padding: 12px; justify-content: center; }
.sidebar.collapsed .menu-icon { margin: 0; }
.sidebar.collapsed .sidebar-toggle { right: 50%; transform: translateX(50%); }

.sidebar.collapsed + .main-content { margin-left: 60px; }

/* ---- Main Content ---- */
.main-content {
  flex: 1;
  margin-left: 220px;
  padding: 16px 16px;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* Sections */
.section {
  display: none;
}

.section.active {
  display: block;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 20px;
}

/* ---- KPI Cards ---- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  text-align: center;
}

.kpi-card-sm {
  padding: 14px 16px;
}

.kpi-card-sm .kpi-value {
  font-size: 1.2rem;
}

.kpi-label {
  font-size: 0.8rem;
  color: #888;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.kpi-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: #1a1a2e;
  display: inline-block;
  vertical-align: baseline;
}

.kpi-unit {
  font-size: 0.85rem;
  color: #666;
  margin-top: 0;
  margin-left: 4px;
  display: inline-block;
  vertical-align: baseline;
  white-space: nowrap;
}

.kpi-progress-bar {
  width: 100%;
  height: 8px;
  background: #e9ecef;
  border-radius: 4px;
  margin-top: 10px;
  overflow: hidden;
}

.kpi-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #4a9eff, #28c76f);
  border-radius: 4px;
  transition: width 0.6s ease;
}

.kpi-target-label {
  font-size: 0.7rem;
  color: #aaa;
  margin-top: 6px;
}

/* ---- Cards ---- */
.card {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  margin-bottom: 20px;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: #1a1a2e;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid #f0f0f0;
}

/* ---- Tables ---- */
.table-wrapper {
  overflow: auto;
  max-height: calc(100vh - 180px);
  width: 100%;
}

.data-table {
  width: 100%;
  table-layout: auto;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.data-table thead th {
  background: #f8f9fb;
  color: #555;
  font-weight: 600;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid #e9ecef;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 10;
  user-select: none;
  box-shadow: 0 2px 0 #e9ecef;
}
/* 有在庫 table header 強制 sticky (背景白で行スクロール時 透けず) */
#table-inventory thead th {
  position: sticky !important;
  top: 0 !important;
  background: #f8f9fb !important;
  z-index: 20;
  box-shadow: 0 3px 6px rgba(0,0,0,0.1);
}

.data-table thead th[data-sort] {
  cursor: pointer;
}

.data-table thead th[data-sort]:hover {
  background: #eef1f5;
}

.data-table thead th .sort-indicator {
  margin-left: 4px;
  font-size: 0.7rem;
  color: #aaa;
}

.data-table thead th .sort-indicator.asc::after {
  content: ' \25B2';
}

.data-table thead th .sort-indicator.desc::after {
  content: ' \25BC';
}

.data-table tbody tr {
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.15s;
}

.data-table tbody tr:nth-child(even) {
  background: #fafbfc;
}

.data-table tbody tr:hover {
  background: #f0f5ff;
}

.data-table tbody td {
  padding: 8px 12px;
  vertical-align: middle;
}

.data-table .thumbnail {
  width: 50px;
  height: 50px;
  object-fit: cover;
  border-radius: 4px;
  background: #f0f0f0;
}

.data-table .no-image {
  width: 50px;
  height: 50px;
  background: #f0f0f0;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ccc;
  font-size: 0.7rem;
}

/* Profit coloring */
.profit-positive {
  color: #16a34a;
  font-weight: 600;
}

.profit-warning {
  color: #e67e22;
  font-weight: 600;
}

.profit-negative {
  color: #dc2626;
  font-weight: 600;
}

.row-loss {
  background-color: #fff0f0 !important;
}

.row-return {
  background-color: #ffcccc !important;
}

/* Compact table for sales */
.data-table-compact {
  font-size: 0.72rem;
}

.data-table-compact thead th {
  padding: 3px 4px;
  font-size: 0.7rem;
  white-space: nowrap;
}

.data-table-compact tbody td {
  padding: 2px 4px;
  white-space: nowrap;
}

/* ホーム 全体を大きく濃く */
#section-dashboard { font-size: 1.05rem; color: #111; }
#section-dashboard h2, #section-dashboard h3, #section-dashboard h4 { color: #111 !important; }
#section-dashboard .card-title { font-size: 1.4rem !important; color: #111 !important; font-weight: 800 !important; }
#section-dashboard .section-title { font-size: 1.7rem !important; color: #111 !important; font-weight: 800; }
#section-dashboard p, #section-dashboard div, #section-dashboard span, #section-dashboard label { color: #1f2937; }
#section-dashboard table { font-size: 1.05rem; color: #111; }
#section-dashboard table thead th { color: #111 !important; font-weight: 700 !important; background: #eef2f7 !important; padding: 10px 8px !important; font-size: 1rem !important; border-bottom: 3px solid #555 !important; }
#section-dashboard table tbody td { color: #111 !important; padding: 10px 8px !important; font-size: 1.1rem; font-weight: 600; }
#section-dashboard table tbody tr { border-bottom: 2px solid #999 !important; }
#section-dashboard .kpi-unit { font-size: 1rem !important; color: #444 !important; font-weight: 600; }
/* ホーム ランキング/販売状況 inline font 上書き */
#section-dashboard #advice-list,
#section-dashboard #inventory-info,
#section-dashboard #trend-info,
#section-dashboard #high-profit-list,
#section-dashboard #loss-list { font-size: 1.05rem !important; color: #111 !important; line-height: 1.5; }
#section-dashboard #activity-today .kpi-value { font-size: 1.6rem !important; color: #111 !important; font-weight: 800 !important; }
#section-dashboard #activity-today .kpi-label { font-size: 0.95rem !important; color: #444 !important; font-weight: 700; }
#section-dashboard #activity-today .kpi-unit { font-size: 0.9rem !important; }

/* 設定 カード フォールド (collapsed 時 card-title 以外 非表示) */
#section-settings .card.collapsed > *:not(.card-title) { display: none !important; }
#section-research .card.collapsed > *:not(.card-title) { display: none !important; }
#section-research .card.collapsed { margin-bottom: 8px !important; }
#section-settings .card .card-title { transition: opacity 0.2s; }
#section-settings .card .card-title:hover { opacity: 0.75; }

/* 作業管理 全体を大きく濃く (ホーム同様) */
#section-work { font-size: 1.05rem; color: #111; }
#section-work h2, #section-work h3, #section-work h4 { color: #111 !important; }
#section-work .card-title { font-size: 1.4rem !important; color: #111 !important; font-weight: 800 !important; }
#section-work .section-title { font-size: 1.7rem !important; color: #111 !important; font-weight: 800; }
#section-work p, #section-work div, #section-work span, #section-work label { color: #1f2937; }
#section-work table { font-size: 1.05rem; color: #111; }
#section-work table thead th { color: #111 !important; font-weight: 700 !important; background: #eef2f7 !important; padding: 10px 8px !important; font-size: 1rem !important; border-bottom: 3px solid #555 !important; }
#section-work table tbody td { color: #111 !important; padding: 10px 8px !important; font-size: 1.1rem; font-weight: 600; }
#section-work table tbody tr { border-bottom: 2px solid #999 !important; }
#section-work .kpi-card { padding: 14px 16px !important; }
#section-work .kpi-value { font-size: 1.6rem !important; color: #111 !important; font-weight: 800 !important; }
#section-work .kpi-label { font-size: 1rem !important; color: #444 !important; font-weight: 700 !important; }
#section-work .kpi-unit { font-size: 1rem !important; color: #444 !important; font-weight: 600; }
#section-work input, #section-work select, #section-work textarea { font-size: 1rem !important; font-weight: 600 !important; color: #111 !important; padding: 8px 10px !important; }
#section-work .btn { font-size: 1rem !important; font-weight: 700 !important; padding: 8px 14px !important; }
#section-work .form-label { font-size: 1rem !important; font-weight: 700 !important; color: #111 !important; }

/* ホーム 月別利益推移 表を大きく濃く */
#table-monthly { font-size: 1.05rem; }
#table-monthly thead th { font-size: 1.05rem !important; padding: 10px 8px !important; color: #111 !important; font-weight: 700 !important; background: #eef2f7 !important; border-bottom: 3px solid #555 !important; }
#table-monthly tbody td { font-size: 1.1rem !important; padding: 10px 8px !important; color: #111 !important; font-weight: 600; }
#table-monthly tbody tr { border-bottom: 2px solid #999 !important; }

/* 販売管理 + ホーム 上部 KPIサマリ を大きく濃く */
#sales-summary-revenue, #sales-summary-count, #sales-summary-remaining, #sales-summary-pct,
#sales-summary-profit, #sales-summary-profit-rate, #sales-summary-profit-refund, #sales-summary-profit-rate-refund,
#kpi-sales, #kpi-count, #kpi-remaining, #kpi-target-pct,
#kpi-profit-only, #kpi-profit-rate, #kpi-profit, #kpi-profit-rate-refund {
  font-size: 1.8rem !important;
  font-weight: 800 !important;
  color: #111 !important;
}
#section-sales .kpi-card.kpi-card-sm .kpi-label,
#section-dashboard .kpi-card.kpi-card-sm .kpi-label { font-size: 0.95rem !important; color: #444 !important; font-weight: 700; }
#section-sales .kpi-card.kpi-card-sm,
#section-dashboard .kpi-card.kpi-card-sm { padding: 16px 18px; }

/* 出品管理 上部 (タイトル + toolbar + filter/button) を大きく濃く */
#section-listings .section-title { font-size: 1.7rem !important; color: #111 !important; font-weight: 800; }
#section-listings .toolbar { font-size: 1.05rem; }
#section-listings .toolbar-left .input-search,
#section-listings .toolbar-left .input-select { font-size: 1rem !important; padding: 6px 10px !important; min-height: 36px; color: #111 !important; font-weight: 600; }
#section-listings .toolbar-left .input-select { min-width: 110px; }
#section-listings .toolbar .btn,
#section-listings .toolbar button { font-size: 1rem !important; padding: 7px 14px !important; font-weight: 700; }
#section-listings .item-count { font-size: 1.1rem !important; color: #111 !important; font-weight: 700; }
#section-listings #listings-bulk-count { font-size: 1rem !important; color: #111 !important; font-weight: 600; }
#section-listings #btn-monitor-by-status { font-size: 0.95rem !important; padding: 6px 14px !important; }

/* 販売管理テーブルも同等サイズ + 濃いライン */
#table-sales.data-table-compact { font-size: 1.05rem; table-layout: auto; }
#table-sales.data-table-compact thead th { padding: 6px 6px; font-size: 1rem !important; text-align: center !important; font-weight: 700; color: #111 !important; }
#table-sales.data-table-compact tbody td { padding: 4px 5px; font-size: 1.05rem; color: #111; }
#table-sales.data-table-compact .thumbnail,
#table-sales .sale-zoom-img { width: 90px !important; height: 90px !important; }
#table-sales tbody tr { border-bottom: 2px solid #999 !important; }
#table-sales thead th { border-bottom: 3px solid #555 !important; box-shadow: 0 3px 0 #555 !important; }
#table-sales tbody td.text-right { font-size: 1.05rem; font-weight: 400; color: #111; }
#table-sales input[type="checkbox"] { width: 22px; height: 22px; cursor: pointer; }
#table-sales input[type="text"],
#table-sales input[type="number"],
#table-sales select,
#table-sales textarea { font-size: 1.05rem !important; padding: 3px 5px !important; min-height: 28px; max-width: 80px; font-weight: 400; color: #111; }

/* 確定/常時bold = default style (上書きなし) */
#table-sales .cell-confirmed,
#table-sales .cell-bold {
  /* default style 上書きなし */
}
/* 未確定 (見込み計算値) = italic + grey 薄字 */
#table-sales .cell-provisional {
  font-weight: 400 !important;
  color: #9ca3af !important;
  font-style: italic !important;
}
/* キャンセル/リタリク 等の status-select は文字小さく */
#table-sales select.status-select { font-size: 0.7rem !important; max-width: 60px; padding: 2px 3px !important; min-height: 22px; }
/* 処理列(1) を狭く */
#table-sales th:nth-child(1),
#table-sales tbody td:nth-child(1) { max-width: 65px; min-width: 50px; }
#table-sales .btn,
#table-sales button { font-size: 0.95rem !important; padding: 3px 6px !important; font-weight: 700; }
#table-sales a { font-size: 1rem; }
#table-sales a.sub-link-ebay,
#table-sales span.sub-link-manage,
#table-sales a.sub-link-source {
  font-size: 1.05rem !important;
  padding: 5px 10px !important;
  white-space: nowrap;
  font-weight: 800;
  margin-right: 0 !important;
  border-radius: 6px;
}

/* 出品管理テーブルは大きめサイズ + 濃いライン (sales は変更なし、横幅収まる調整) */
/* 出品管理 table: 横幅 画面ぴったり (overflow なし、 余白なし) */
#table-listings.data-table-compact { font-size: 1.05rem; table-layout: fixed; width: 100% !important; min-width: 100%; max-width: 100%; }
#table-listings.data-table-compact th,
#table-listings.data-table-compact td { overflow: hidden; text-overflow: ellipsis; word-break: break-word; }
/* table-wrapper を 横スクロールなしに固定 */
#section-listings .table-wrapper { overflow-x: hidden; width: 100%; }
/* 売価/仕入 input は セル幅 100% + spinner 削除 + font/padding 圧縮 */
#table-listings .lst-price,
#table-listings .lst-cost {
  max-width: 100% !important;
  width: 100% !important;
  box-sizing: border-box;
  padding: 2px 2px !important;
  font-size: 0.9rem !important;
  text-align: right;
  min-height: 24px;
  -moz-appearance: textfield;
}
#table-listings .lst-price::-webkit-inner-spin-button,
#table-listings .lst-price::-webkit-outer-spin-button,
#table-listings .lst-cost::-webkit-inner-spin-button,
#table-listings .lst-cost::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
/* 数量 input セル内 fit (padding 削減 + font 縮小 + spinner 削除) */
#table-listings .lst-qty {
  max-width: 100% !important;
  width: 100% !important;
  box-sizing: border-box;
  padding: 2px 0 !important;
  font-size: 0.9rem !important;
  text-align: center;
  min-height: 24px;
  -moz-appearance: textfield;  /* Firefox spinner 削除 */
}
#table-listings .lst-qty::-webkit-inner-spin-button,
#table-listings .lst-qty::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
/* col 12 (数量) 幅 + 余白 確保 */
#table-listings.data-table-compact th:nth-child(12),
#table-listings.data-table-compact td:nth-child(12) { width: 44px !important; padding-left: 1px !important; padding-right: 1px !important; }

/* 列幅 明示 (table-layout: fixed 前提): title 広く / 数値小列 狭く で 管理/eBay btn 見えるように */
#table-listings.data-table-compact th:nth-child(1),
#table-listings.data-table-compact td:nth-child(1) { width: 32px; }  /* checkbox */
#table-listings.data-table-compact th:nth-child(2),
#table-listings.data-table-compact td:nth-child(2) { width: 92px; }  /* image (90px写真) */
#table-listings.data-table-compact th:nth-child(3),
#table-listings.data-table-compact td:nth-child(3) { width: 172px; min-width: 172px; max-width: 172px; }  /* title (eBay/管理/仕入先 btn が収まる幅) */
/* title 2行表示 (3行目以降 ... 省略) */
#table-listings .lst-title-text {
  display: -webkit-box !important;
  -webkit-line-clamp: 2 !important;
  -webkit-box-orient: vertical !important;
  white-space: normal !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  line-height: 1.3 !important;
  word-break: break-word !important;
}
#table-listings.data-table-compact th:nth-child(4),
#table-listings.data-table-compact td:nth-child(4) { width: 58px; }  /* sku */
#table-listings.data-table-compact th:nth-child(5),
#table-listings.data-table-compact td:nth-child(5) { width: 72px; }  /* cost */
#table-listings.data-table-compact th:nth-child(6),
#table-listings.data-table-compact td:nth-child(6) { width: 72px; }  /* price */
#table-listings.data-table-compact th:nth-child(7),
#table-listings.data-table-compact td:nth-child(7) { width: 76px; }  /* profit */
#table-listings.data-table-compact th:nth-child(8),
#table-listings.data-table-compact td:nth-child(8) { width: 60px; }  /* rate */
#table-listings.data-table-compact th:nth-child(9),
#table-listings.data-table-compact td:nth-child(9) { width: 76px; }  /* profit-refund */
#table-listings.data-table-compact th:nth-child(10),
#table-listings.data-table-compact td:nth-child(10) { width: 60px; }  /* rate-refund */
#table-listings.data-table-compact th:nth-child(11),
#table-listings.data-table-compact td:nth-child(11) { width: 64px; }  /* ship */
#table-listings.data-table-compact th:nth-child(12),
#table-listings.data-table-compact td:nth-child(12) { width: 50px; }  /* qty */
#table-listings.data-table-compact th:nth-child(13),
#table-listings.data-table-compact td:nth-child(13) { width: 70px; }  /* status */
#table-listings.data-table-compact th:nth-child(14),
#table-listings.data-table-compact td:nth-child(14) { width: 52px; }  /* sold */
#table-listings.data-table-compact th:nth-child(15),
#table-listings.data-table-compact td:nth-child(15) { width: 56px; }  /* watch */
#table-listings.data-table-compact th:nth-child(16),
#table-listings.data-table-compact td:nth-child(16) { width: 52px; }  /* view */
#table-listings.data-table-compact th:nth-child(17),
#table-listings.data-table-compact td:nth-child(17) { width: 38px; }  /* 実col17=View (縦書きで狭く) */
#table-listings.data-table-compact th:nth-child(18),
#table-listings.data-table-compact td:nth-child(18) { width: 50px; }  /* monitor */
#table-listings.data-table-compact th:nth-child(19),
#table-listings.data-table-compact td:nth-child(19) { width: 50px; }  /* in_stock */
/* header text wrap 許可 (還付込利益 等 2行表示) */
#table-listings.data-table-compact thead th { white-space: normal !important; word-break: keep-all; line-height: 1.15; font-size: 0.85rem !important; }
/* 縦書き header: 出品数 (col 12) / Sold (14) / Watch (15) / View (16) / 監視 (18) / 有在庫 (19) */
#table-listings.data-table-compact thead th:nth-child(12),
#table-listings.data-table-compact thead th:nth-child(14),
#table-listings.data-table-compact thead th:nth-child(15),
#table-listings.data-table-compact thead th:nth-child(16),
#table-listings.data-table-compact thead th:nth-child(20) {
  writing-mode: vertical-rl;
  text-orientation: upright;
  white-space: nowrap !important;
  letter-spacing: 0.05em;
  padding: 8px 2px !important;
  min-height: 60px;
}
/* 縦書き列 幅圧縮 */
#table-listings.data-table-compact th:nth-child(12),
#table-listings.data-table-compact td:nth-child(12) { width: 36px; }  /* qty */
#table-listings.data-table-compact th:nth-child(14),
#table-listings.data-table-compact td:nth-child(14) { width: 36px; }  /* sold */
#table-listings.data-table-compact th:nth-child(15),
#table-listings.data-table-compact td:nth-child(15) { width: 36px; }  /* watch */
#table-listings.data-table-compact th:nth-child(16),
#table-listings.data-table-compact td:nth-child(16) { width: 36px; }  /* view */
#table-listings.data-table-compact th:nth-child(18),
#table-listings.data-table-compact td:nth-child(18) { width: 68px; }  /* 実col18=出品日 (横書きで広く) */
#table-listings.data-table-compact th:nth-child(19),
#table-listings.data-table-compact td:nth-child(19) { width: 50px; }  /* 実col19=監視 (横書き、 監視↑ + トグル↓) */
#table-listings.data-table-compact th:nth-child(20),
#table-listings.data-table-compact td:nth-child(20) { width: 38px; }  /* 実col20=有在庫 (縦書き) */
#table-listings.data-table-compact thead th { padding: 6px 6px; font-size: 1rem !important; text-align: center !important; font-weight: 700; }
#table-listings.data-table-compact tbody td { padding: 4px 5px; font-size: 1.05rem; color: #111; }
/* 数値セル(text-right) は太字で読みやすく */
#table-listings tbody td.text-right { font-size: 1.1rem; font-weight: 700; color: #111; }
#table-listings.data-table-compact td.profit-positive { color: #16a34a !important; }
#table-listings.data-table-compact td.profit-negative { color: #dc2626 !important; }
#table-listings.data-table-compact .thumbnail { width: 90px; height: 90px; }
#table-listings tbody tr { border-bottom: 2px solid #999 !important; }
#table-listings thead th { border-bottom: 3px solid #555 !important; box-shadow: 0 3px 0 #555 !important; }
/* チェックボックス + 入力欄 */
#table-listings input[type="checkbox"] { width: 22px; height: 22px; cursor: pointer; }
#table-listings input[type="text"],
#table-listings input[type="number"],
#table-listings select,
#table-listings textarea { font-size: 1rem !important; padding: 3px 5px !important; min-height: 28px; font-weight: 700; max-width: 65px; color: #111; }
#table-listings .btn,
#table-listings button { font-size: 0.95rem !important; padding: 3px 6px !important; font-weight: 700; min-width: 0; }
#table-listings a { font-size: 1rem; }
/* タイトル列内のサブリンク (eBay/管理/仕入先) は1行に収まるサイズで上書き */
#table-listings a.sub-link-ebay,
#table-listings span.sub-link-manage,
#table-listings a.sub-link-source,
#table-listings span.sub-link-source {
  font-size: 1.05rem !important;
  padding: 5px 10px !important;
  white-space: nowrap;
  font-weight: 800;
  margin-right: 0 !important;
  border-radius: 6px;
}
/* タイトル列(3列目) — タイトル本文だけ2行clamp、item_id/ボタンは別行で表示 */
#table-listings tbody td:nth-child(3) {
  white-space: normal !important;
  max-width: 260px;
  line-height: 1.3;
  vertical-align: top;
}
/* 仕入(円) 列(5) を最小幅 */
#table-listings th:nth-child(5),
#table-listings tbody td:nth-child(5) {
  max-width: 60px;
  min-width: 45px;
  white-space: nowrap;
}
#table-listings tbody td.cell-title-truncate > :first-child,
#table-listings tbody td.cell-title-truncate {
  /* td内の最初のテキストノード(タイトル本文)に line-clamp 効かせる代わり、
     title本体を span ラッパなしのテキストノードで表示させ、wrap許可のみ */
}

/* 出品日 列(17) を3行表示 */
#table-listings tbody td:nth-child(17) {
  white-space: normal !important;
  text-align: center;
  min-width: 70px;
  max-width: 80px;
}

/* Sold/Watch/View 列は数値のみで狭く + 数字太字 */
#table-listings th[data-sort="sold_count"],
#table-listings th[data-sort="watch_count"],
#table-listings th[data-sort="hit_count"],
#table-listings tbody td:nth-child(14),
#table-listings tbody td:nth-child(15),
#table-listings tbody td:nth-child(16) {
  max-width: 65px;
  min-width: 45px;
  font-size: 1.2rem !important;
  font-weight: 800;
  text-align: center;
  color: #111;
}

/* 横スクロール: 親 div で auto、テーブル自体は親の幅内 */
#table-listings {
  table-layout: auto;
}

.data-table-compact .thumbnail {
  width: 40px;
  height: 40px;
}

.data-table-compact .no-image {
  width: 40px;
  height: 40px;
  font-size: 0.6rem;
}

/* Toggle switch (small) */
.toggle-sm { position:relative; display:inline-block; width:36px; height:20px; }
.toggle-sm input { opacity:0; width:0; height:0; }
.toggle-sm-slider {
  position:absolute; cursor:pointer; top:0; left:0; right:0; bottom:0;
  background:#ccc; border-radius:20px; transition:0.3s;
}
.toggle-sm-slider:before {
  position:absolute; content:""; height:16px; width:16px; left:2px; bottom:2px;
  background:#fff; border-radius:50%; transition:0.3s;
}
.toggle-sm input:checked + .toggle-sm-slider { background:#4a90d9; }
.toggle-sm input:checked + .toggle-sm-slider:before { transform:translateX(16px); }

.btn-sm { font-size:0.72rem; padding:3px 8px; }

/* Image dropzone */
.image-dropzone {
  border: 2px dashed #ccc;
  border-radius: 8px;
  padding: 12px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  min-height: 80px;
}

.image-dropzone.dragover {
  border-color: #4a90d9;
  background: #f0f7ff;
}

.dropzone-hint {
  color: #999;
  font-size: 0.8rem;
  margin-top: 6px;
}

.image-preview-area {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.image-preview-item {
  position: relative;
  width: 60px;
  height: 60px;
}

.image-preview-item img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid #ddd;
}

.image-preview-item .img-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #e74c3c;
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: 11px;
  cursor: pointer;
  line-height: 18px;
  text-align: center;
  padding: 0;
}

.image-preview-item img {
  cursor: pointer;
}

.image-preview-item .cover-badge {
  display: none;
  position: absolute;
  top: -6px;
  left: -6px;
  background: #f59e0b;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  pointer-events: none;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
  z-index: 2;
}

.image-preview-item.is-cover .cover-badge {
  display: block;
}

.image-preview-item.is-cover img {
  outline: 2px solid #f59e0b;
  outline-offset: -2px;
}

.image-preview-item.dragging {
  opacity: 0.4;
}

/* Listing title link */
.lst-title-link:hover {
  opacity: 0.7;
}

/* Inline status select */
.status-select {
  padding: 1px 2px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.75rem;
  background: #fff;
  cursor: pointer;
  width: auto;
  min-width: 65px;
}

.status-select:focus {
  border-color: #4a90d9;
  outline: none;
}

/* Inline inputs (shipping, cost, fees, duty) */
.ship-input,
.fees-input,
.duty-input {
  width: 75px;
}

.cost-input {
  width: 80px;
}

.ship-input,
.cost-input,
.fees-input,
.duty-input {
  padding: 2px 4px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.75rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.ship-input:focus,
.cost-input:focus,
.fees-input:focus,
.duty-input:focus {
  border-color: #4a90d9;
  outline: none;
  background: #fffff0;
}

/* Title truncation */
.cell-title-truncate {
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

a.sub-link,
span.sub-link {
  text-decoration: none !important;
  cursor: pointer;
}

/* eBay/管理/仕入先はクリックしやすく拡大、タップ範囲確保 */
a.sub-link-ebay,
span.sub-link-manage,
a.sub-link-source,
span.sub-link-source {
  font-size: 0.95rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  display: inline-block;
  margin-right: 4px;
}
a.sub-link-ebay { background: #2563eb; color: #fff !important; }
span.sub-link-manage { background: #ea580c; color: #fff !important; }
a.sub-link-source, span.sub-link-source { background: #16a34a; color: #fff !important; }
a.sub-link-ebay:hover { background: #1d4ed8; }
span.sub-link-manage:hover { background: #c2410c; }
a.sub-link-source:hover { background: #15803d; }

a.sub-link:hover,
span.sub-link:hover {
  opacity: 0.7;
}

a.sub-link-ebay, a.sub-link-ebay:link, a.sub-link-ebay:visited, a.sub-link-ebay:active, span.sub-link-ebay { color: #fff !important; }
a.sub-link-manage, a.sub-link-manage:link, a.sub-link-manage:visited, a.sub-link-manage:active, span.sub-link-manage { color: #fff !important; }
a.sub-link-source, a.sub-link-source:link, a.sub-link-source:visited, a.sub-link-source:active, span.sub-link-source { color: #fff !important; }

/* オファータブ: eBay/管理/仕入先 ボタン (出品管理/販売/メッセージと統一 + クリックしやすく拡大) */
#section-offers a.sub-link-ebay,
#section-offers span.sub-link-manage,
#section-offers a.sub-link-source,
#section-offers span.offer-mag-parent {
  font-size: 1.05rem !important;
  padding: 9px 16px !important;
  font-weight: 800;
  border-radius: 7px;
  text-decoration: none !important;
  cursor: pointer;
  display: inline-block;
}
#section-offers span.offer-mag-parent:hover { background: #8e44ad !important; }
@media (max-width: 768px) {
  #section-offers a.sub-link-ebay,
  #section-offers span.sub-link-manage,
  #section-offers a.sub-link-source,
  #section-offers span.offer-mag-parent { font-size: 1.05rem !important; padding: 9px 14px !important; }
  /* スマホ: 過大fontだと写真/本文/未済 の3カラムが潰れ本文が単語ごと折返し=縦並びに崩れる。 タップ用に少し拡大した適正サイズに */
  #section-offers .offer-card { font-size: 1.05rem; }
  #section-offers .offer-buyer { font-size: 1.15rem !important; }
  #section-offers .offer-meta,
  #section-offers .offer-latest { font-size: 1rem !important; }
  #section-offers .offer-badge { font-size: 0.9rem !important; padding: 4px 10px !important; }
  #section-offers .offer-oneline > span { font-size: 1rem !important; }
  #section-offers .offer-oneline > b { font-size: 1.35rem !important; }
  #section-offers .offer-msg { font-size: 1.05rem !important; }
  #section-offers .offer-handle-toggle { font-size: 1.05rem !important; padding: 9px 14px !important; }
  #section-offers .offer-thread-toggle { font-size: 1.5rem !important; }
  #section-offers .offer-accept,
  #section-offers .offer-counter,
  #section-offers .offer-decline { font-size: 1.1rem !important; padding: 13px !important; }
  #section-offers .offer-filter-btn { font-size: 1rem !important; padding: 9px 14px !important; }
  #section-offers .offer-photo-stack { max-width: 96px !important; }
  #section-offers .offer-item-id { font-size: 0.95rem !important; }
  #section-offers .offer-countdown { font-size: 1rem !important; }
}

.cell-title-truncate a {
  text-decoration: none;
}

/* Status badges */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}

.badge-active {
  background: #e8f5e9;
  color: #2e7d32;
}

.badge-inactive {
  background: #fff3e0;
  color: #e65100;
}

.badge-sold {
  background: #e3f2fd;
  color: #1565c0;
}

.badge-completed {
  background: #e8f5e9;
  color: #2e7d32;
}

.badge-shipped {
  background: #e3f2fd;
  color: #1565c0;
}

.badge-pending {
  background: #fff3e0;
  color: #e65100;
}

.badge-cancelled {
  background: #fce4ec;
  color: #c62828;
}

.badge-refunded {
  background: #f3e5f5;
  color: #6a1b9a;
}

.badge-delivered {
  background: #e0f2f1;
  color: #00695c;
}

.badge-miship {
  background: #fce4ec;
  color: #ad1457;
}

.badge-partial-refund {
  background: #f3e5f5;
  color: #7b1fa2;
}

.badge-monitor_error { background: #ff9800; color: #fff; }
.badge-draft { background: #9e9e9e; color: #fff; }
.badge-scheduled { background: #2196f3; color: #fff; }
.badge-schedule_error { background: #f44336; color: #fff; }
.badge-lost-refund {
  background: #efebe9;
  color: #4e342e;
}

/* Recommendation badges */
.rec-excellent {
  color: #28a745;
  font-weight: 700;
  font-size: 1.1rem;
}

.rec-good {
  color: #2196f3;
  font-weight: 700;
  font-size: 1.1rem;
}

.rec-fair {
  color: #e67e22;
  font-weight: 700;
  font-size: 1.1rem;
}

.rec-poor {
  color: #e74c3c;
  font-weight: 700;
  font-size: 1.1rem;
}

/* ---- Toolbar ---- */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.input-search {
  padding: 8px 14px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.85rem;
  width: 220px;
  outline: none;
  transition: border-color 0.2s;
}

.input-search:focus {
  border-color: #4a9eff;
}

.input-select {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.85rem;
  outline: none;
  background: #fff;
  cursor: pointer;
}

.input-select:focus {
  border-color: #4a9eff;
}

.item-count {
  font-size: 0.85rem;
  color: #888;
  font-weight: 500;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: #4a9eff;
  color: #fff;
}

.btn-primary:hover {
  background: #3a8eef;
}

.btn-success {
  background: #28c76f;
  color: #fff;
}

.btn-success:hover {
  background: #1fb862;
}

.btn-danger {
  background: #ea5455;
  color: #fff;
}

.btn-danger:hover {
  background: #d94445;
}

.btn-default {
  background: #e9ecef;
  color: #555;
}

.btn-default:hover {
  background: #dde1e5;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.78rem;
}

/* ---- Pagination ---- */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 20px 0 8px;
}

.pagination button {
  padding: 10px 20px;
  border: 2px solid #555;
  border-radius: 6px;
  background: #fff;
  color: #111;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}

.pagination button:hover {
  background: #eef2ff;
  border-color: #2563eb;
}

.pagination button.active {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}

.pagination span {
  font-size: 1.05rem;
  color: #111;
  font-weight: 600;
}

.pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ---- Settings Form ---- */
/* セキュリティ card (max-width 制約なし) と同じ 全幅 に統一 */
.settings-card {
  max-width: 100%;
}
/* 設定ページ 全体フォント拡大 (2026-05-01) */
#section-settings .card-title { font-size: 1.4rem; font-weight: 800; color: #111; }
#section-settings .form-label { font-size: 1rem; font-weight: 700; color: #1f2937; margin-bottom: 4px; }
#section-settings .form-input { font-size: 1.05rem; font-weight: 600; color: #111; padding: 6px 10px; min-height: 36px; }
#section-settings select.form-input { min-height: 38px; }
#section-settings textarea.form-input { font-size: 1rem; font-weight: 500; min-height: auto; }
#section-settings .btn { font-size: 1rem; font-weight: 700; padding: 8px 16px; }
#section-settings .btn-sm { font-size: 0.95rem; font-weight: 700; padding: 6px 12px; }
#section-settings p { font-size: 0.9rem; color: #4b5563; }
#section-settings span { font-size: 1rem; }
#section-settings label span { font-size: inherit; }

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

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

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #ccc;
  border-radius: 22px;
  transition: 0.2s;
}
.toggle-slider:before {
  content: "";
  position: absolute;
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: #4a90d9; }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(18px); }

.form-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #555;
  margin-bottom: 6px;
}

.form-input {
  padding: 9px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus {
  border-color: #4a9eff;
  box-shadow: 0 0 0 3px rgba(74,158,255,0.1);
}

.form-actions {
  margin-top: 24px;
  display: flex;
  justify-content: flex-end;
}

/* ---- Loading Overlay ---- */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 220px;
  right: 0;
  bottom: 0;
  background: rgba(255,255,255,0.75);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 200;
  gap: 12px;
}

.loading-overlay p {
  color: #888;
  font-size: 0.9rem;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #e9ecef;
  border-top-color: #4a9eff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* 月別利益推移 全列中央寄せ (text-right を override) */
.monthly-centered th, .monthly-centered td { text-align: center !important; }

/* 出品モーダル 画面いっぱい (PC) + 文字大きく */
#modal-overlay .modal {
  max-width: calc(95vw - 3cm) !important;
  width: calc(95vw - 3cm) !important;
  max-height: 95vh !important;
}
#modal-overlay .modal .form-label { font-size: 0.95rem !important; }
#modal-overlay .modal .form-input,
#modal-overlay .modal input[type="text"],
#modal-overlay .modal input[type="number"],
#modal-overlay .modal select,
#modal-overlay .modal textarea { font-size: 1rem !important; padding: 8px 10px !important; }
#modal-overlay .modal .modal-header h3 { font-size: 1.3rem !important; }
#modal-overlay .modal .btn { font-size: 1rem !important; padding: 8px 18px !important; }
#modal-overlay .modal label { font-size: 0.95rem !important; }
#modal-overlay .modal { font-size: 0.95rem !important; }

/* ---- API Usage Bar ---- */
.api-usage-bar {
  padding: 1px 6px;
  border-radius: 4px;
  margin-bottom: 2px;
  font-size: 0.78rem;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  color: #0c4a6e;
  display: flex;
  align-items: center;
  gap: 4px;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  line-height: 1;
  flex-wrap: nowrap;
}
.api-usage-bar > span:first-child {
  flex-shrink: 0;
}
#api-usage-stores {
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
}
.api-usage-label-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 1px;
  padding-left: 2px;
  line-height: 1;
}
.api-usage-hint {
  font-size: 0.95rem;
  color: #444;
  white-space: nowrap;
  font-weight: 500;
}
.api-usage-label {
  font-weight: bold;
  font-size: 1.1rem;
  color: #0c4a6e;
}
@media (max-width: 768px) {
  .api-usage-bar { font-size: 0.7rem; gap: 4px; padding: 3px 6px; width: 100%; max-width: 100%; box-sizing: border-box; overflow: hidden; flex-wrap: wrap; }
  .api-usage-hint { font-size: 0.55rem; position: static; transform: none; margin-left: auto; }
  .api-usage-bar #api-usage-stores { gap: 6px !important; font-size: 0.7rem; flex-direction: column; align-items: stretch; width: 100%; min-width: 0; }
  .api-usage-bar #api-usage-stores > span { flex: 1 1 100% !important; display: flex !important; align-items: center; gap: 4px; flex-wrap: wrap; min-width: 0; }
  /* バーチャート 横幅 縮小 */
  .api-usage-bar #api-usage-stores span span[style*="width:120px"] { width: 60px !important; }
  /* label-row も viewport 内に収める */
  .api-usage-label-row { width: 100%; max-width: 100%; box-sizing: border-box; flex-wrap: wrap; gap: 4px; padding: 0 4px; overflow: hidden; }
  .api-usage-label-row .api-usage-label { font-size: 0.9rem; }
  .api-usage-label-row .api-usage-hint { font-size: 0.6rem; }
  .api-usage-label-row #api-usage-app-bar { flex: 1 1 100% !important; min-width: 0 !important; order: 10; }
  .api-usage-label-row #api-usage-toggle { font-size: 0.65rem; padding: 1px 4px; }
}

/* ---- Toast ---- */
#toast-container {
  position: fixed;
  top: 20px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: 8px;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  animation: toastIn 0.3s ease;
  max-width: 480px;
  cursor: pointer;
  border: 2px solid rgba(0,0,0,0.15);
  /* error/warning は デフォで消えない (auto-dismiss クラスで上書き) */
  opacity: 1 !important;
}

/* 自動消去 (success/info): 2.7s 後 fade out */
.toast.auto-dismiss {
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  opacity: 1;
}
/* error/warning は フェードしない、絶対に消えない (click-to-dismiss only) */
.toast-error:not(.auto-dismiss),
.toast-warning:not(.auto-dismiss) {
  animation: toastIn 0.3s ease !important;
  opacity: 1 !important;
}

/* error/warning は click-to-dismiss、視認性UP */
.toast-success {
  background: #16a34a;
}

.toast-error {
  background: #dc2626;
  border-color: #7f1d1d;
}

.toast-warning {
  background: #ea580c;
  color: #fff;
  border-color: #7c2d12;
}

.toast-info {
  background: #2563eb;
}

/* error/warning 用: テキスト選択可能 + ボタン */
.toast-error, .toast-warning {
  cursor: default;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.toast-error .toast-msg, .toast-warning .toast-msg {
  flex: 1;
  user-select: text;
  cursor: text;
  white-space: pre-wrap;
  word-break: break-word;
}
.toast-btn {
  border: 1px solid rgba(255,255,255,0.4);
  background: rgba(0,0,0,0.2);
  color: #fff;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
  font-weight: bold;
  flex-shrink: 0;
}
.toast-btn:hover {
  background: rgba(0,0,0,0.4);
}
.toast-close {
  padding: 4px 8px;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; }
  to { opacity: 0; transform: translateY(-10px); }
}

/* ---- Utilities ---- */
.hidden {
  display: none !important;
}

.text-right {
  text-align: right;
}

.text-center {
  text-align: center;
}

.text-muted {
  color: #aaa;
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: #aaa;
  font-size: 0.95rem;
}

/* ---- Profit Calculator ---- */
.calc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.calc-input-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.calc-input-grid .calc-row { min-width: 0; }
.calc-input-grid .form-input,
.calc-input-grid select.form-input {
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
}

.calc-row {
  margin-bottom: 4px;
}

.calc-row-wide {
  grid-column: span 2;
}

.calc-detail-section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #ddd;
}

.calc-result-section {
  margin-bottom: 4px;
}

.calc-label {
  display: block;
  font-size: 0.85rem;
  color: #555;
  margin-bottom: 4px;
  font-weight: 500;
}

.calc-btn {
  margin-top: 8px;
  width: 100%;
  padding: 10px;
  font-size: 1rem;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.calc-results {
  background: #f8f9fc;
  border-radius: 8px;
  padding: 16px;
}

.calc-result-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 0.9rem;
  border-bottom: 1px solid #eee;
}

.calc-result-label {
  color: #666;
}

.calc-result-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.calc-divider {
  border-top: 2px solid #ccc;
  margin-top: 4px;
  padding-top: 8px;
}

.calc-highlight {
  font-size: 1rem;
  font-weight: 700;
}

.calc-highlight .calc-result-value {
  color: #1a1a2e;
}

.calc-highlight-green {
  font-size: 1rem;
  font-weight: 700;
}

.calc-highlight-green .calc-result-value {
  color: #27ae60;
}

.calc-verdict-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

.calc-verdict {
  padding: 12px;
  border-radius: 8px;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
}

.calc-verdict-btn {
  padding: 12px;
  border-radius: 8px;
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.calc-verdict.ok {
  background: #d4edda;
  color: #155724;
}

.calc-verdict.caution {
  background: #fff3cd;
  color: #856404;
}

.calc-verdict.ng {
  background: #f8d7da;
  color: #721c24;
}

/* ---- Listing Form ---- */
.modal-wide { max-width: 600px; }

.listing-form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.form-section-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1a1a2e;
  margin: 0 0 16px 0;
  padding-bottom: 8px;
  border-bottom: 2px solid #e0e0e0;
}

.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 4px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 4px; }
.form-row-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 8px; margin-bottom: 4px; }

.listing-profit-display {
  background: #fffde7;
  border: 2px solid #ffd600;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 16px;
}

.listing-profit-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.lp-item { text-align: center; }

.lp-label {
  display: block;
  font-size: 0.75rem;
  color: #666;
  margin-bottom: 2px;
}

.lp-value {
  display: block;
  font-size: 1.1rem;
  font-weight: 700;
  color: #1a1a2e;
}

.lp-highlight .lp-value { color: #2e7d32; }

.char-count {
  font-size: 0.75rem;
  color: #999;
  text-align: right;
  margin-top: 2px;
}

.listing-form-right .form-group { margin-bottom: 4px; }
.listing-form-right .form-label { font-size: 0.8rem; margin-bottom: 2px; }
.listing-form-right .form-input { padding: 6px 8px; font-size: 0.9rem; }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal {
  background: #fff;
  border-radius: 12px;
  width: 90%;
  max-width: 700px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid #eee;
}

.modal-header h3 {
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #999;
}

.modal-close:hover {
  color: #333;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid #eee;
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  background: #fff;
  justify-content: flex-end;
}

/* ---- 返信モーダル ---- */
/* PC: 出品モーダル と 同サイズ (calc(95vw - 3cm) 幅、 95vh 高)、 文字大きく濃く */
.reply-modal-inner {
  max-width: calc(95vw - 3cm) !important;
  width: calc(95vw - 3cm) !important;
  max-height: 95vh !important;
}
#reply-modal { font-size: 1.4rem !important; color: #000 !important; }
#reply-modal .form-label { font-size: 1.35rem !important; font-weight: 900 !important; color: #000 !important; }
#reply-modal label { font-size: 1.35rem !important; font-weight: 900 !important; color: #000 !important; }
#reply-modal .form-input,
#reply-modal input[type="text"],
#reply-modal input[type="number"],
#reply-modal select,
#reply-modal textarea {
  font-size: 1.4rem !important;
  font-weight: 700 !important;
  color: #000 !important;
  padding: 14px 16px !important;
  line-height: 1.7 !important;
  border: 2px solid #555 !important;
  border-radius: 6px !important;
  background: #fff !important;
}
#reply-modal .modal-header h3 { font-size: 1.9rem !important; font-weight: 900 !important; color: #000 !important; }
#reply-modal .btn { font-size: 1.3rem !important; font-weight: 800 !important; padding: 13px 28px !important; }
.reply-original-box {
  background: #fff;
  padding: 16px 18px;
  border-radius: 6px;
  border: 2px solid #555;
  font-size: 1.4rem;
  font-weight: 700;
  color: #000;
  margin-bottom: 4px;
  line-height: 1.7;
}
/* 翻訳結果 box: 黄色 背景 廃止、 他 input と 同じ 白背景 + 濃 border (統一) */
.reply-translated-box {
  background: #fff;
  padding: 16px 18px;
  border-radius: 6px;
  border: 2px solid #555;
  font-size: 1.4rem;
  font-weight: 700;
  color: #000;
  line-height: 1.7;
}
/* 送信内容 (英語) 空欄=赤枠、 入力済=緑枠 */
#reply-modal #reply-text-en.reply-empty {
  border: 2px solid #ef4444 !important;
  background: #fef2f2 !important;
}
#reply-modal #reply-text-en.reply-filled {
  border: 2px solid #10b981 !important;
  background: #ecfdf5 !important;
}
.reply-template-select { font-size: 1.4rem !important; font-weight: 700 !important; color: #000 !important; }
.reply-textarea { font-size: 1.4rem !important; font-weight: 700 !important; color: #000 !important; line-height: 1.7 !important; }
/* 返信モーダル 2列レイアウト (日本語入力 | 英訳結果 / 英語送信 | 日本語逆翻訳) */
.reply-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-items: stretch;
}
.reply-col { display: flex; flex-direction: column; min-width: 0; }
/* preview box: 左col 内容物 合計 高さ に合わせて basis 0 + grow で確実に伸ばす */
.reply-preview-box {
  flex: 1 1 0;
  min-height: 130px;
  overflow-y: auto;
  white-space: pre-wrap;
  box-sizing: border-box;
}
/* textarea も基本 sizing: rows=5 維持しつつ shrink/grow 抑止 */
#reply-modal .reply-textarea { flex: 0 0 auto; resize: vertical; }
/* 翻訳btn 行: 右揃え + btn 幅 狭く */
.reply-btn-row { display: flex; justify-content: flex-end; margin-top: 6px; flex: 0 0 auto; }
.reply-translate-btn {
  width: auto !important;
  min-width: 0 !important;
  flex: 0 0 auto !important;
  padding: 6px 14px !important;
  font-size: 0.95rem !important;
}
@media (max-width: 768px) {
  .reply-row { grid-template-columns: 1fr; }
}
.reply-offer-section {
  border-top: 2px solid #999; margin-top: 12px; padding-top: 12px;
}
.reply-offer-toggle {
  font-size: 1.2rem; font-weight: 800; color: #000;
  cursor: pointer; padding: 6px 0; user-select: none;
}
.reply-offer-body { padding: 14px 0 0 0; }
.reply-offer-body p { font-size: 1rem !important; font-weight: 600 !important; color: #333 !important; }
.reply-footer .btn { justify-content: center; }

/* ---- eBay接続ステータス ---- */
.ebay-connection-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}

.ebay-status-icon {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

.ebay-status-icon.connected {
  background: #28c76f;
  box-shadow: 0 0 6px rgba(40,199,111,0.4);
}

.ebay-status-icon.disconnected {
  background: #ea5455;
  box-shadow: 0 0 6px rgba(234,84,85,0.4);
}

/* 画像拡大オーバーレイ（PC・スマホ共通） */
.img-zoom-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.85);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.img-zoom-overlay img {
  max-width: 90%;
  max-height: 90%;
  border-radius: 8px;
}

/* モバイルエリアはPCでは非表示 */
.mobile-area { display: none; }

/* ---- Message Cards ---- */
.message-card {
  background: #fff;
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.message-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.message-sender {
  font-weight: 600;
  font-size: 0.9rem;
  color: #1a1a2e;
}
.message-date {
  font-size: 0.75rem;
  color: #999;
}
.message-body-en {
  background: #f5f5f5;
  padding: 14px 16px;
  border-radius: 8px;
  font-size: 1.1rem;
  font-weight: 600;
  color: #111;
  margin-bottom: 6px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.message-body-ja {
  background: #fff;
  border: 2px solid #555;
  padding: 14px 16px;
  border-radius: 8px;
  font-size: 1.1rem;
  font-weight: 700;
  color: #000;
  line-height: 1.65;
  margin-bottom: 8px;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.message-footer {
  display: flex;
  gap: 8px;
  align-items: center;
}

.message-footer .btn {
  text-align: center;
  justify-content: center;
  display: flex;
  align-items: center;
}
.message-item-link {
  font-size: 0.75rem;
  color: #4a90d9;
}
.unread { border-left: 4px solid #4a90d9; }
/* スレッド表示 */
.msg-thread {
  background: #fff;
  border-radius: 10px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  overflow: hidden;
  display: flex !important;
  flex-direction: row !important;
  align-items: flex-start;
}
.msg-thread-img {
  width: 90px !important;
  height: 90px !important;
  max-width: 90px !important;
  max-height: 90px !important;
  object-fit: cover;
  border-radius: 8px;
  cursor: pointer;
  flex-shrink: 0;
}
.msg-thread-content {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.msg-priority-urgent { border-left: 4px solid #e74c3c !important; background: #fff0f0 !important; box-shadow: 0 0 0 2px #e74c3c33; }
.msg-priority-important { border-left: 4px solid #ff9800 !important; background: #fff8f0 !important; }
.msg-bookmarked { box-shadow: 0 2px 8px rgba(255,193,7,0.3); }
.msg-bookmark-btn {
  cursor: pointer;
  font-size: 1.1rem;
  color: #ccc;
  user-select: none;
  flex-shrink: 0;
}
.msg-bookmark-btn.active { color: #ffc107; }
.msg-bookmark-btn:hover { color: #ffa000; }
.msg-priority-badge {
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: 8px;
  font-weight: 700;
  margin-left: 2px;
  flex-shrink: 0;
  white-space: nowrap;
}
.msg-priority-badge.urgent { background: #e74c3c; color: #fff; animation: pulse-urgent 1.5s infinite; }
.msg-priority-badge.important { background: #ff9800; color: #fff; }
@keyframes pulse-urgent {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}
.msg-thread-unhandled { border-left: 4px solid #e74c3c; }
.msg-thread-handled { border-left: 4px solid #27ae60; opacity: 0.8; }
.msg-thread-header {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  background: #f8f9fc;
  border-bottom: 2px solid #ccc;
  gap: 10px;
}
.msg-thread-checkbox {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: #4a90d9;
}
.msg-thread-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.msg-thread-sender {
  font-weight: 800;
  font-size: 1.2rem;
  color: #000;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.msg-thread-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: nowrap;
}
.msg-action-btn {
  font-size: 1.1rem;
  padding: 6px 14px;
  border-radius: 6px;
  color: #fff !important;
  text-decoration: none !important;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
}
/* メッセージ一覧 返信/削除 ボタン: 大きく濃く */
#section-messages .btn-reply,
#section-messages .btn-hide-thread {
  font-size: 1.1rem !important;
  font-weight: 800 !important;
  padding: 8px 18px !important;
  border-radius: 6px !important;
  color: #fff !important;
  border: 2px solid transparent !important;
}
#section-messages .btn-reply { background: #1d4ed8 !important; border-color: #1e3a8a !important; }
#section-messages .btn-reply:hover { background: #1e3a8a !important; }
#section-messages .btn-hide-thread { background: #b91c1c !important; border-color: #7f1d1d !important; }
#section-messages .btn-hide-thread:hover { background: #7f1d1d !important; }
.msg-btn-ebay { background: #4a90d9; }
.msg-btn-manage { background: #e67e22; }
.msg-btn-source { background: #27ae60; }
.msg-thread-toggle {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.msg-thread-count {
  font-size: 0.95rem;
  font-weight: 700;
  color: #444;
  background: #e5e7eb;
  padding: 3px 10px;
  border-radius: 10px;
}
.msg-thread-messages {
  padding: 8px 14px;
  max-height: 400px;
  overflow-y: auto;
}
.msg-bubble {
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid #f0f0f0;
}
.msg-bubble:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}
.bubble-unhandled {
  background: #fff5f5;
  border-radius: 6px;
  padding: 8px;
  margin-bottom: 8px;
}
.bubble-handled {
  background: #f0faf0;
  border-radius: 6px;
  padding: 8px;
  margin-bottom: 8px;
  opacity: 0.7;
}
.bubble-mine {
  background: #e8f4fd;
  border-radius: 6px;
  padding: 8px;
  margin-bottom: 8px;
  margin-left: 30px;
  border-left: 3px solid #4a90d9;
}
.msg-bubble-date {
  font-size: 0.95rem;
  font-weight: 600;
  color: #555;
  margin-bottom: 6px;
}
.msg-thread-footer {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid #eee;
  background: #fafafa;
}

/* メッセージ 各項目 全体的に文字大きく */
#section-messages .msg-thread { font-size: 1.05rem; }
#section-messages .msg-thread-sender { font-size: 1.35rem !important; }
#section-messages .msg-thread-info > div { font-size: 1rem !important; }
#section-messages .msg-thread-info a { font-size: 1rem !important; }
#section-messages .msg-thread-info span[style*="font-size:0.78rem"],
#section-messages .msg-thread-info span[style*="font-size:0.72rem"],
#section-messages .msg-thread-info span[style*="font-size:0.85rem"] { font-size: 0.95rem !important; padding: 3px 9px !important; }
#section-messages .msg-bubble { font-size: 1.1rem; line-height: 1.6; }
#section-messages .msg-bubble-date { font-size: 1.05rem !important; }
#section-messages .msg-thread-count { font-size: 1.05rem !important; }
#section-messages .msg-action-btn { font-size: 1.15rem !important; padding: 8px 16px !important; }
#section-messages .msg-bookmark-btn { font-size: 1.4rem !important; }

/* location は ID 直右 inline (空白ギャップなし) */
#section-messages .msg-country-inline { display: inline-flex; align-items: center; margin-left: 6px; }
#section-messages .msg-country-inline .country-badge { font-size: 0.95rem !important; padding: 3px 10px !important; background: #fff7ed !important; color: #ea580c !important; border: 1px solid #fed7aa; margin-left: 0 !important; }

@media (max-width: 768px) {
  #section-messages .msg-thread-sender { flex-wrap: wrap; gap: 4px; font-size: 2rem !important; }
  #section-messages .msg-country-inline .country-badge { font-size: 1.5rem !important; padding: 6px 16px !important; }
  /* スマホ message 1.5倍 */
  #section-messages .msg-thread { font-size: 1.5rem; }
  #section-messages .msg-bubble { font-size: 1.6rem !important; line-height: 1.6; }
  #section-messages .msg-bubble-date { font-size: 1.55rem !important; }
  #section-messages .msg-thread-info > div { font-size: 1.5rem !important; }
  #section-messages .msg-thread-info a { font-size: 1.5rem !important; }
  #section-messages .msg-action-btn { font-size: 1.7rem !important; padding: 14px 20px !important; }
  #section-messages .msg-bookmark-btn { font-size: 2.1rem !important; }
  #section-messages .message-body-en,
  #section-messages .message-body-ja { font-size: 1.55rem !important; padding: 14px 16px !important; line-height: 1.65; }
  #section-messages .msg-thread-count { font-size: 1.5rem !important; }
}
/* 担当者 + store badge スマホ */
@media (max-width: 768px) {
  #section-messages .msg-owner-badge { font-size: 1.3rem !important; padding: 5px 12px !important; }
  #section-messages .msg-store-badge { font-size: 1.2rem !important; padding: 5px 12px !important; }
}
/* 写真 mobile thread img 100px */
@media (max-width: 768px) {
  .msg-thread-img,
  #section-messages .msg-thread-img {
    width: 100px !important;
    height: 100px !important;
    max-width: 100px !important;
    max-height: 100px !important;
  }
  /* 写真右 未/済 btn (click 後と同サイズ = default) */
  .msg-status-big {
    display: inline-block !important;
    font-size: 1.05rem !important;
    padding: 4px 14px !important;
    border-radius: 12px !important;
    font-weight: 800 !important;
    flex-shrink: 0;
    cursor: pointer;
    line-height: 1.3;
    width: auto !important;
    height: auto !important;
  }
  /* mobile = sender 行 + msg-thread-toggle 行の 小 badge 全部 非表示 (写真右の msg-status-big のみ表示) */
  #section-messages .message-status-badge:not(.msg-status-big) { display: none !important; }
  /* mobile = msg-thread-toggle 元 div の中の toggle btn 非表示 (photo row に移動済) */
  #section-messages .msg-thread-toggle .msg-toggle-btn:not(.msg-toggle-photo) { display: none !important; }
  /* toggle = msg-thread 右上 absolute (右端固定) */
  .msg-thread { position: relative; }
  .msg-toggle-photo {
    font-size: 5rem !important;
    padding: 16px 22px;
    color: #2563eb;
    background: #eff6ff;
    border-radius: 12px;
    line-height: 1;
    position: absolute !important;
    top: 8px;
    right: 8px;
    z-index: 5;
  }
}
/* PC = 大型 status btn 非表示 + msg-thread-toggle 内 toggle btn 大きく */
@media (min-width: 769px) {
  .msg-status-big { display: none !important; }
  .msg-toggle-photo { display: none !important; }
  #section-messages .msg-thread-toggle .msg-toggle-btn { font-size: 2.4rem !important; padding: 4px 10px; }
}

.msg-unhandled { border-left: 4px solid #e74c3c; background: #fff5f5; }
.msg-handled { border-left: 4px solid #27ae60; opacity: 0.7; }
.message-status-badge {
  font-size: 1.05rem;
  padding: 4px 14px;
  border-radius: 12px;
  font-weight: 800;
  color: #fff;
  margin-left: 4px;
  flex-shrink: 0;
  white-space: nowrap;
}
.msg-badge-unhandled { background: #b91c1c; color: #fff; }
.msg-badge-handled { background: #15803d; color: #fff; }
/* bubble 内 日時 / 原文 toggle / 未対応 ・対応済 toggle: 大きく濃く */
.msg-bubble-date {
  font-size: 1.05rem !important;
  font-weight: 700 !important;
  color: #333 !important;
}
.btn-bubble-original {
  font-size: 1.05rem !important;
  font-weight: 800 !important;
  color: #1d4ed8 !important;
  margin-left: 8px !important;
}
.btn-bubble-status {
  font-size: 1.05rem !important;
  font-weight: 800 !important;
  margin-left: 8px !important;
}
.btn-bubble-status span { font-size: 1.05rem !important; font-weight: 800 !important; }
/* 返信モーダル 内 「原文」 toggle: 大きく濃く (inline style override) */
#reply-modal #btn-reply-toggle-lang {
  font-size: 1.15rem !important;
  font-weight: 800 !important;
  color: #1d4ed8 !important;
  margin-left: 10px !important;
}

/* ---- Research Section ---- */
.research-card {
  display: block !important;
}

.research-card .kpi-card-sm {
  text-align: center;
}

.research-bottom-grid {
  align-items: flex-start;
}

#trend-keywords-list .trend-kw-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f0f4f8;
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 0.82rem;
  margin: 0 4px 6px 0;
  cursor: pointer;
  transition: background 0.2s;
}

#trend-keywords-list .trend-kw-item:hover {
  background: #dce6f0;
}

#trend-keywords-list .trend-kw-item.active {
  background: #4a90d9;
  color: #fff;
}

#trend-keywords-list .trend-kw-delete {
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0 2px;
  line-height: 1;
}

#trend-keywords-list .trend-kw-item.active .trend-kw-delete {
  color: rgba(255,255,255,0.7);
}

#rec-advice .advice-item {
  padding: 6px 10px;
  margin-bottom: 6px;
  border-radius: 6px;
  font-size: 0.82rem;
  background: #e8f5e9;
  border-left: 3px solid #27ae60;
}

#rs-items-list .rs-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid #f0f0f0;
}

#rs-items-list .rs-item img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  border-radius: 4px;
  flex-shrink: 0;
}

/* ---- Responsive ---- */
@media (max-width: 1024px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

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

@media (max-width: 768px) {
  /* サイドバーを下部タブバーに変更 */
  .sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    width: 100%;
    min-width: 100%;
    height: 60px;
    flex-direction: row;
    z-index: 100;
  }

  .sidebar-header,
  .sidebar-subtitle,
  .sidebar-version,
  .sidebar-footer,
  .sidebar-toggle { display: none; }

  /* mobile: icon + 小ラベル (どのタブか分かる) */
  .menu-label {
    display: block !important;
    font-size: 0.62rem !important;
    line-height: 1 !important;
    margin-top: 2px;
    color: inherit;
    white-space: nowrap;
  }

  .sidebar-menu {
    display: flex;
    flex-direction: row;
    width: 100%;
    justify-content: flex-start;
    padding: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .sidebar-menu::-webkit-scrollbar { display: none; }

  .menu-item {
    padding: 4px 2px;
    justify-content: center;
    flex: 0 0 auto;
    min-width: 56px;
    border-left: none;
    flex-direction: column;
    align-items: center;
    gap: 0;
  }

  .menu-item.active { border-left: none; background: rgba(255,255,255,0.15); }
  .menu-item.hide-mobile-tab { display: none !important; }
  .menu-icon { margin: 0; font-size: 1.2rem; }

  .main-content {
    margin-left: 0;
    padding: 12px 8px 70px 8px;
  }

  .loading-overlay { left: 0; }

  /* KPIカード */
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi-value { font-size: 1.1rem; }

  /* 利益計算機 */
  .calc-grid { grid-template-columns: 1fr; }
  .calc-input-grid { grid-template-columns: 1fr 1fr; }
  .calc-results { margin-top: 12px; }
  .calc-verdict-row { grid-template-columns: 1fr 1fr; }

  /* ツールバー */
  .toolbar { flex-direction: column; align-items: flex-start; gap: 6px; }
  .toolbar-left, .toolbar-right { width: 100%; flex-wrap: wrap; gap: 4px; }
  .input-search { width: 100%; }
  .input-select { font-size: 0.8rem; }

  /* テーブル */
  .table-wrapper { font-size: 0.7rem; }
  .data-table-compact { font-size: 0.7rem; }
  .data-table-compact thead th { padding: 3px 4px; font-size: 0.65rem; }
  .data-table-compact tbody td { padding: 2px 4px; }
  .data-table-compact .thumbnail,
  .data-table-compact .no-image { width: 32px; height: 32px; }

  .cell-title-truncate { max-width: 120px; }
  .ship-input, .cost-input, .fees-input, .duty-input { width: 50px; font-size: 0.7rem; }
  .status-select { width: auto; min-width: 55px; font-size: 0.7rem; }
  .toggle-sm { width: 28px; height: 16px; }
  .toggle-sm-slider:before { height: 12px; width: 12px; }
  .toggle-sm input:checked + .toggle-sm-slider:before { transform: translateX(12px); }
  .btn-sm { font-size: 0.65rem; padding: 2px 6px; }

  /* モーダル */
  .modal-overlay { align-items: flex-start; }
  .modal-wide { max-width: 100%; }
  .modal {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    margin: 0;
  }
  /* モーダル本体: 横幅 100% フル使用 (padding 縮小、 modal-wide も override) */
  .modal-overlay { padding: 0 !important; }
  .modal, .modal.modal-wide, #modal-overlay .modal {
    width: 100vw !important;
    max-width: 100vw !important;
    min-width: 100vw !important;
    box-sizing: border-box;
    margin: 0 !important;
    border-radius: 0 !important;
  }
  .modal-body { padding: 10px 8px 60px 8px; box-sizing: border-box; width: 100%; }
  .modal-header { padding: 10px 10px; flex-shrink: 0; flex-wrap: wrap; gap: 4px; position: sticky; top: 0; background: #fff; z-index: 10; box-shadow: 0 2px 6px rgba(0,0,0,0.08); box-sizing: border-box; width: 100%; }
  .modal-header h3 { font-size: 1.25rem !important; line-height: 1.3; word-break: break-word; }
  #modal-item-header { width: 100%; order: -1; }
  .modal-footer { padding: 10px 8px env(safe-area-inset-bottom,10px); flex-shrink: 0; position: sticky; bottom: 0; background: #fff; z-index: 10; box-shadow: 0 -2px 6px rgba(0,0,0,0.08); display: flex; flex-wrap: wrap; gap: 4px; box-sizing: border-box; width: 100%; }
  .modal-footer .btn { flex: 1 1 calc(33.33% - 4px); min-width: 0; font-size: 1rem !important; padding: 14px 2px !important; font-weight: 700; text-align: center !important; display: flex; align-items: center; justify-content: center; }
  /* 削除 btn は margin-left:auto を override (3列均等配置) */
  #btn-list-end-delete { margin-left: 0 !important; }
  .listing-form-grid { grid-template-columns: 1fr; gap: 8px; width: 100%; }
  .form-row-2, .form-row-3 { grid-template-columns: 1fr; gap: 8px; }
  /* form-row-4: 仕入元 + 仕入URL を 1行 2列 に. 他 (競合URL/キーワード) は full width */
  .form-row-4 { grid-template-columns: 1fr 1fr !important; gap: 8px; }
  .form-row-4 > .form-group { grid-column: 1 / -1; }
  .form-row-4 > .form-group:has(#list-source-type),
  .form-row-4 > .form-group:has(#list-source-url) { grid-column: span 1; }
  .listing-profit-row { grid-template-columns: 1fr 1fr; gap: 6px; }
  .listing-profit-row > div { font-size: 1rem; padding: 8px; }
  .listing-profit-row .lp-label { font-size: 1rem !important; color: #444; font-weight: 600; }
  .listing-profit-row .lp-value { font-size: 2rem !important; font-weight: 800; display: block; line-height: 1.1; color: #111; }

  /* モバイル モーダル: 入力 横幅 100% + box-sizing */
  #modal-overlay .modal,
  #modal-overlay .modal-body,
  #modal-overlay .modal .listing-form-grid,
  #modal-overlay .modal .form-row,
  #modal-overlay .modal .form-row-2,
  #modal-overlay .modal .form-row-3,
  #modal-overlay .modal .form-row-4 { box-sizing: border-box; max-width: 100%; }
  #modal-overlay .modal * { box-sizing: border-box; }

  #modal-overlay .modal,
  #modal-overlay .modal-body { font-size: 1rem !important; }
  #modal-overlay .modal .form-label,
  #modal-overlay .modal label { font-size: 1.05rem !important; font-weight: 700; margin-bottom: 4px; display: block; color: #222; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  /* バッジ inline で 改行しない */
  #modal-overlay .modal .form-label > span { white-space: nowrap; }
  #modal-overlay .modal .form-input,
  #modal-overlay .modal input[type="text"],
  #modal-overlay .modal input[type="number"],
  #modal-overlay .modal select,
  #modal-overlay .modal textarea {
    font-size: 1.15rem !important;
    padding: 12px 12px !important;
    min-height: 48px;
    border-radius: 6px;
    box-sizing: border-box;
    width: 100% !important;
    max-width: 100%;
    min-width: 0;
    color: #111;
  }
  #modal-overlay .modal textarea { min-height: 80px; font-size: 1.05rem !important; }
  #modal-overlay .modal .btn { min-height: 48px; font-size: 1.05rem !important; }
  #modal-overlay .modal h4, #modal-overlay .modal .form-section-title { font-size: 1.15rem !important; font-weight: 800; }
  #modal-overlay .modal .char-count { font-size: 0.9rem !important; }

  /* Item Specifics chip grid: 1col + 余白 */
  #list-aspects-container { grid-template-columns: 1fr !important; gap: 6px !important; padding: 0 !important; }
  #list-aspects-container .aspect-chip { padding: 8px !important; box-sizing: border-box; max-width: 100%; }

  /* 画像 dropzone */
  .image-dropzone, #list-image-dropzone {
    min-height: 120px;
    padding: 14px;
    font-size: 1rem;
    box-sizing: border-box;
    width: 100%;
  }
  .image-preview-item { width: 180px !important; height: 180px !important; }
  .image-preview-item img { width: 100% !important; height: 100% !important; object-fit: cover; }

  /* policy 4列 → 1列 (スマホ 横狭 = 1列が見やすい) */
  .form-row-policies { grid-template-columns: 1fr !important; }

  /* バッジ系 */
  .badge-suggest, #lf-price-suggest, #lf-duty-est { font-size: 0.8rem; padding: 4px 6px; display: inline-block; word-break: break-word; }

  /* lf-* 利益計算 input 行 (5列) → 2列 */
  .listing-calc-row { grid-template-columns: 1fr 1fr !important; gap: 6px !important; }

  /* Cat ID + Category + 数量 = 1行3列、 FVF + プロモ = 自動 2行目 */
  .listing-cat-row { grid-template-columns: 1fr 1fr 1fr !important; gap: 6px !important; }

  /* ストア + 原産国 = 1行2列、 Item ID = 別1行 全幅 */
  .listing-store-row { grid-template-columns: 1fr 1fr !important; gap: 6px !important; }
  .listing-store-row .store-cell { grid-column: 1; grid-row: 1; }
  .listing-store-row .origin-cell { grid-column: 2; grid-row: 1; }
  .listing-store-row .item-id-cell { grid-column: 1 / -1; grid-row: 2; }

  /* 販売価格 全幅、 仕入価格 全幅、 発送方法 全幅、 重量 + 送料 = 1行 2列 */
  .listing-price-row { grid-template-columns: 1fr 1fr !important; gap: 6px !important; }
  .listing-price-row .price-cell { grid-column: 1 / -1; grid-row: 1; }
  .listing-price-row .purchase-cell { grid-column: 1 / -1; grid-row: 2; }
  .listing-price-row .ship-method-cell { grid-column: 1 / -1; grid-row: 3; }
  .listing-price-row .weight-cell { grid-column: 1; grid-row: 4; min-width: 0; }
  .listing-price-row .ship-cost-cell { grid-column: 2; grid-row: 4; min-width: 0; }
  .listing-price-row .weight-cell input,
  .listing-price-row .ship-cost-cell input { width: 100% !important; min-width: 0 !important; max-width: 100% !important; box-sizing: border-box; }

  /* セクションタイトル */
  .section-title { font-size: 1.2rem; }

  /* モバイル検索 */
  .mobile-search-input {
    width: 100%;
    padding: 12px 14px;
    font-size: 1rem;
    border: 2px solid #ddd;
    border-radius: 10px;
    margin-bottom: 10px;
    box-sizing: border-box;
  }
  .mobile-search-input:focus {
    border-color: #4a90d9;
    outline: none;
  }

  /* 画像拡大オーバーレイ */
  .img-zoom-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.85);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .img-zoom-overlay img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 8px;
  }
  .mobile-sale-img { cursor: pointer; }

  /* スマホではホーム・出品管理・設定を非表示、販売管理のみ */
  #section-dashboard .card,
  #section-dashboard .kpi-grid,
  #section-dashboard .calc-card { display: none !important; }

  /* ダッシュボード分析セクションはスマホでも表示 */
  #section-dashboard .card.mobile-visible { display: block !important; }
  #section-dashboard .kpi-grid.mobile-visible { display: grid !important; grid-template-columns: 1fr !important; gap: 8px !important; }
  #section-dashboard .mobile-visible .table-wrapper { display: block !important; }

  /* OC突合セクションはスマホでも表示 */
  #section-oc-reconcile .card.mobile-visible { display: block !important; }
  #section-oc-reconcile .kpi-grid.mobile-visible { display: grid !important; grid-template-columns: 1fr !important; gap: 8px !important; }
  #section-oc-reconcile .mobile-visible .table-wrapper { display: block !important; }

  /* リサーチセクションはスマホでも表示 */
  #section-research .card.mobile-visible { display: block !important; }

  /* 出品管理 スマホ表示: toolbar + mobile-area カードのみ。 デスクトップ table カード(#listings-table-card)/MAG ghost カードは出さない = 上の重複リストを消す (二重表示=ダブり防止、 2026-06-12)。 .card 強制表示はしない (general .card{display:none} で全 card 隠す) */
  #section-listings .toolbar { display: flex !important; flex-wrap: wrap !important; gap: 6px; }
  #section-listings #mobile-listings-search { display: none !important; } /* toolbar に検索あり → 二重検索欄 防止 (販売管理と同) */
  #section-listings #mag-ghost-view { display: none !important; } /* MAG ghost は スマホでは常に非表示 (JS で ghost filter 選択時も) */

  /* 販売管理のスマホ専用リスト */
  .mobile-sales-list { display: block; }
  .mobile-area { display: block; }
  .table-wrapper { display: none; }
  .card { display: none; }
  .toolbar { display: none; }
  .kpi-grid.kpi-grid-4 { display: grid; }
  .mobile-area + .card { display: none; }

  /* 販売管理 toolbar (フィルタ群) は スマホでも表示 (2026-05-02) */
  #section-sales .toolbar { display: flex !important; flex-wrap: wrap; gap: 6px; padding: 8px; background: #fff; border-radius: 8px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
  #section-sales .toolbar-left { display: flex !important; flex-wrap: wrap; gap: 6px; width: 100%; }
  #section-sales .toolbar-left .input-search,
  #section-sales .toolbar-left .input-select { font-size: 0.9rem !important; padding: 6px 8px !important; min-height: 36px !important; flex: 1 1 auto !important; min-width: 110px !important; display: inline-block !important; }
  #section-sales .toolbar-left .input-search { flex-basis: 100% !important; }
  /* 販売管理 mobile-area の重複検索欄 隠す (toolbar 内に search あるため) */
  #section-sales #mobile-sales-search { display: none !important; }

  .mobile-sale-item {
    background: #fff;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
  }
  #mobile-sales-list, #mobile-listings-list { width: 100%; max-width: 100%; box-sizing: border-box; overflow-x: hidden; }
  .mobile-sale-links { flex-wrap: wrap !important; }

  .mobile-sale-img {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
  }

  .mobile-sale-info {
    flex: 1;
    min-width: 0;
  }

  .mobile-sale-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #1a1a2e;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mobile-sale-meta {
    font-size: 0.75rem;
    color: #888;
    margin-top: 3px;
  }

  .mobile-sale-links {
    display: flex;
    gap: 6px;
    margin-top: 6px;
  }

  .mobile-sale-link {
    font-size: 0.95rem;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 4px;
    text-decoration: none;
    color: #fff;
    background: #4a90d9;
    white-space: nowrap;
  }

  .mobile-sale-link.source {
    background: #27ae60;
    font-size: 0.8rem;
    padding: 5px 8px;
  }
  .mobile-sale-link.mobile-manage-link {
    background: #e67e22;
    color: #fff !important;
    border: none;
  }
  .hide-on-mobile {
    display: none !important;
  }

  /* ツールバーをシンプルに */
  .toolbar-right { display: none; }
  .toolbar-left { width: 100%; }
  .toolbar-left .input-search {
    width: 100%;
    font-size: 1rem;
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 6px;
  }
  .toolbar-left .input-select { display: none; }
  .kpi-grid.kpi-grid-4 { grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px; }
  .kpi-card-sm { padding: 8px; }
  .kpi-card-sm .kpi-value { font-size: 1rem; }
  .pagination { justify-content: center; }

  /* メッセージのスマホ用ボタン */
  .message-footer { flex-wrap: wrap; }
  .message-footer .btn {
    font-size: 0.9rem;
    padding: 10px 16px;
    flex: 1;
    text-align: center;
  }
  .message-status-badge { font-size: 0.8rem; padding: 3px 10px; }

  /* メッセージ */
  #section-messages .toolbar { display: flex; }
  /* スマホ = PC離脱時 監視用 (dashboard + sales + messages のみ表示)
     PC作業 (出品/有在庫/過去データ/作業管理) はスマホ非表示 */
  .menu-item[data-section="settings"],
  .menu-item[data-section="inventory"],
  .menu-item[data-section="research-notes"],
  .menu-item[data-section="work"] { display: none; }

  /* リサーチセクションモバイル対応 */
  #section-research .research-card { display: block !important; }
  #section-research .research-bottom-grid { grid-template-columns: 1fr !important; }
  #section-research .kpi-grid { grid-template-columns: 1fr 1fr !important; }
  #section-research .table-wrapper { display: block !important; }
  #section-messages .toolbar .input-select { display: inline-block !important; font-size: 0.9rem; padding: 8px; flex: 1; }
  #section-messages .message-card { display: block; }

  /* スレッドを縦レイアウトに → 写真をヘッダー横に */
  .msg-thread {
    flex-direction: column !important;
  }
  .msg-thread-img {
    width: 50px !important;
    height: 50px !important;
    max-width: 50px !important;
    max-height: 50px !important;
    margin: 0 !important;
    position: static;
    border-radius: 6px;
  }
  .msg-thread-header {
    flex-wrap: nowrap;
    gap: 6px;
    padding: 8px 10px !important;
  }
  .msg-thread-sender {
    flex-wrap: wrap !important;
    overflow: visible;
  }
  .msg-thread-sender a {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex-shrink: 1;
  }
  .msg-thread-sender .msg-bookmark-btn {
    flex-shrink: 0;
  }
  /* country badge は ID 右 inline 維持 (msg-sender-id-wrap で固定) */
  .msg-thread-sender .country-badge {
    display: inline-block !important;
    margin-left: 6px !important;
    margin-top: 0 !important;
    flex-basis: auto;
  }
  /* メッセージ section = 幅いっぱい (padding 最小) */
  #section-messages.section {
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
  }
  .main-content #section-messages {
    padding: 0 !important;
  }
  body.msg-fullwidth .main-content {
    padding: 0 0 70px 0 !important;
    margin: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
  }
  body.msg-fullwidth #section-messages > .toolbar,
  body.msg-fullwidth #section-messages > h2.section-title,
  body.msg-fullwidth #section-messages > #msg-bulk-bar {
    padding-left: 8px;
    padding-right: 8px;
  }
  body.msg-fullwidth #messages-list {
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  .msg-thread {
    border-radius: 0 !important;
    margin-bottom: 6px !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  }
  .msg-thread-content {
    width: 100% !important;
    flex: 1 1 100% !important;
  }
  .msg-thread-info {
    width: 100% !important;
    flex: 1 1 100% !important;
  }
  .msg-thread-header {
    padding: 6px 8px !important;
  }
  .msg-thread-messages {
    padding: 6px 8px !important;
  }
  .msg-thread-footer {
    padding: 6px 8px !important;
  }
  /* main-content スマホ padding 横方向 削減 (メッセージ専用) */
  body.msg-fullwidth .main-content {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
  /* メッセージ action btn を 写真下 全幅 grid (4列 均等) */
  .msg-thread-actions {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 6px !important;
    width: 100% !important;
    margin-top: 8px !important;
    flex-wrap: nowrap !important;
  }
  .msg-thread-actions .msg-action-btn {
    text-align: center !important;
    padding: 10px 4px !important;
    font-size: 0.95rem !important;
    font-weight: 700 !important;
    white-space: nowrap;
    display: flex !important;
    align-items: center;
    justify-content: center;
    min-width: 0;
  }
  /* info を image 下に流す (image 行 + info+actions 行) */
  .msg-thread-header {
    flex-wrap: wrap !important;
  }
  .msg-thread-info {
    width: 100% !important;
    flex-basis: 100% !important;
  }
  .msg-toggle-btn:not(.msg-toggle-photo) {
    font-size: 1rem !important;
    padding: 0 4px !important;
  }
  /* photo toggle 強制再宣言 (specificity 上書き勝ち) */
  .msg-toggle-btn.msg-toggle-photo {
    font-size: 3rem !important;
    padding: 10px 16px !important;
    color: #2563eb !important;
    background: #eff6ff !important;
    border-radius: 10px !important;
    line-height: 1 !important;
    position: absolute !important;
    top: 8px !important;
    right: 8px !important;
    z-index: 5 !important;
  }
  .msg-thread-content {
    width: 100%;
  }
  .msg-thread-messages {
    padding: 6px 10px;
  }
  .msg-bubble {
    margin-bottom: 6px;
    padding-bottom: 6px;
  }
  .bubble-mine {
    margin-left: 16px;
  }
  .message-body-ja, .message-body-en {
    font-size: 0.9rem;
    padding: 8px;
    line-height: 1.6;
  }
  .msg-thread-footer {
    padding: 8px 10px;
  }
  .msg-thread-footer .btn {
    font-size: 0.9rem;
    padding: 10px 20px;
  }
  .btn-bubble-original, .btn-bubble-status {
    font-size: 0.9rem !important;
    padding: 4px 10px;
    background: #eee;
    border-radius: 4px;
    margin-left: 6px;
  }
  .msg-bubble-date {
    font-size: 0.85rem !important;
    color: #666 !important;
  }
  /* メッセージ 写真+文字 を 販売管理カードと同サイズに (スマホ、 2026-06-12)。 #section-messages 前置 + !important + 後置 で 既存の大きめ指定 (写真100px / sender 2rem 等) に勝つ */
  #section-messages .msg-thread-img { width: 50px !important; height: 50px !important; max-width: 50px !important; max-height: 50px !important; }
  #section-messages .msg-thread-sender,
  #section-messages .msg-thread-sender a { font-size: 0.9rem !important; }
  #section-messages .msg-thread-info > div,
  #section-messages .msg-thread-info a { font-size: 0.78rem !important; }
  #section-messages .msg-owner-badge,
  #section-messages .msg-store-badge { font-size: 0.78rem !important; padding: 2px 7px !important; }
  #section-messages .msg-country-inline .country-badge { font-size: 0.78rem !important; padding: 2px 8px !important; }
  #section-messages .msg-bubble { font-size: 0.85rem !important; line-height: 1.5; }
  #section-messages .msg-bubble-date { font-size: 0.72rem !important; }
  #section-messages .msg-thread-count { font-size: 0.78rem !important; }
  #section-messages .msg-action-btn,
  #section-messages .msg-thread-actions .msg-action-btn { font-size: 0.8rem !important; padding: 8px 4px !important; }
  #section-messages .msg-bookmark-btn { font-size: 1rem !important; }
  #section-messages .msg-status-big { font-size: 0.8rem !important; padding: 3px 10px !important; }
  #section-messages .msg-toggle-btn.msg-toggle-photo { font-size: 1.6rem !important; padding: 6px 10px !important; }
  /* 返信モーダル スマホ最適化 */
  #reply-modal .modal {
    width: 100%; max-width: 100%; height: 100%; max-height: 100%;
    border-radius: 0; margin: 0;
  }
  #reply-modal .modal-header {
    padding: 12px 16px;
    position: sticky; top: 0; background: #fff; z-index: 2;
  }
  #reply-modal .modal-header h3 { font-size: 1.1rem; }
  #reply-modal .modal-close { font-size: 1.8rem; padding: 4px 8px; }
  #reply-modal .modal-body { padding: 12px 14px; }
  #reply-modal .reply-buyer-msg { margin-bottom: 12px; }
  #reply-modal .reply-original-box {
    font-size: 0.9rem; padding: 12px; max-height: 100px; overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  #reply-modal .reply-translated-box {
    font-size: 0.9rem; padding: 12px; max-height: 100px; overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  #reply-modal .reply-template-select {
    width: 100%; font-size: 1rem; padding: 10px 12px;
    border-radius: 8px; border: 2px solid #ddd;
    -webkit-appearance: none; appearance: none;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23666' stroke-width='2' fill='none'/%3E%3C/svg%3E") no-repeat right 12px center;
  }
  #reply-modal .reply-textarea {
    width: 100%; font-size: 1rem; padding: 12px;
    border-radius: 8px; border: 2px solid #ddd;
    min-height: 70px; resize: vertical;
    -webkit-appearance: none;
  }
  #reply-modal .reply-textarea:focus,
  #reply-modal .reply-template-select:focus {
    border-color: #4a90d9; outline: none;
  }
  #reply-modal #btn-reply-translate {
    font-size: 0.95rem; padding: 10px 20px; width: 100%;
    border-radius: 8px; margin-top: 8px;
  }
  #reply-modal .reply-calc-section .form-input {
    font-size: 1rem; padding: 10px 12px; border-radius: 8px; border: 2px solid #ddd;
  }
  #reply-modal .reply-calc-section .form-input:focus {
    border-color: #4a90d9; outline: none;
  }
  #reply-modal #reply-calc-result { font-size: 0.95rem; }
  #reply-modal .reply-offer-toggle {
    font-size: 0.95rem; padding: 8px 0;
  }
  #reply-modal .reply-offer-body {
    padding: 12px 0 0 0;
  }
  #reply-modal .reply-offer-body .form-input {
    font-size: 1rem; padding: 10px 12px;
  }
  #reply-modal .reply-offer-body .btn {
    font-size: 0.95rem; padding: 10px 16px;
  }
  #reply-modal .reply-footer {
    position: sticky; bottom: 0; background: #fff; z-index: 2;
    padding: 12px 14px; gap: 10px;
    border-top: 1px solid #eee;
  }
  #reply-modal .reply-footer .btn {
    flex: 1; font-size: 1rem; padding: 14px 0;
    border-radius: 10px; text-align: center;
  }
  #reply-modal .reply-footer #btn-reply-send {
    font-weight: 700;
  }
  #reply-modal .form-label {
    font-size: 0.85rem; font-weight: 600; margin-bottom: 6px;
  }
  #monitor-quick-bar { display: none !important; }
}
/* オファーカード: PC=バイヤー詳細を写真右(中央列)に、モバイル=写真下に全幅 */
.offer-buyer-pc { display: block; }
.offer-buyer-mobile { display: none; }
@media (max-width: 640px) {
  .offer-buyer-pc { display: none !important; }
  .offer-buyer-mobile { display: block !important; }
}
