/* ═══════════════════════════════════════════════════════
   まるごと復活メール 管理画面 v2
   白基調・インディゴ1色アクセント・状態6色・外部通信なし
   ═══════════════════════════════════════════════════════ */

:root {
  /* ── 背景 3階層 ── */
  --bg-base:    #FAFAFB;
  --bg-surface: #FFFFFF;
  --bg-subtle:  #F4F5F7;

  /* ── 文字 3階層 ── */
  --text-strong: #191C20;
  --text-body:   #41464D;
  --text-muted:  #898F98;

  /* ── アクセント（操作系専用） ── */
  --accent:       #4F46E5;
  --accent-hover: #4338CA;
  --accent-soft:  #EEF2FF;
  --accent-ring:  rgba(79, 70, 229, .18);

  /* ── 状態色（データの意味専用） ── */
  --st-send:        #16803C; --st-send-soft:   #EDFAF1; --st-send-line:   rgba(22,128,60,.25);
  --st-hold:        #B45309; --st-hold-soft:   #FFF8EB; --st-hold-line:   rgba(180,83,9,.28);
  --st-stop:        #DC2626; --st-stop-soft:   #FEF1F1; --st-stop-line:   rgba(220,38,38,.25);
  --st-ng:          #991B1B; --st-ng-soft:     #FDEDED; --st-ng-line:     rgba(153,27,27,.30);
  --st-paused:      #5B6472; --st-paused-soft: #F2F4F6; --st-paused-line: rgba(91,100,114,.25);
  --st-react:       #0E7490; --st-react-soft:  #ECFAFD; --st-react-line:  rgba(14,116,144,.25);

  /* ── 罫線 ── */
  --line:        #E8EAED;
  --line-strong: #D9DCE1;
  --hairline: 1px solid var(--line);

  /* ── 影 3段階 ── */
  --shadow-1: 0 1px 2px rgba(17, 24, 39, .04);
  --shadow-2: 0 2px 8px rgba(17, 24, 39, .07), 0 1px 2px rgba(17,24,39,.04);
  --shadow-3: 0 12px 32px rgba(17, 24, 39, .12), 0 2px 8px rgba(17,24,39,.05);

  /* ── 寸法 ── */
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-full: 999px;
  --header-h: 56px;
  --tab-h: 44px;

  /* ── 動き ── */
  --dur-fast: 120ms;
  --dur-base: 200ms;
  --dur-view: 260ms;
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-std: cubic-bezier(.4, 0, .2, 1);

  /* ── フォント ── */
  --font-sans: -apple-system, BlinkMacSystemFont, "Hiragino Sans",
               "Hiragino Kaku Gothic ProN", "Yu Gothic UI", Meiryo,
               system-ui, sans-serif;
}

/* ═══ ベース ═══ */

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg-base);
  color: var(--text-body);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.65;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

input { font-family: inherit; }

h2, h3, p { margin: 0; }

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

/* ═══ フォーカスリング（二重・:focus-visibleのみ） ═══ */

button:focus-visible,
a:focus-visible,
tr:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg-surface), 0 0 0 4px var(--accent);
  border-radius: var(--radius-xs);
}

/* ═══ ヘッダー（白・すりガラス・sticky） ═══ */

.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--header-h);
  padding: 0 24px;
  background: rgba(255, 255, 255, .88);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line-strong);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-xs);
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  flex: none;
}

.brand-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-strong);
  white-space: nowrap;
}

.header-meta {
  font-size: 11.5px;
  letter-spacing: .01em;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-spacer { flex: 1; }

.demo-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: var(--st-hold-soft);
  border: 1px solid var(--st-hold-line);
  color: var(--st-hold);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  flex: none;
}

.demo-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--st-hold);
  flex: none;
}

/* ═══ タブナビ（白・sticky・アクセント下線） ═══ */

