/* =================================================================
   リラクゼーションサロン 問い合わせ管理アプリ
   Gmail 風UI（v3.1）
   ================================================================= */

:root {
  --bg: #f6f8fc;                  /* Gmail 風の青み off-white */
  --surface: #ffffff;
  --surface-hover: #f5f6fa;
  --border: #e8eaed;
  --border-strong: #dadce0;
  --text: #202124;
  --text-muted: #5f6368;
  --text-faint: #80868b;
  --accent: #1a73e8;              /* Gmail ブルー */
  --accent-bg: #e8f0fe;
  --alert: #d93025;               /* Gmail 風レッド */
  --alert-bg: #fce8e6;
  --star: #f4b400;                /* スター黄色（Gmailと同じ） */
  --radius: 8px;
  --radius-lg: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: -apple-system, "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
input { font: inherit; }

/* ---- 全体レイアウト ---- */
.app {
  display: grid;
  grid-template-rows: 64px 1fr;
  height: 100vh;
}

/* ---- トップバー（Gmail 風）---- */
.topbar {
  background: var(--bg);
  display: grid;
  /* ハンバーガー幅 | 検索バー（伸長） | 右側（ベル + ログアウト） */
  grid-template-columns: 56px 1fr auto;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
}

/* チケット詳細ページ用: 検索バーがない + 要対応ボタンが追加されるため列幅を変える */
.topbar.topbar-ticket {
  grid-template-columns: auto 1fr auto;
}

/* ===== ユーザーメニュー（トップバー右・ドロップダウン）===== */
.user-menu {
  position: relative;
}
.user-menu-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
  max-width: 200px;
}
.user-menu-trigger:hover {
  background: rgba(0, 0, 0, 0.04);
  border-color: var(--border);
}
.user-menu-trigger[aria-expanded="true"] {
  background: rgba(0, 0, 0, 0.06);
  border-color: var(--border-strong);
}
.topbar-user-name {
  font-weight: 500;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-menu-chevron {
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1;
}

/* ドロップダウン本体 */
.user-menu-dropdown[hidden] {
  display: none !important;
}
.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 260px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  z-index: 100;
  padding: 6px 0;
  animation: user-menu-fade-in 0.12s ease-out;
}
@keyframes user-menu-fade-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ユーザー情報部分 */
.user-menu-info {
  padding: 12px 16px;
}
.user-menu-info-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.user-menu-info-email {
  font-size: 12px;
  color: var(--text-muted);
  word-break: break-all;
}
.user-menu-info-role {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 4px;
  padding: 2px 8px;
  background: var(--accent-bg);
  color: var(--accent);
  border-radius: 10px;
  display: inline-block;
}

.user-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* メニュー項目 */
.user-menu-item {
  display: flex;
  align-items: center;
  width: 100%;
  background: transparent;
  border: none;
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background 0.1s;
}
.user-menu-item:hover {
  background: var(--surface-hover);
}
.user-menu-item-logout {
  color: var(--alert);
}
.user-menu-item-logout:hover {
  background: var(--alert-bg);
}
.user-menu-item-badge {
  margin-left: auto;
  font-size: 10px;
  padding: 2px 8px;
  background: var(--border);
  color: var(--text-muted);
  border-radius: 10px;
}

/* SP: 名前を隠してアイコンっぽく */
@media (max-width: 600px) {
  .topbar-user-name { display: none; }
  .user-menu-trigger { padding: 6px 8px; }
  .user-menu-trigger::before {
    content: '👤';
    font-size: 16px;
  }
  .user-menu-dropdown {
    min-width: 240px;
    right: -4px;
  }
}

