* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", "Hiragino Kaku Gothic ProN", "Meiryo", sans-serif;
  background: #f4f6f8;
  color: #2b2b2b;
}

/* ヘッダー */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  background: #1f3a5f;
  color: #fff;
  padding: 0 20px;
  height: 52px;
}

.brand { font-weight: bold; font-size: 15px; }

.mainnav { display: flex; gap: 4px; flex: 1; }

.mainnav a, .nav-disabled {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 14px;
  text-decoration: none;
}

.mainnav a { color: #fff; }
.mainnav a.active { background: rgba(255, 255, 255, 0.18); }
.mainnav a:hover { background: rgba(255, 255, 255, 0.12); }

.nav-disabled { color: rgba(255, 255, 255, 0.45); cursor: not-allowed; }

.user-area { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.user-area .logout { color: #cfe0f5; }

.container { max-width: 1000px; margin: 0 auto; padding: 24px 20px; }

/* 2ペイン画面は広く使う */
.container:has(.split) { max-width: 1500px; }

/* ログイン・初回設定カード */
.auth-card {
  max-width: 380px;
  margin: 80px auto 0;
  background: #fff;
  border: 1px solid #dde3ea;
  border-radius: 10px;
  padding: 32px 28px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.auth-card h1 { margin: 0 0 12px; font-size: 20px; text-align: center; }

.auth-note { font-size: 13px; color: #5a6573; text-align: center; margin-bottom: 20px; }

.auth-card label {
  display: block;
  font-size: 13px;
  color: #44505e;
  margin-bottom: 14px;
}

.auth-card input {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 9px 10px;
  font-size: 14px;
  border: 1px solid #c4ccd6;
  border-radius: 6px;
}

.auth-card input:focus { outline: 2px solid #3f72af; border-color: #3f72af; }

.btn-primary {
  width: 100%;
  padding: 10px;
  margin-top: 6px;
  font-size: 14px;
  font-weight: bold;
  color: #fff;
  background: #2d6cdf;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.btn-primary:hover { background: #2459bd; }

.btn-secondary {
  padding: 8px 16px;
  font-size: 13px;
  background: #fff;
  border: 1px solid #c4ccd6;
  border-radius: 6px;
  cursor: pointer;
}

.btn-secondary:disabled, select:disabled { color: #9aa4b0; cursor: not-allowed; background: #eef1f4; }

/* お知らせ・エラー表示 */
.alert { padding: 10px 12px; border-radius: 6px; font-size: 13px; margin-bottom: 16px; }
.alert-error { background: #fdecea; color: #b3261e; border: 1px solid #f5c6c2; }
.alert-info { background: #e8f1fd; color: #1d4f91; border: 1px solid #c3d9f5; }

/* メッセージ一覧画面 */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.page-header h1 { font-size: 20px; margin: 0; }

.toolbar { display: flex; gap: 10px; }
.toolbar select { padding: 8px 10px; font-size: 13px; border: 1px solid #c4ccd6; border-radius: 6px; }

.empty-state {
  background: #fff;
  border: 1px dashed #c4ccd6;
  border-radius: 10px;
  padding: 60px 20px;
  text-align: center;
  color: #5a6573;
}

.empty-state p { margin: 4px 0; }
.empty-sub { font-size: 13px; color: #8a94a0; }

/* 絞り込みバー */
.filter-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  align-items: center;
}

.filter-bar select, .filter-bar input[type="text"] {
  padding: 8px 10px;
  font-size: 13px;
  border: 1px solid #c4ccd6;
  border-radius: 6px;
  background: #fff;
}

.filter-bar input[type="text"] { width: 320px; }

/* 一覧テーブル */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid #dde3ea;
  border-radius: 10px;
  overflow: hidden;
  font-size: 13px;
}

.data-table th, .data-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid #eef1f4;
  vertical-align: middle;
}

.data-table th { background: #f0f3f7; color: #44505e; font-size: 12px; }
.data-table tbody tr:hover { background: #f7fafd; }

.cell-title { font-weight: bold; }
.cell-preview { color: #6a7480; max-width: 360px; }
.col-num { text-align: center; width: 70px; }
.col-actions { width: 130px; white-space: nowrap; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  background: #e8f1fd;
  color: #1d4f91;
  border-radius: 10px;
  white-space: nowrap;
}

/* ボタン追加分 */
.btn-link {
  display: inline-block;
  width: auto;
  text-decoration: none;
  text-align: center;
  padding: 8px 16px;
  font-size: 13px;
}

.btn-small { padding: 4px 10px; font-size: 12px; }

.btn-danger {
  padding: 4px 10px;
  font-size: 12px;
  color: #b3261e;
  background: #fff;
  border: 1px solid #e7b9b5;
  border-radius: 6px;
  cursor: pointer;
}

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

.btn-plain { font-size: 13px; color: #3f72af; text-decoration: none; padding: 8px 4px; }

.inline-form { display: inline; margin-left: 4px; }

/* 追加・編集フォーム */
.edit-form {
  max-width: 640px;
  background: #fff;
  border: 1px solid #dde3ea;
  border-radius: 10px;
  padding: 24px;
}

.edit-form label {
  display: block;
  font-size: 13px;
  color: #44505e;
  margin-bottom: 16px;
}

.edit-form input[type="text"], .edit-form select, .edit-form textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 9px 10px;
  font-size: 14px;
  border: 1px solid #c4ccd6;
  border-radius: 6px;
  font-family: inherit;
}

.edit-form textarea { resize: vertical; }

.edit-form input:focus, .edit-form select:focus, .edit-form textarea:focus {
  outline: 2px solid #3f72af;
  border-color: #3f72af;
}

.required {
  font-size: 11px;
  color: #b3261e;
  background: #fdecea;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 4px;
}

.form-actions { display: flex; gap: 16px; align-items: center; margin-top: 8px; }
.btn-fit { width: auto; padding: 10px 28px; }

/* 翻訳画面 */
.translate-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 900px) {
  .translate-grid { grid-template-columns: 1fr; }
}

.translate-card {
  background: #fff;
  border: 1px solid #dde3ea;
  border-radius: 10px;
  padding: 20px;
}

.translate-card h2 { font-size: 15px; margin: 0 0 14px; color: #1f3a5f; }

.translate-card label {
  display: block;
  font-size: 12px;
  color: #5a6573;
  margin: 10px 0 4px;
}

.translate-card textarea {
  width: 100%;
  padding: 9px 10px;
  font-size: 14px;
  border: 1px solid #c4ccd6;
  border-radius: 6px;
  font-family: inherit;
  resize: vertical;
}

.translate-card textarea[readonly] { background: #f7f9fb; }

.translate-card textarea:focus { outline: 2px solid #3f72af; border-color: #3f72af; }

.translate-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 10px 0;
}

.notice { font-size: 12px; color: #5a6573; }
.notice-ok { color: #1a7f37; }
.notice-error { color: #b3261e; }

/* ── メッセージ画面（2ペイン）───────────────────────────── */
.split {
  display: flex;
  gap: 14px;
  height: calc(100vh - 110px);
  min-height: 420px;
}

.pane-left {
  flex: 0 0 35%;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #dde3ea;
  border-radius: 10px;
  overflow: hidden;
}

.pane-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #dde3ea;
  border-radius: 10px;
  overflow: hidden;
}

.pane-left-head {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-bottom: 1px solid #eef1f4;
}

.pane-left-head select { max-width: 200px; padding: 7px 8px; font-size: 13px; border: 1px solid #c4ccd6; border-radius: 6px; }

.filter-tabs-small { padding: 8px 10px; margin-bottom: 0; border-bottom: 1px solid #eef1f4; }
.filter-tabs-small a { padding: 5px 12px; font-size: 12px; }

.thread-list { overflow-y: auto; flex: 1; }

.thread-row {
  display: flex;
  gap: 10px;
  padding: 10px;
  border-bottom: 1px solid #eef1f4;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.thread-row:hover { background: #f7fafd; }
.thread-active { background: #e8f1fd; }
.thread-active:hover { background: #e8f1fd; }

.thumb-link { flex-shrink: 0; display: block; }
.thumb-link:hover .thumb { outline: 2px solid #2d6cdf; }

.thumb {
  width: 76px;
  height: 76px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: #eef1f4;
}

.thumb-ph {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  color: #9aa4b0;
}

.thread-main { min-width: 0; flex: 1; }

.thread-top { display: flex; justify-content: space-between; gap: 8px; }
.thread-buyer { font-weight: bold; font-size: 13px; }
.thread-date { font-size: 11px; color: #8a94a0; white-space: nowrap; }

.thread-item, .thread-preview {
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thread-item { color: #44505e; margin-top: 2px; }
.thread-preview { color: #8a94a0; margin-top: 2px; }

.thread-badges { display: flex; gap: 4px; margin-top: 4px; }
.thread-badges .badge { font-size: 10px; padding: 1px 7px; }

.badge-buyer { background: #e6f4ea; color: #1a7f37; }
.badge-repeater { background: #e8f1fd; color: #1d4f91; }

/* バイヤー情報バー */
.buyer-bar {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid #eef1f4;
  background: #f7f9fb;
  flex-wrap: wrap;
}

.buyer-name { font-weight: bold; font-size: 14px; }

/* 国情報: 確実（国旗画像＋国名）と推定（控えめな文字のみ）を見た目で区別 */
.flag-img {
  width: 18px;
  height: 14px;
  vertical-align: -2px;
  border: 1px solid #dde3ea;
  border-radius: 2px;
}

.buyer-country { font-size: 13px; }
.buyer-country-est { font-size: 11px; color: #8a94a0; }

.buyer-dd { position: relative; font-size: 12px; }
.buyer-dd summary { cursor: pointer; color: #2d6cdf; user-select: none; }

/* 購入履歴・他の会話 共通のポップアップ:「日時＋商品名」を1リスト1行で表示 */
.dd-body {
  position: absolute;
  z-index: 10;
  top: 22px;
  left: 0;
  min-width: 480px;
  max-width: 820px;
  max-height: 320px;
  overflow-y: auto;
  overflow-x: auto;
  background: #fff;
  border: 1px solid #c4ccd6;
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  padding: 10px 14px;
}

.dd-body ul { margin: 0; padding-left: 0; list-style: none; }
.dd-body li { margin: 5px 0; white-space: nowrap; }
.dd-body li a { color: #2d6cdf; text-decoration: none; }
.dd-body li a:hover { text-decoration: underline; }
.dd-date { color: #8a94a0; font-size: 11px; margin-right: 6px; }

/* 日本語／原文 切り替え */
.lang-toggle { margin-left: auto; display: flex; gap: 0; }

.lang-btn {
  padding: 5px 14px;
  font-size: 12px;
  border: 1px solid #c4ccd6;
  background: #fff;
  cursor: pointer;
}

.lang-btn:first-child { border-radius: 6px 0 0 6px; }
.lang-btn:last-child { border-radius: 0 6px 6px 0; border-left: none; }
.lang-btn.lang-active { background: #2d6cdf; border-color: #2d6cdf; color: #fff; font-weight: bold; }

/* チャットスクロール領域 */
.chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
}

/* 表示モード: 日本語（既定）= 訳のみ。原文が英語・日本語以外の吹き出しは原文も併記 */
.chat-scroll[data-mode="ja"] .chat-original { display: none; }
.chat-scroll[data-mode="ja"] .chat-bubble.show-original .chat-original {
  display: block;
  font-size: 12px;
  color: #6a7480;
  border-bottom: 1px dashed #dde3ea;
  padding-bottom: 6px;
  margin-bottom: 6px;
}

/* 表示モード: 原文 = 原文のみ */
.chat-scroll[data-mode="en"] .chat-ja { display: none; }

.chat-original {
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}

.purchase-marker {
  text-align: center;
  font-size: 12px;
  color: #9a6700;
  background: #fff8e6;
  border: 1px solid #f0dca8;
  border-radius: 14px;
  padding: 4px 12px;
  margin: 4px auto;
  width: fit-content;
  max-width: 80%;
}

/* 返信エリア（下部固定） */
.reply-area {
  border-top: 1px solid #eef1f4;
  padding: 10px 14px;
  background: #fbfcfd;
}

.reply-area .reply-tools { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.reply-area .reply-tools select { max-width: 320px; padding: 6px 8px; font-size: 12px; border: 1px solid #c4ccd6; border-radius: 6px; }

.reply-grid { display: flex; gap: 10px; }
.reply-grid > div, .reply-grid > form { flex: 1; display: flex; flex-direction: column; gap: 6px; }

.reply-grid textarea {
  width: 100%;
  padding: 8px;
  font-size: 13px;
  border: 1px solid #c4ccd6;
  border-radius: 6px;
  font-family: inherit;
  resize: vertical;
}

.reply-grid button { align-self: flex-end; }

.pane-empty { border: none; margin: auto; }
.empty-small { border: none; padding: 30px 10px; }

/* メッセージ一覧 */
.filter-tabs { display: flex; gap: 4px; margin-bottom: 14px; }

.filter-tabs a {
  padding: 7px 18px;
  font-size: 13px;
  color: #44505e;
  text-decoration: none;
  border: 1px solid #c4ccd6;
  border-radius: 6px;
  background: #fff;
}

.filter-tabs a.tab-active {
  background: #2d6cdf;
  border-color: #2d6cdf;
  color: #fff;
  font-weight: bold;
}

.row-link { cursor: pointer; }

.badge-alert { background: #fdecea; color: #b3261e; }
.badge-warn { background: #fff8e6; color: #9a6700; }
.badge-muted { background: #eef1f4; color: #6a7480; }

.settings-divider { border: none; border-top: 1px solid #eef1f4; margin: 18px 0; }
.col-status { width: 110px; }
.col-date { width: 140px; white-space: nowrap; font-size: 12px; color: #5a6573; }

/* 会話画面 */
.thread-item { margin: 4px 0 0; font-size: 13px; color: #5a6573; }

.chat { display: flex; flex-direction: column; gap: 14px; }

.chat-row { display: flex; }
.chat-in { justify-content: flex-start; }
.chat-out { justify-content: flex-end; }

.chat-bubble {
  max-width: 70%;
  background: #fff;
  border: 1px solid #dde3ea;
  border-radius: 10px;
  padding: 12px 14px;
}

.chat-out .chat-bubble { background: #e8f1fd; border-color: #c3d9f5; }

.chat-meta { font-size: 11px; color: #8a94a0; margin-bottom: 6px; }
.chat-subject { font-size: 12px; font-weight: bold; color: #44505e; margin-bottom: 6px; }
.chat-body { font-size: 14px; white-space: pre-wrap; word-break: break-word; }

.chat-ja-body { font-size: 14px; white-space: pre-wrap; word-break: break-word; }

.btn-translate { margin-top: 8px; }

/* 返信欄 */
.reply-alert { margin-top: 20px; }

.reply-card {
  margin-top: 24px;
  background: #fff;
  border: 1px solid #dde3ea;
  border-radius: 10px;
  padding: 20px;
}

.reply-card h2 { font-size: 15px; margin: 0 0 6px; color: #1f3a5f; }

.reply-to { font-size: 13px; color: #5a6573; margin: 0 0 14px; }

.reply-tools {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.reply-tools label {
  font-size: 12px;
  color: #5a6573;
  display: block;
}

.reply-tools select, .reply-tools textarea {
  display: block;
  margin-top: 4px;
  padding: 8px 10px;
  font-size: 13px;
  border: 1px solid #c4ccd6;
  border-radius: 6px;
  font-family: inherit;
}

.reply-ja-label { flex: 1; min-width: 280px; }
.reply-ja-label textarea { width: 100%; resize: vertical; }

#reply-form label {
  display: block;
  font-size: 12px;
  color: #5a6573;
  margin-bottom: 12px;
}

#reply-form textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 9px 10px;
  font-size: 14px;
  border: 1px solid #c4ccd6;
  border-radius: 6px;
  font-family: inherit;
  resize: vertical;
}

.btn-send { background: #1a7f37; }
.btn-send:hover { background: #156a2e; }

/* 設定画面 */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 900px) {
  .settings-grid { grid-template-columns: 1fr; }
}

.settings-card {
  background: #fff;
  border: 1px solid #dde3ea;
  border-radius: 10px;
  padding: 20px;
}

.settings-card-wide { grid-column: 1 / -1; }

.settings-card h2 { font-size: 15px; margin: 0 0 12px; color: #1f3a5f; }

.settings-card label {
  display: block;
  font-size: 13px;
  color: #44505e;
  margin-bottom: 12px;
}

.settings-card input[type="text"], .settings-card input[type="password"] {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  font-size: 13px;
  border: 1px solid #c4ccd6;
  border-radius: 6px;
}

.settings-note { font-size: 13px; color: #5a6573; }
.settings-warning { font-size: 12px; color: #9a6700; background: #fff8e6; border: 1px solid #f0dca8; border-radius: 6px; padding: 8px 10px; }

.input-small { width: auto !important; display: inline-block !important; padding: 6px 8px !important; }

.rename-form { display: flex; gap: 6px; align-items: center; }

.add-account-form { display: flex; gap: 8px; margin-top: 14px; align-items: center; }

.col-actions-wide { width: 170px; white-space: nowrap; }

/* eBay認証画面 */
.auth-steps { font-size: 14px; line-height: 1.9; padding-left: 22px; }
.auth-steps li { margin-bottom: 18px; }
.auth-step-action { margin-top: 8px; display: flex; gap: 10px; align-items: center; }
.auth-url-input { flex: 1; padding: 9px 10px; font-size: 13px; border: 1px solid #c4ccd6; border-radius: 6px; }

.reply-placeholder {
  margin-top: 24px;
  padding: 14px;
  border: 1px dashed #c4ccd6;
  border-radius: 8px;
  font-size: 13px;
  color: #5a6573;
  background: #fbfcfd;
  text-align: center;
}