.tab-nav-wrap {
  position: sticky;
  top: var(--header-h);
  z-index: 40;
  background: rgba(255, 255, 255, .88);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.tab-nav-wrap::-webkit-scrollbar { display: none; }

/* 横にまだタブが隠れている側の端だけフェード（JSが fade-left / fade-right を付与） */
.tab-nav-wrap.fade-right {
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
}
.tab-nav-wrap.fade-left {
  -webkit-mask-image: linear-gradient(to right, transparent, #000 28px);
  mask-image: linear-gradient(to right, transparent, #000 28px);
}
.tab-nav-wrap.fade-left.fade-right {
  -webkit-mask-image: linear-gradient(to right, transparent, #000 28px, #000 calc(100% - 28px), transparent);
  mask-image: linear-gradient(to right, transparent, #000 28px, #000 calc(100% - 28px), transparent);
}

.tab-nav {
  display: flex;
  gap: 4px;
  height: var(--tab-h);
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 24px;
  min-width: max-content;
}

.tab-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  transition: color var(--dur-fast) var(--ease-std);
}

.tab-btn:hover { color: var(--text-body); }

.tab-btn.is-active { color: var(--accent); }

.tab-btn.is-active::after {
  content: '';
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 0;
  height: 2px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
}

/* ═══ レイアウト ═══ */

.main-content {
  max-width: 1160px;
  margin: 0 auto;
  padding: 24px 24px 64px;
}

.view { display: none; }

.view.is-active {
  display: block;
  animation: viewIn var(--dur-view) var(--ease-out) both;
}

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

.section-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin: 0 0 16px;
}

.section-head:not(:first-child) { margin-top: 32px; }

.section-head h2 {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text-strong);
}

.section-head .sub {
  font-size: 11.5px;
  letter-spacing: .01em;
  color: var(--text-muted);
}

/* ═══ KPIストリップ（ヘアライン分割） ═══ */

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 24px;
}

/* KPIカードは該当画面へ移動するボタン */
.kpi-card {
  position: relative;
  display: block;
  width: 100%;
  text-align: left;
  background: var(--bg-surface);
  padding: 16px 16px 14px;
  min-width: 0;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-std);
}

.kpi-card:hover { background: var(--bg-subtle); }

.kpi-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .06em;
  color: var(--text-muted);
  line-height: 1.4;
}

.kpi-value {
  font-size: 30px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.01em;
  color: var(--text-strong);
  margin: 6px 0 2px;
}

.kpi-value.v-send   { color: var(--st-send); }
.kpi-value.v-react  { color: var(--st-react); }
.kpi-value.v-back   { color: var(--st-hold); }
.kpi-value.v-paused { color: var(--st-paused); }

.kpi-note {
  font-size: 11.5px;
  letter-spacing: .01em;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ライブステータスドット（パルス） */
.live-dot {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--st-stop);
  animation: pulseRing 2s var(--ease-std) infinite;
}

@keyframes pulseRing {
  0%   { box-shadow: 0 0 0 0 rgba(220, 38, 38, .35); }
  70%  { box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); }
  100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}

/* ═══ 行動カード ═══ */

.action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.action-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  text-align: left;
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-1);
  transition: transform var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-std);
}

.action-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-2);
  border-color: var(--line-strong);
}

.action-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  flex: none;
}

.action-body { min-width: 0; flex: 1; }

.action-title {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-strong);
  margin-bottom: 4px;
}

.action-desc {
  display: block;
  font-size: 11.5px;
  letter-spacing: .01em;
  color: var(--text-muted);
  line-height: 1.6;
}

.action-desc .badge { margin-left: 4px; vertical-align: middle; }

.action-arrow {
  color: var(--text-muted);
  font-size: 14px;
  flex: none;
  align-self: center;
  transition: transform var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-std);
}

.action-card:hover .action-arrow {
  transform: translateX(2px);
  color: var(--accent);
}

/* ═══ 直近の反応（全体画面・押すと反応ありへ） ═══ */

.recent-list {
  background: var(--bg-surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}

.recent-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  transition: background-color var(--dur-fast) var(--ease-std);
}

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

.recent-row:hover { background: var(--bg-subtle); }

.recent-row:hover .action-arrow {
  transform: translateX(2px);
  color: var(--accent);
}