/* ===== パスワード変更モーダル ===== */
.pw-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.pw-modal {
  position: relative;
  background: var(--surface);
  border-radius: 12px;
  padding: 32px 28px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  animation: pw-modal-pop 0.15s ease-out;
}
@keyframes pw-modal-pop {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}
.pw-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  font-size: 16px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 4px;
}
.pw-modal-close:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text);
}
.pw-modal-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}
.pw-modal-hint {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 16px;
}
.pw-modal-error {
  background: var(--alert-bg);
  color: var(--alert);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  border-left: 3px solid var(--alert);
  margin-bottom: 12px;
}
.pw-modal-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.pw-modal-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pw-modal-field label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}
.pw-modal-field input {
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
}
.pw-modal-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.15);
}
.pw-modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 8px;
}
.pw-modal-cancel,
.pw-modal-submit {
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
.pw-modal-cancel:hover { background: var(--surface-hover); }
.pw-modal-submit {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.pw-modal-submit:hover { background: #1557b0; }
.pw-modal-submit:disabled { opacity: 0.6; cursor: wait; }
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-logo { display: none; }  /* ロゴ文言を非表示 */
.topbar-nav { display: none; }  /* Gmailはトップにナビなし。サイドバーに統一 */

/* 検索バー（広く・上限なし） */
.search-wrap {
  position: relative;
  width: 100%;
}
.search-wrap input {
  width: 100%;
  background: #eaf1fb;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 11px 16px 11px 48px;
  font-size: 14px;
  color: var(--text);
  transition: background 0.15s, box-shadow 0.15s;
}
.search-wrap input:focus {
  outline: none;
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  border-color: var(--border);
}
.search-wrap::before {
  content: "";
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235f6368' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='8'/><path d='m21 21-4.3-4.3'/></svg>");
  background-repeat: no-repeat;
}

.topbar-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* ベル */
.bell-wrap {
  position: relative;
  cursor: pointer;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}
.bell-wrap:hover { background: rgba(60,64,67,0.08); }
.bell-wrap::before {
  content: "";
  width: 20px;
  height: 20px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235f6368' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9'/><path d='M10.3 21a1.94 1.94 0 0 0 3.4 0'/></svg>");
  background-repeat: no-repeat;
  background-position: center;
}
.bell-icon { display: none; }
.bell-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--alert);
  color: white;
  font-size: 9px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  border: 2px solid var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---- メインレイアウト ---- */
.main-layout {
  display: flex;
  min-height: 0;
  overflow: hidden;
}

/* ---- サイドバー（Gmail 風）---- */
.sidebar {
  width: 256px;
  background: var(--bg);
  padding: 8px;
  font-size: 14px;
  overflow-y: auto;
  flex-shrink: 0;
}

/* 新規作成ボタン（Gmail のCompose）*/
.compose-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #c2e7ff;
  color: #001d35;
  border: none;
  border-radius: 16px;
  padding: 14px 24px 14px 16px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  margin: 8px 0 16px;
  cursor: pointer;
  transition: box-shadow 0.15s;
  text-decoration: none;
}
.compose-btn:hover {
  box-shadow: 0 1px 3px rgba(60,64,67,0.3), 0 4px 8px rgba(60,64,67,0.15);
}
.compose-btn::before {
  content: "";
  width: 18px;
  height: 18px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23001d35' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M12 20h9'/><path d='M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z'/></svg>");
  background-repeat: no-repeat;
  background-position: center;
}

.sidebar-section { margin-bottom: 8px; }
.sidebar-title {
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0.6px;
  padding: 12px 16px 4px;
  font-weight: 500;
  text-transform: uppercase;
}
.sidebar-item {
  padding: 0 10px 0 26px;
  height: 32px;
  border-radius: 0 16px 16px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1px;
  margin-right: 8px;
  cursor: pointer;
  color: var(--text);
  font-size: 14px;
}
.sidebar-item:hover { background: rgba(60,64,67,0.08); }
.sidebar-item.active {
  background: #d3e3fd;
  font-weight: 700;
  color: var(--text);
}
.count {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}
.sidebar-item.active .count { color: var(--text); }

/* 🆕 PR #18: サイドバーのサブ項目（メイン/サブ）*/
.sidebar-sub-item {
  padding: 0 10px 0 42px; /* sidebar-item より深くインデント */
  height: 28px;
  border-radius: 0 16px 16px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1px;
  margin-right: 8px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
}
.sidebar-sub-item:hover { background: rgba(60, 64, 67, 0.06); }
.sidebar-sub-item.active {
  background: #d3e3fd;
  font-weight: 700;
  color: var(--text);
}
.sidebar-sub-item.active .count { color: var(--text); }

/* 🆕 PR #18: SP 用 メイン/サブ タブバー (PC では非表示) */
.bucket-tabs {
  display: none; /* PC は非表示。SP の media query で表示 */
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.bucket-tab {
  flex: 1;
  background: transparent;
  border: none;
  padding: 12px 8px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.bucket-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: var(--surface);
  font-weight: 600;
}
.bucket-tab-count {
  background: var(--text-faint);
  color: #fff;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}
.bucket-tab.active .bucket-tab-count { background: var(--accent); }

/* ステータスドット */
.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 12px;
  vertical-align: middle;
  background: var(--text-faint);
}
.dot-unhandled { background: var(--alert); }
.dot-progress  { background: #f9ab00; }
.dot-done      { background: #34a853; }

/* ---- メインコンテンツ ---- */
.content {
  flex: 1;
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  margin-right: 8px;
  min-width: 0;
}
.content-header {
  display: none;  /* タイトルは toolbar に統合 */
}
.content-title { display: none; }

/* ツールバー（リスト上部）*/
.list-toolbar {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
  min-height: 48px;
  gap: 12px;
}
.list-toolbar-title {
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
  white-space: nowrap;
  flex-shrink: 0;
}
.list-toolbar-info {
  font-size: 12px;
  color: var(--text-faint);
  margin-left: auto;
  white-space: nowrap;
}
.refresh-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 14px;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  transition: background 0.1s, color 0.1s;
}
.refresh-btn:hover { background: var(--hover); color: var(--text); }
.refresh-btn:disabled { opacity: 0.4; cursor: default; }
.refresh-indicator {
  font-size: 11px;
  color: var(--text-faint);
}
.refresh-indicator.updating {
  color: var(--primary, #4f46e5);
  animation: refresh-fade 0.8s ease-in-out infinite alternate;
}
@keyframes refresh-fade {
  from { opacity: 0.5; }
  to   { opacity: 1; }
}

/* ---- カテゴリ絞り込み（プルダウン）---- */
.category-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.category-filter label {
  white-space: nowrap;
  font-weight: 500;
}
.category-filter select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 28px 5px 10px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235f6368' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 12px;
}
.category-filter select:focus {
  outline: none;
  border-color: var(--accent, #4a6cf7);
  box-shadow: 0 0 0 2px rgba(74, 108, 247, 0.15);
}

/* ---- 受信トレイ（LINE 風・3 カラム）---- */
.inbox-list {
  background: var(--surface);
}

/*
 * 行レイアウト:
 *   左カラム: 日付
 *   中央カラム: 名前 / 件名 / 本文プレビュー / 要対応バッジ
 *   右カラム: 未読緑丸（未読時のみ表示）
 */
/* ============================================================
 * 受信トレイ：Gmail 風レイアウト
 *   PC（>=768px）: 1 行表示 [要対応] [送信者] [タグ・件名・本文プレビュー] [日時]
 *   SP（<768px）: 3 行表示
 *     L1: 送信者                                                     日時
 *     L2:        件名
 *     L3:        本文プレビュー                                    [タグ]
 *   ※ 未読は太字（Gmail と同様、緑丸なし）
 * ============================================================ */
.inbox-item {
  display: grid;
  grid-template-columns: 28px 36px 160px minmax(0, 1fr) 64px;
  /*                    select toggle sender content                date */
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
  font-size: 14px;
  background: var(--surface);
  min-height: 44px;
}
.inbox-item:hover {
  background: rgba(60, 64, 67, 0.04);
  z-index: 1;
  position: relative;
}
.inbox-item.selected {
  background: #e8f0fe;
}
.inbox-item.selected:hover {
  background: #d8e5fb;
}

/* ===== 一括選択用チェックボックス ===== */
.inbox-select {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 4px;
  margin: -4px;
}
.inbox-select-input {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent);
}

/* ===== 一括アクションバー ===== */
.bulk-action-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: #f1f5fd;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 5;
}
.bulk-count-label {
  font-size: 13px;
  color: var(--text);
  margin-right: 8px;
}
.bulk-count-label strong {
  color: var(--accent);
  font-size: 15px;
}
.bulk-btn {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.bulk-btn:hover {
  background: var(--surface-hover);
}
.bulk-btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.bulk-btn-primary:hover {
  background: #1557b0;
}
.bulk-btn-danger {
  background: var(--alert);
  color: #fff;
  border-color: var(--alert);
}
.bulk-btn-danger:hover {
  background: #b1281f;
}
.bulk-btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
  margin-left: auto;
}
.bulk-btn-ghost:hover {
  background: rgba(0,0,0,0.04);
}

/* ===== 要対応トグルボタン（左端）===== */
.na-toggle {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  font-size: 14px;
  line-height: 1;
  color: var(--text-muted);
  transition: background 0.1s;
}
.na-toggle:hover {
  background: rgba(0, 0, 0, 0.08);
}
.na-toggle.active {
  /* ON 時は黄色丸の絵文字を強調 */
  background: rgba(245, 158, 11, 0.12);
}
.na-toggle:disabled { opacity: 0.5; cursor: wait; }
.na-toggle-icon { font-size: 14px; line-height: 1; }

/* ===== 送信者セル ===== */
.sender-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  white-space: nowrap;
  min-width: 0;
}
.sender-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  font-size: 14px;
  color: var(--text);
}
.sender-cell .status { flex-shrink: 0; font-size: 11px; }
.sender-cell .draft-indicator { flex-shrink: 0; }