.recent-time {
  flex: none;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  color: var(--text-muted);
}

.recent-company {
  flex: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-strong);
}

.recent-next {
  flex: 1;
  min-width: 0;
  font-size: 11.5px;
  letter-spacing: .01em;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-row .action-arrow { margin-left: auto; }

/* ═══ ツールバー（検索＋フィルタピル） ═══ */

.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 220px;
  max-width: 380px;
}

.search-box input {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 32px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-body);
  font-size: 13px;
  transition: border-color var(--dur-fast) var(--ease-std),
              box-shadow var(--dur-fast) var(--ease-std);
}

.search-box input::placeholder { color: var(--text-muted); }

.search-box input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

/* CSS描画の虫眼鏡 */
.search-glass {
  position: absolute;
  left: 11px;
  top: 50%;
  width: 10px;
  height: 10px;
  margin-top: -7px;
  border: 1.5px solid var(--text-muted);
  border-radius: var(--radius-full);
  pointer-events: none;
}
.search-glass::after {
  content: '';
  position: absolute;
  width: 5px;
  height: 1.5px;
  background: var(--text-muted);
  right: -4px;
  bottom: -2px;
  transform: rotate(45deg);
  border-radius: 1px;
}

.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-body);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease-std),
              border-color var(--dur-fast) var(--ease-std),
              color var(--dur-fast) var(--ease-std);
}

.filter-pill:hover { background: var(--bg-subtle); }

.filter-pill.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.pill-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  flex: none;
}
.pill-dot.d-send { background: var(--st-send); }
.pill-dot.d-hold { background: var(--st-hold); }
.pill-dot.d-stop { background: var(--st-stop); }

/* ═══ テーブル（横罫線のみ・縦罫線なし） ═══ */

.table-wrap {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  overflow-x: auto;
  box-shadow: var(--shadow-1);
  /* 横にはみ出している時だけ端にスクロールシャドウを出す（純CSS） */
  background:
    linear-gradient(to right, var(--bg-surface) 35%, rgba(255, 255, 255, 0)) left / 48px 100%,
    linear-gradient(to left,  var(--bg-surface) 35%, rgba(255, 255, 255, 0)) right / 48px 100%,
    radial-gradient(farthest-side at 0 50%,   rgba(17, 24, 39, .16), transparent) left / 14px 100%,
    radial-gradient(farthest-side at 100% 50%, rgba(17, 24, 39, .16), transparent) right / 14px 100%;
  background-color: var(--bg-surface);
  background-repeat: no-repeat;
  background-attachment: local, local, scroll, scroll;
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.data-table th {
  background: var(--bg-subtle);
  padding: 8px 12px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .06em;
  color: var(--text-muted);
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--line-strong);
}

.data-table td {
  padding: 12px;
  font-size: 13px;
  color: var(--text-body);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  vertical-align: middle;
}

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

.data-table tbody tr {
  cursor: default;
  transition: background-color var(--dur-fast) var(--ease-std);
}

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

/* 行選択（対象判定） */
.data-table tbody tr.is-clickable { cursor: pointer; }

.data-table tbody tr.is-selected { background: var(--accent-soft); }

.data-table tbody tr.is-selected td:first-child {
  box-shadow: inset 2px 0 0 var(--accent);
}

td.cell-strong {
  font-weight: 600;
  color: var(--text-strong);
}

td.cell-num { font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

td.cell-wrap {
  white-space: normal;
  min-width: 140px;
  line-height: 1.5;
}

/* ═══ 状態バッジ（6種のみ・ドット二重符号） ═══ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .03em;
  line-height: 1.4;
  white-space: nowrap;
}

.b-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: currentColor;
  flex: none;
}

.badge.b-send   { background: var(--st-send-soft);   border: 1px solid var(--st-send-line);   color: var(--st-send); }
.badge.b-hold   { background: var(--st-hold-soft);   border: 1px solid var(--st-hold-line);   color: var(--st-hold); }
.badge.b-stop   { background: var(--st-stop-soft);   border: 1px solid var(--st-stop-line);   color: var(--st-stop); }
.badge.b-ng     { background: var(--st-ng-soft);     border: 1px solid var(--st-ng-line);     color: var(--st-ng); }
.badge.b-paused { background: var(--st-paused-soft); border: 1px solid var(--st-paused-line); color: var(--st-paused); }
.badge.b-react  { background: var(--st-react-soft);  border: 1px solid var(--st-react-line);  color: var(--st-react); }

/* 開封＝アウトライン（塗りなし）でクリックとの強弱を表現 */
.badge.b-react-outline {
  background: transparent;
  border: 1px solid var(--st-react-line);
  color: var(--st-react);
}

/* 登録元＝沈んだアウトライン */
.badge.b-source {
  background: transparent;
  border: 1px solid var(--st-paused-line);
  color: var(--st-paused);
}

/* ═══ 優先度ドット ═══ */

.priority-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: var(--text-strong);
}

.priority-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  flex: none;
}
.priority-dot.p-high   { background: var(--st-stop); }
.priority-dot.p-mid    { background: var(--st-hold); }
.priority-dot.p-normal { background: var(--line-strong); }

/* ═══ 操作チップ（反応あり・常時表示。ホバーは色変化のみ） ═══ */

.row-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-body);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  transition: border-color var(--dur-fast) var(--ease-std),
              color var(--dur-fast) var(--ease-std),
              background-color var(--dur-fast) var(--ease-std);
}

.row-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

/* 戻し済み行：グレーアウト */
.data-table tbody tr.is-returned,
.data-table tbody tr.is-returned:hover {
  background: var(--bg-subtle);
}

.data-table tbody tr.is-returned td {
  color: var(--text-muted);
}

/* ═══ 対象判定：分割レイアウト＋詳細パネル ═══ */

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
}

.detail-panel {
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-2);
  padding: 20px;
}

.detail-empty {
  text-align: center;
  padding: 48px 0;
  font-size: 11.5px;
  letter-spacing: .01em;
  color: var(--text-muted);
}

.detail-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--text-strong);
  margin: 0 0 12px;
}

.detail-row {
  display: flex;
  gap: 8px;
  padding: 4px 0;
  align-items: baseline;
}

.detail-key {
  flex: none;
  width: 72px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .06em;
  color: var(--text-muted);
}

.detail-val {
  font-size: 13px;
  color: var(--text-body);
  min-width: 0;
  word-break: break-word;
}

.reason-box {
  margin-top: 12px;
  padding: 12px;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--st-paused);
  font-size: 13px;
  line-height: 1.65;
  color: var(--text-body);
}

.reason-box.r-send { border-left-color: var(--st-send); }
.reason-box.r-hold { border-left-color: var(--st-hold); }
.reason-box.r-stop { border-left-color: var(--st-stop); }

/* モバイル用インライン詳細行（デスクトップでは非表示） */
.detail-inline-row { display: none; }

/* ═══ 配信予定：注意帯＋タイムライン ═══ */

.demo-notice {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 16px;
  background: var(--st-hold-soft);
  border: 1px solid var(--st-hold-line);
  border-radius: var(--radius-sm);
  color: var(--st-hold);
  font-size: 12px;
  line-height: 1.6;
  margin-bottom: 24px;
}

/* CSS描画の丸枠「!」 */
.notice-icon {
  position: relative;
  width: 16px;
  height: 16px;
  border: 1.5px solid currentColor;
  border-radius: var(--radius-full);
  flex: none;
  margin-top: 2px;
}
.notice-icon::before {
  content: '!';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

.schedule-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

/* タイムライン接続線（水平） */
.schedule-grid::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 40px;
  right: 40px;
  height: 1px;
  background: var(--line-strong);
}

.timeline-item {
  position: relative;
  padding-top: 16px;
}

.timeline-node {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--line-strong);
  box-shadow: 0 0 0 3px var(--bg-base);
  z-index: 1;
}

.timeline-node.is-first { background: var(--st-hold); }