/* ===== コンテンツセル（タグ + 件名 + 本文プレビュー）===== */
.content-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  min-width: 0;
  color: var(--text);
}
.subject-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 0;
  max-width: 50%;
}
.body-preview {
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.body-preview::before {
  content: '- ';
  margin-right: 2px;
  color: var(--text-muted);
}

/* ===== 日時セル ===== */
.date-cell {
  text-align: right;
}
.received-at {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ===== 未読表示（Gmail 仕様：太字 + 強調色）===== */
.inbox-item.unread .sender-name,
.inbox-item.unread .subject-text {
  font-weight: 700;
  color: var(--text);
}
.inbox-item.unread .received-at {
  font-weight: 700;
  color: var(--text);
}
/* 既読は薄く（Gmail 風）*/
.inbox-item:not(.unread) .sender-name,
.inbox-item:not(.unread) .subject-text {
  color: var(--text-muted);
}

/* ===== 旧クラス互換（非表示）===== */
.meta-col, .content-col, .sender-row, .subject-row, .preview-row,
.category-row, .badges-row, .unread-dot {
  display: none !important;
}

/* ===== カテゴリタグ（Gmail 風チップ）===== */
.category-tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
  line-height: 1.5;
}
.inbox-item.unread .category-tag {
  background: rgba(16, 185, 129, 0.10);
  color: #047857;
  font-weight: 600;
}

/* バッジ行（要対応バッジなど・該当時のみ）*/
.badges-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

/* 要対応バッジ（白背景 + 緑強調・視認性重視）*/
.needs-action-badge {
  display: inline-flex;
  align-items: center;
  background: #ffffff;
  color: #059669;  /* 緑文字（しっかり濃いめ）*/
  border: 1.5px solid #10b981;  /* ビビッドグリーンの太めボーダー */
  border-radius: 999px;
  padding: 2px 11px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  white-space: nowrap;
}
.needs-action-badge::before {
  content: "●";
  color: #10b981;  /* 緑ドット */
  margin-right: 5px;
  font-size: 8px;
  line-height: 1;
}

/* 下書きありインジケータ（受信トレイ各行）*/
.draft-indicator {
  display: inline-flex;
  align-items: center;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #93c5fd;
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

/* 返信エディタの下書き保存インジケータ */
.draft-save-indicator {
  font-size: 11px;
  color: var(--text-faint);
  margin-right: 8px;
  white-space: nowrap;
}
.draft-save-indicator.saving { color: var(--accent, #1a73e8); }
.draft-save-indicator.saved { color: #059669; }
.draft-save-indicator.error { color: var(--alert, #d93025); }

/* 未読緑丸：件名の左に配置・unread の時のみ表示 */
.unread-dot {
  display: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #10b981;
  flex-shrink: 0;
}
.inbox-item.unread .unread-dot {
  display: block;
}
/* 旧 .preview スタイル削除（新レイアウトでは .preview-row を使用） */

/* タグ・フラグ（インラインバッジ）*/
.label-chip {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 500;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid;
  margin-right: 4px;
  white-space: nowrap;
  height: 18px;
}
.flag {
  background: var(--alert-bg);
  color: var(--alert);
  border-color: var(--alert);
}
.flag.warn {
  background: #feefc3;
  color: #5f3f00;
  border-color: #f9ab00;
}
.flag.info {
  background: #e8eaed;
  color: var(--text-muted);
  border-color: var(--border-strong);
}
.flag.reserve {
  background: var(--text);
  color: white;
  border-color: var(--text);
}


/* 受信トレイのフィルタ・コンパクトな絞り込みプルダウン */
.brand-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 12px;
  font-size: 13px;
  color: var(--text-muted);
}
.brand-filter select {
  padding: 4px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font-size: 13px;
  background: var(--surface);
}

/* 新規送信画面のブランド選択（大きめのトグルボタン） */
.brand-selector {
  display: flex;
  gap: 8px;
  flex: 1;
}
.brand-option {
  flex: 1;
  padding: 10px 16px;
  border: 2px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.brand-option:hover { background: var(--surface-hover); }
.brand-option.selected[data-brand="gokunokimochi"] {
  background: #f5f3ff;
  color: #6d28d9;
  border-color: #8b5cf6;
}
.brand-option.selected[data-brand="gokuspa"] {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #3b82f6;
}

/* ステータスバッジ（Gmail にはないが業務上必要）*/
.status {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 8px;
  font-weight: 600;
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
  margin-right: 8px;
}
/* 新ステータス */
.s-unanswered     { color: var(--alert); border-color: var(--alert); background: var(--alert-bg); }
.s-needs-action   { color: #5f3f00; border-color: #f9ab00; background: #feefc3; }
.s-sent           { color: #137333; border-color: #34a853; background: #e6f4ea; }
.s-reply-received { color: #b45309; border-color: #ea580c; background: #ffedd5; font-weight: 700; }
.s-pending        { color: #1e40af; border-color: #3b82f6; background: #dbeafe; }
/* 🆕 PR #21: 担当依頼チャット用ステータス */
.s-pending-reservation { color: #1e40af; border-color: #3b82f6; background: #dbeafe; }
.s-supervisor-replied  { color: #5b21b6; border-color: #8b5cf6; background: #ddd6fe; font-weight: 700; }
.s-reservation-replied { color: #3730a3; border-color: #6366f1; background: #c7d2fe; font-weight: 700; }
/* 旧（後方互換） */
.s-unhandled { color: var(--alert); border-color: var(--alert); background: var(--alert-bg); }
.s-progress { color: #5f3f00; border-color: #f9ab00; background: #feefc3; }
.s-done { color: #137333; border-color: #34a853; background: #e6f4ea; }

/* チャネル（絵文字バッジ）*/
.channel {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  margin-right: 8px;
  flex-shrink: 0;
}

/* 受信日時 */
.received-at {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  font-weight: inherit;
}
.inbox-item.unread .received-at { color: var(--text); font-weight: 700; }

.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-faint);
}
.empty-state h3 { font-size: 16px; margin-bottom: 8px; color: var(--text-muted); font-weight: 500; }

/* ---- レスポンシブ ---- */
.hamburger {
  display: none;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  padding: 6px 10px;
  color: var(--text-muted);
}

/* ===== タブレット（< 1024px）：サイドバーをハンバーガー化 ===== */
@media (max-width: 1023px) {
  .app { grid-template-rows: 56px 1fr; }
  .topbar { grid-template-columns: 48px 1fr 96px; padding: 0 8px; gap: 8px; }
  .hamburger { display: block; }
  .sidebar {
    position: fixed;
    top: 56px;
    left: 0;
    bottom: 0;
    width: 280px;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.2s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  }
  .sidebar.open { transform: translateX(0); }
  .content { margin-right: 0; border-radius: 0; }

  /* 🆕 PR #22: サイドバー背景オーバーレイ (タップで閉じる用) */
  .sidebar-backdrop {
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.3);
    z-index: 99;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
  }
  .sidebar-backdrop.open {
    opacity: 1;
    pointer-events: auto;
  }
}

/* PC では backdrop は完全に無効 */
@media (min-width: 1024px) {
  .sidebar-backdrop { display: none; }
}

/* ===== スマホ（< 768px）：Gmail iOS 風 3 行レイアウト =====
 *   L1: 送信者 + 日時（右）
 *   L2: 件名
 *   L3: 本文プレビュー + カテゴリタグ（右）
 */
@media (max-width: 767px) {
  /* list-toolbar: 件数表示を非表示にして title + filter + refresh だけに */
  .list-toolbar { padding: 8px 12px; gap: 8px; }
  .list-toolbar-info { display: none; }
  .category-filter label { display: none; }  /* 「カテゴリ:」ラベル非表示でセレクトだけ残す */

  /* 🆕 PR #18: SP では サイドバーサブ項目を隠して タブバー を表示 */
  .sidebar-sub-item { display: none; }
  .bucket-tabs { display: flex; }

  .inbox-item {
    grid-template-columns: 24px 32px minmax(0, 1fr) auto;
    grid-template-areas:
      "select toggle sender date"
      "select toggle content content";
    gap: 4px 8px;
    padding: 12px 10px;
    align-items: start;
  }
  .inbox-select { grid-area: select; align-self: center; }

  /* 🆕 PR #22: SP では通常時チェックボックスを非表示 → 長押しで selection-mode に入ると表示
   *   PC (>= 768px) はメディアクエリ外なので影響なし（今まで通り常時表示）。
   *   selection-mode 時は select 列を 24px に戻す（デフォルトのまま）。
   *   通常モードでは select 列を 0 に潰してレイアウトを詰める。
   */
  body:not(.selection-mode) .inbox-item {
    grid-template-columns: 0 32px minmax(0, 1fr) auto;
  }
  body:not(.selection-mode) .inbox-item .inbox-select {
    display: none;
  }
  .na-toggle { grid-area: toggle; align-self: center; }
  .sender-cell { grid-area: sender; }
  .date-cell { grid-area: date; align-self: start; }
  .content-cell {
    grid-area: content;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "subject subject"
      "preview tag";
    gap: 2px 8px;
    align-items: center;
  }
  /* SP: タグは content-cell の右下に grid-area で配置（PC のインラインは無効化）*/
  .content-cell > .category-tag {
    grid-area: tag;
    justify-self: end;
    font-size: 10px;
    padding: 1px 6px;
    max-width: 35vw;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .content-cell > .subject-text {
    grid-area: subject;
    max-width: none;
    font-size: 14px;
  }
  .content-cell > .body-preview {
    grid-area: preview;
    font-size: 12px;
  }
  .received-at { font-size: 11px; }
  .sender-name { font-size: 14px; }
  .preview-row {
    font-size: 12px;
  }
  .needs-action-badge {
    font-size: 10px;
    padding: 2px 10px;
  }
  .needs-action-badge::before {
    font-size: 7px;
    margin-right: 3px;
  }

  /* チケット詳細ページ（モバイル）*/
  .ticket-page,
  .compose-page,
  .notif-page {
    padding: 12px !important;
  }
}

/* ===== ページ共通：戻るボタン ===== */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 6px;
}
.back-link:hover { background: rgba(0,0,0,0.04); color: var(--text); }
.back-link::before {
  content: "←";
  font-size: 16px;
}

/* ===== ページタイトル ===== */
.page-title {
  font-size: 20px;
  font-weight: 600;
  padding: 16px 24px 8px;
}
.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  padding: 0 24px 16px;
}

/* ===== フォーム共通 ===== */
.form-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
}
.form-label {
  width: 100px;
  font-size: 13px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.form-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font-size: 14px;
}
.form-input:focus { outline: 2px solid var(--accent); outline-offset: -2px; }
.form-textarea {
  width: 100%;
  min-height: 180px;
  padding: 12px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}

@media (max-width: 600px) {
  .form-row { flex-direction: column; align-items: flex-start; padding: 12px 16px; }
  .form-label { width: 100%; }
  .form-input { width: 100%; }
}

/* ===== モーダル ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.4);
  z-index: 1000;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 16px;
  overflow-y: auto;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: 12px;
  width: 100%;
  max-width: 720px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  overflow: hidden;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
}
.modal-close:hover { background: var(--bg); }

@media (max-width: 600px) {
  .modal-backdrop { padding: 0; }
  .modal { max-width: 100%; border-radius: 0; min-height: 100vh; }
}