.schedule-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
  overflow: hidden;
  height: 100%;
  transition: transform var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-std);
}

.schedule-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-2);
  border-color: var(--line-strong);
}

.schedule-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--line);
}

.schedule-num {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .06em;
  color: var(--text-muted);
}

.schedule-card-body {
  padding: 16px;
  flex: 1;
}

.schedule-date {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
  color: var(--text-strong);
}

.schedule-meta {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-body);
  margin: 4px 0 8px;
}

.schedule-desc {
  font-size: 11.5px;
  letter-spacing: .01em;
  line-height: 1.6;
  color: var(--text-muted);
}

.schedule-card-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-body);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease-std),
              border-color var(--dur-fast) var(--ease-std),
              color var(--dur-fast) var(--ease-std);
}

.btn-ghost:hover {
  background: var(--bg-subtle);
  border-color: var(--accent);
  color: var(--accent);
}

/* 記録済み（押せない）状態 */
.btn-ghost:disabled {
  opacity: .55;
  cursor: default;
}
.btn-ghost:disabled:hover {
  background: var(--bg-surface);
  border-color: var(--line-strong);
  color: var(--text-body);
}

/* ═══ 反応あり：アラート ═══ */

.alert-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--st-stop-soft);
  border: 1px solid var(--st-stop-line);
  border-radius: var(--radius-sm);
  color: var(--st-stop);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 16px;
}

.alert-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--st-stop);
  flex: none;
  animation: pulseRing 2s var(--ease-std) infinite;
}

.alert-strip .cnt {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1;
}

/* 最優先の対応がすべて完了した状態 */
.alert-strip.is-clear {
  background: var(--st-send-soft);
  border-color: var(--st-send-line);
  color: var(--st-send);
}

.alert-strip.is-clear .alert-dot {
  background: var(--st-send);
  animation: none;
}

/* ═══ 配信停止：保護バナー（静かな厳格さ） ═══ */

.protect-banner {
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--st-ng);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
  padding: 16px 20px;
  margin-bottom: 16px;
}

.protect-banner h3 {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--st-ng);
  margin-bottom: 4px;
}

.protect-banner p {
  font-size: 12px;
  line-height: 1.7;
  color: var(--text-body);
}

/* ═══ 文面：メールクライアント風プレビュー ═══ */

.msg-selector { margin-bottom: 16px; }

.msg-card {
  background: var(--bg-surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}

.msg-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 20px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--line);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .06em;
  color: var(--text-muted);
}

.msg-subject {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}

.msg-subject-label {
  flex: none;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .06em;
  color: var(--text-muted);
}

.msg-subject-text {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--text-strong);
}

/* 宛名差し込みの注釈（デモ用固定値の説明） */
.msg-note {
  padding: 10px 20px;
  background: var(--st-hold-soft);
  border-bottom: 1px solid var(--line);
  color: var(--st-hold);
  font-size: 11.5px;
  letter-spacing: .01em;
  line-height: 1.6;
}

.msg-body {
  padding: 20px;
  max-width: 640px;
  font-size: 13px;
  line-height: 1.8;
  color: var(--text-body);
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-footer {
  padding: 14px 20px;
  background: var(--bg-subtle);
  border-top: 1px solid var(--line);
  font-size: 12px;
  line-height: 1.7;
  color: var(--text-body);
}

.msg-footer a {
  color: var(--accent);
  text-decoration: underline;
}

/* ダミー配信停止リンク（button要素）。タップ領域を44px相当に拡大 */
.unsub-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 8px;
  margin-left: -8px;
  vertical-align: middle;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}

.unsub-link:hover { color: var(--accent-hover); }

.msg-footer .note {
  font-size: 11.5px;
  letter-spacing: .01em;
  color: var(--text-muted);
}

/* ═══ トースト（唯一のダーク面） ═══ */

.toast-wrap {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

.toast {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--text-strong);
  color: #fff;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-3);
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--dur-base) var(--ease-out),
              transform var(--dur-base) var(--ease-out);
  max-width: 360px;
}

.toast.is-show {
  opacity: 1;
  transform: translateY(0);
}

.toast-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  flex: none;
}
.toast-dot.td-green { background: #4ADE80; }
.toast-dot.td-amber { background: #FBBF24; }

/* ═══ レスポンシブ ═══ */

@media (max-width: 1000px) {
  .kpi-strip { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 900px) {
  .split-layout { grid-template-columns: 1fr; }
  .main-content { padding-left: 20px; padding-right: 20px; }
}

@media (max-width: 640px) {

  .app-header { padding: 0 16px; gap: 8px; }
  .header-meta { display: none; }

  .tab-nav { padding: 0 16px; }

  .main-content { padding: 16px 16px 56px; }

  .kpi-strip { grid-template-columns: repeat(2, 1fr); }
  .kpi-value { font-size: 24px; }

  .search-box { max-width: none; }

  /* ── テーブル → カード行 ── */
  .table-wrap {
    background: transparent;
    border: none;
    box-shadow: none;
    overflow: visible;
  }

  .data-table, .data-table tbody { display: block; width: 100%; }
  .data-table thead { display: none; }

  .data-table tbody { display: grid; gap: 12px; }

  .data-table tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-1);
    padding: 14px 16px;
  }

  .data-table tbody tr:hover { background: var(--bg-surface); }

  .data-table tbody tr.is-selected {
    background: var(--accent-soft);
    border-color: var(--accent);
  }

  .data-table tbody tr.is-selected td:first-child { box-shadow: none; }

  .data-table td {
    display: block;
    padding: 0;
    border: none;
    white-space: normal;
    min-width: 0;
    word-break: break-word;
  }

  .data-table td.m-title {
    grid-column: 1;
    grid-row: 1;
    font-weight: 600;
    color: var(--text-strong);
  }

  .data-table td.m-badge {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
  }

  .data-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: .06em;
    color: var(--text-muted);
    margin-bottom: 2px;
  }

  td.cell-wrap { min-width: 0; }

  /* 操作セル（反応あり）は全幅・常時表示 */
  .data-table td.cell-op { grid-column: 1 / -1; }
  .data-table td.cell-op .row-chip {
    opacity: 1;
    width: 100%;
    justify-content: center;
  }

  /* 詳細パネルは廃止 → インライン展開 */
  .detail-panel { display: none; }

  .detail-inline-row {
    display: block !important;
    background: var(--bg-surface);
    border: 1px solid var(--line);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-2);
    padding: 16px !important;
  }

  .detail-inline-row td {
    display: block;
    padding: 0;
    border: none;
    white-space: normal;
  }

  /* タイムライン：縦向き */
  .schedule-grid { grid-template-columns: 1fr; }

  .schedule-grid::before {
    top: 12px;
    bottom: 12px;
    left: 2.5px;
    right: auto;
    width: 1px;
    height: auto;
  }

  .timeline-item { padding-top: 0; padding-left: 20px; }

  .timeline-node {
    top: 20px;
    left: 0;
    transform: none;
  }

  /* 行動カード 1列 */
  .action-grid { grid-template-columns: 1fr; }

  /* 直近の反応：1行目＝会社名（全幅・省略しない）、2行目＝日時＋反応バッジ */
  .recent-next { display: none; }

  .recent-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 2px 10px;
    align-items: center;
  }

  .recent-company {
    grid-column: 1 / 3;
    grid-row: 1;
    min-width: 0;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    line-height: 1.5;
  }

  .recent-time {
    grid-column: 1;
    grid-row: 2;
    justify-self: start;
  }

  .recent-row .badge {
    grid-column: 2;
    grid-row: 2;
    justify-self: end;
  }

  .recent-row .action-arrow {
    grid-column: 3;
    grid-row: 1 / 3;
    margin-left: 0;
  }

  /* トースト全幅 */
  .toast-wrap { left: 16px; right: 16px; bottom: 16px; align-items: stretch; }
  .toast { max-width: none; }
}

/* ═══ prefers-reduced-motion ═══ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
