:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-soft: #f1f4f6;
  --line: #d9dee5;
  --text: #17202a;
  --muted: #647182;
  --muted-2: #8b96a6;
  --accent: #1b6f70;
  --accent-soft: #dff1ef;
  --blue: #315c99;
  --pink: #b24a74;
  --lime: #7a8b24;
  --orange: #b4652a;
  --red: #b33a3a;
  --shadow: 0 10px 30px rgba(24, 34, 48, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 18px 14px;
  background: #18222b;
  color: #f8fbfc;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #dfe8e3;
  color: #17202a;
  font-weight: 800;
}

.brand-title {
  font-weight: 750;
}

.brand-subtitle,
.sidebar-label {
  color: rgba(255, 255, 255, 0.58);
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 4px;
  margin: 18px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 38px;
  padding: 9px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: rgba(255, 255, 255, 0.76);
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.nav-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.55;
}

.source-panel {
  margin-top: auto;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
}

.sidebar-settings {
  display: grid;
  gap: 8px;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.settings-item {
  margin-bottom: 10px;
}

.sidebar-settings + .source-panel {
  margin-top: 0;
}

.source-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
}

.source-row strong {
  color: #ffffff;
  font-weight: 650;
}

/* A: ワイド画面（1920px+）でコンテンツが間延びしないよう最大幅を設定。
   グリッドセル内で width + margin-inline: auto により中央寄せする。
   1280/1440px では max-width に届かないため従来レイアウト維持。 */
.main {
  min-width: 0;
  width: min(100%, 1560px);
  margin-inline: auto;
  padding: 22px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.2;
}

h2 {
  font-size: 15px;
  line-height: 1.35;
}

h3 {
  font-size: 13px;
  line-height: 1.35;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.api-notice {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  margin: -6px 0 14px;
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 650;
}

.api-notice.loading {
  background: #e8eef7;
  color: var(--blue);
}

.api-notice.fallback {
  background: #fbecd8;
  color: #74410d;
}

.api-notice.live {
  background: #dff1ef;
  color: #126164;
}

.api-notice span {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(49, 92, 153, 0.2);
  border-top-color: var(--blue);
  border-radius: 50%;
}

select,
input,
textarea {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  padding: 7px 9px;
}

.top-actions select {
  width: auto;
  min-width: 132px;
}

.primary-button,
.secondary-button,
.icon-button {
  min-height: 34px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 7px 12px;
  font-weight: 650;
}

.primary-button {
  background: var(--accent);
  color: #ffffff;
}

.secondary-button {
  background: #ffffff;
  border-color: var(--line);
  color: var(--text);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 34px;
  padding: 0;
  background: #ffffff;
  border-color: var(--line);
}

/* A: KPIカードもワイド画面で間延びしないよう、.kpi-grid で最大列幅を制限 */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.kpi,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.kpi {
  display: grid;
  gap: 6px;
  min-height: 108px;
  padding: 13px;
}

.kpi span,
.kpi small,
.panel-heading p,
.rank-main small,
.data-table small,
.field span,
.note-field span,
.detail-list span,
.metric span,
.drawer-header p {
  color: var(--muted);
}

.kpi strong {
  font-size: 24px;
  line-height: 1.1;
}

.content-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 14px;
}

.overview-grid .wide {
  grid-column: span 2;
}

.panel {
  min-width: 0;
  padding: 14px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.legend,
.row-meta,
.row-title,
.tag-list,
.drawer-actions,
.segmented {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.legend {
  color: var(--muted);
  font-size: 12px;
}

.legend i {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 4px;
  border-radius: 2px;
}

.legend-x,
.bar-x {
  background: var(--blue);
}

.legend-ig,
.bar-ig {
  background: var(--pink);
}

.legend-tt,
.bar-tt {
  background: var(--lime);
}

.chart {
  display: grid;
  grid-template-columns: repeat(8, minmax(42px, 1fr));
  align-items: end;
  gap: 8px;
  min-height: 220px;
  padding-top: 8px;
}

.chart-compact {
  min-height: 230px;
}

.chart-large {
  min-height: 340px;
}

.empty-chart {
  display: grid;
  place-items: center;
  min-height: 240px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fbfcfd;
}

.chart-day {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 8px;
  height: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0;
}

.chart-value {
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  opacity: 0.48;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-day.active .chart-value,
.chart-day:hover .chart-value,
.chart-day:focus-visible .chart-value {
  opacity: 1;
}

.chart-day small {
  font-size: 11px;
}

.chart-day.active small,
.chart-day:hover small {
  color: var(--text);
  font-weight: 700;
}

.bar {
  align-self: end;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  overflow: hidden;
  width: 100%;
  min-height: 8px;
  border-radius: 5px 5px 2px 2px;
  background: var(--surface-soft);
}

.bar i {
  display: block;
  width: 100%;
}

.chart-tooltip {
  position: absolute;
  left: 50%;
  bottom: calc(100% - 24px);
  z-index: 5;
  display: grid;
  gap: 7px;
  width: 210px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 12px 28px rgba(24, 34, 48, 0.16);
  color: var(--text);
  opacity: 0;
  padding: 10px;
  pointer-events: none;
  text-align: left;
  transform: translate(-50%, 8px);
  transition: opacity 140ms ease, transform 140ms ease;
  visibility: hidden;
}

.chart-tooltip b {
  font-size: 12px;
}

.chart-tooltip span {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.chart-tooltip i {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.chart-tooltip strong {
  margin-left: auto;
  color: var(--text);
}

.chart-day:hover .chart-tooltip,
.chart-day:focus-visible .chart-tooltip {
  opacity: 1;
  transform: translate(-50%, 0);
  visibility: visible;
}

.chart-day.highlight .bar {
  outline: 2px solid rgba(180, 101, 42, 0.22);
  outline-offset: 2px;
}

.chart-day.active .bar {
  box-shadow: 0 0 0 3px rgba(27, 111, 112, 0.18);
}

.split-list,
.rank-list,
.day-stack,
.evidence-list,
.product-posts {
  display: grid;
  gap: 8px;
}

.split-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 12px;
}

.meter {
  height: 7px;
  overflow: hidden;
  border-radius: 99px;
  background: var(--surface-soft);
}

.meter span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.rank-row,
.day-post,
.product-post,
.evidence-post {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  text-align: left;
  padding: 9px;
}

.rank-row:hover,
.day-post:hover,
.product-post:hover,
.evidence-post:hover {
  border-color: #b9c3ce;
}

.rank-row.static {
  cursor: default;
}

.rank-number {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.rank-main {
  display: grid;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.rank-main strong,
.post-cell strong,
.product-name strong,
.evidence-post strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-value {
  margin-left: auto;
  font-weight: 750;
}

.platform-chip,
.status,
.type-pill,
.source-badge,
.decision,
.tag-list span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  border-radius: 6px;
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}

.platform-x {
  background: #e8eef7;
  color: var(--blue);
}

.platform-instagram {
  background: #f7e8ef;
  color: var(--pink);
}

.platform-tiktok {
  background: #edf1d9;
  color: #65751d;
}

.status-synced {
  background: #dff1ef;
  color: #126164;
}

.status-partial,
.status-stale {
  background: #fbecd8;
  color: var(--orange);
}

.status-manual {
  background: #e9eef5;
  color: var(--blue);
}

.status-queued {
  background: #edf1d9;
  color: #65751d;
}

.status-failed {
  background: #f7dddd;
  color: var(--red);
}

.type-pill.gifting {
  background: #e6f0ee;
  color: var(--accent);
}

.type-pill.organic {
  background: #f2eadf;
  color: #865126;
}

.source-badge,
.tag-list span {
  background: var(--surface-soft);
  color: var(--muted);
}

.tier-pill {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  min-height: 24px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 850;
}

.tier-s {
  background: #dff1ef;
  color: #126164;
}

.tier-a {
  background: #e8eef7;
  color: var(--blue);
}

.tier-b {
  background: #fbecd8;
  color: var(--orange);
}

.insight-mini {
  display: grid;
  gap: 7px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.insight-mini:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.insight-mini p,
.insight-card p,
.drawer-section p {
  color: var(--muted);
  line-height: 1.55;
}

.decision {
  width: fit-content;
}

.decision.scale {
  background: #dff1ef;
  color: #126164;
}

.decision.watch {
  background: #fbecd8;
  color: var(--orange);
}

.decision.learn {
  background: #e8eef7;
  color: var(--blue);
}

.decision.stop {
  background: #f7dddd;
  color: var(--red);
}

.daily-layout,
.posts-layout,
.segment-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 14px;
  align-items: start;
}

.segment-layout {
  grid-template-columns: minmax(0, 1.2fr) minmax(340px, 0.8fr);
}

.segment-list,
.window-list {
  display: grid;
  gap: 10px;
}

.segment-row,
.window-row {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 12px;
}

.segment-metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.segment-metrics span {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 12px;
}

.segment-metrics strong {
  color: var(--text);
  font-size: 13px;
}

.segment-meter {
  margin-top: 9px;
}

.window-row {
  cursor: pointer;
}

.window-bars {
  display: grid;
  gap: 8px;
}

.window-bar {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 82px;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.window-bar strong {
  color: var(--text);
  text-align: right;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
  color: var(--text);
  padding: 10px 12px;
  font-weight: 750;
}

.daily-main {
  min-width: 0;
}

.segmented {
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
}

.segmented button {
  min-height: 28px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  padding: 5px 9px;
}

.segmented button.active {
  background: #ffffff;
  color: var(--text);
  box-shadow: 0 1px 4px rgba(24, 34, 48, 0.08);
}

.daily-table-wrap {
  margin-top: 16px;
}

.empty {
  color: var(--muted);
  padding: 20px;
  text-align: center;
}

.post-visual {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 58px;
  height: 58px;
  border-radius: 8px;
  color: #ffffff;
  font-weight: 800;
}

.post-visual.instagram,
.post-preview.instagram {
  background:
    linear-gradient(135deg, rgba(178, 74, 116, 0.92), rgba(27, 111, 112, 0.78)),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.2) 0 8px, transparent 8px 16px);
}

.post-visual.tiktok,
.post-preview.tiktok {
  background:
    linear-gradient(135deg, rgba(122, 139, 36, 0.96), rgba(49, 92, 153, 0.75)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.18) 0 7px, transparent 7px 14px);
}

.post-visual.x,
.post-preview.x {
  background:
    linear-gradient(135deg, rgba(49, 92, 153, 0.96), rgba(24, 34, 43, 0.82)),
    radial-gradient(circle at 65% 25%, rgba(255, 255, 255, 0.28), transparent 32%);
}

.day-post > div:nth-child(2) {
  min-width: 0;
  flex: 1;
}

.day-post p {
  overflow: hidden;
  margin: 6px 0;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.posts-layout {
  grid-template-columns: 230px minmax(0, 1fr);
}

.filters {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 14px;
}

.field,
.note-field {
  display: grid;
  gap: 6px;
}

.field span,
.note-field span {
  font-size: 12px;
  font-weight: 650;
}

.table-wrap {
  overflow: auto;
}

.data-table {
  width: 100%;
  min-width: 840px;
  border-collapse: collapse;
}

/* ヘッダーは折り返さない（「インプレッション」等が2行化して列が間延びするのを防ぐ） */
.data-table th {
  white-space: nowrap;
}

/* 商品名は長くなりがちなので最大幅 + 省略表示で列幅の暴走を抑える */
.data-table td.prod-col {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compact-table {
  min-width: 720px;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line);
  padding: 11px 8px;
  text-align: left;
  vertical-align: middle;
}

/* 指標セル(リーチ/インプレッション): 値は太字1行、単位ラベルは下段に折り返さず表示 */
.metric-cell strong {
  white-space: nowrap;
}

.metric-cell small {
  display: block;
  margin-top: 1px;
  white-space: nowrap;
  font-size: 11px;
}

.data-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

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

.data-table tbody tr:hover,
.data-table tbody tr.selected {
  background: #f7faf9;
}

.data-table tbody tr[data-post-id] {
  cursor: pointer;
}

.post-cell {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 150px;
}

.post-cell div,
.product-name {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.tag-list {
  gap: 5px;
}

.product-table .product-row > td:first-child {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 230px;
}

.expand-button {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--text);
  font-weight: 800;
}

.product-detail-row td {
  display: table-cell;
  background: #fafbfc;
  padding: 12px;
}

.product-posts {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.product-post {
  min-height: 44px;
}

.product-post strong {
  min-width: 0;
  overflow: hidden;
  flex: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-post b {
  flex: 0 0 auto;
  font-weight: 800;
}

.product-post > span:not(.platform-chip):not(.status) {
  color: var(--muted);
  font-size: 12px;
}

.insights-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.insight-card {
  display: grid;
  gap: 14px;
}

.insight-head {
  display: grid;
  gap: 9px;
}

.evidence-post {
  justify-content: flex-start;
}

.evidence-post span:last-child {
  margin-left: auto;
  color: var(--muted);
}

.note-field textarea {
  min-height: 76px;
  resize: vertical;
}

.integration-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.integration-intro {
  margin-bottom: 14px;
}

.integration-checkline {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.integration-checkline span {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--muted);
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 650;
}

.integration-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.brand-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.brand-summary-card {
  display: grid;
  gap: 13px;
}

.brand-health {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.brand-health div {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  padding: 9px;
}

.brand-health span,
.brand-source-list span {
  color: var(--muted);
  font-size: 12px;
}

.brand-health strong {
  font-size: 18px;
}

.brand-source-list {
  display: grid;
  gap: 7px;
}

.brand-source-list div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 7px;
}

.brand-source-list div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.integration-card {
  display: grid;
  gap: 13px;
}

.integration-card p {
  color: var(--muted);
  line-height: 1.55;
}

.integration-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.integration-category {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.integration-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.integration-connected {
  background: #dff1ef;
  color: #126164;
}

.integration-not-connected {
  background: #e9eef5;
  color: var(--blue);
}

.integration-needs-action,
.integration-syncing,
.integration-setup-required {
  background: #fbecd8;
  color: var(--orange);
}

.integration-failed {
  background: #f7dddd;
  color: var(--red);
}

.integration-meta {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 8px 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  padding: 10px;
}

.integration-meta span,
.sync-run span,
.sync-run small {
  color: var(--muted);
}

.integration-block {
  display: grid;
  gap: 8px;
}

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

.setting-item {
  display: grid;
  gap: 5px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  padding: 9px;
}

.setting-item.wide {
  grid-column: 1 / -1;
}

.setting-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.setting-item strong {
  overflow-wrap: anywhere;
}

.missing-value {
  color: var(--orange);
}

.requirement-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.requirement-list li {
  position: relative;
  padding-left: 18px;
  color: var(--text);
  font-size: 13px;
}

.requirement-list li::before {
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  content: "";
}

.requirement-list li.missing::before {
  background: var(--orange);
}

.missing-box,
.ready-box,
.mcp-note,
.complete-box {
  border-radius: 6px;
  padding: 10px;
  line-height: 1.5;
}

.missing-box.compact,
.ready-box.compact {
  grid-column: 1 / -1;
  padding: 8px 9px;
  font-size: 12px;
}

.missing-box,
.mcp-note {
  background: #fbecd8;
  color: #74410d;
}

.ready-box,
.complete-box {
  background: #dff1ef;
  color: #126164;
}

.sync-run {
  display: grid;
  gap: 3px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.integration-actions {
  display: grid;
  grid-template-columns: 1.05fr 1fr 1fr;
  gap: 8px;
}

.action-box,
.real-sync-note,
.real-sync-confirm {
  border-radius: 6px;
  padding: 9px 10px;
  font-size: 13px;
  line-height: 1.45;
}

.action-box.running {
  background: #fbecd8;
  color: #74410d;
}

.action-box.failed {
  background: #f7dddd;
  color: var(--red);
}

.action-box.success {
  background: #dff1ef;
  color: #126164;
}

.real-sync-note {
  background: #fbfcfd;
  color: var(--muted);
}

.real-sync-confirm {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  border: 1px solid rgba(176, 67, 50, 0.28);
  background: #fff7f5;
  color: var(--red);
}

.danger-button {
  min-height: 36px;
  border: 1px solid #b04332;
  border-radius: 6px;
  background: #b04332;
  color: #ffffff;
  padding: 8px 12px;
  font-weight: 800;
}

.full-width-button {
  width: 100%;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(15, 23, 32, 0.28);
}

.wizard-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 50;
  width: min(820px, calc(100vw - 28px));
  max-height: min(760px, calc(100vh - 28px));
  overflow: auto;
  transform: translate(-50%, -50%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 22px 60px rgba(24, 34, 48, 0.22);
}

.wizard-header,
.wizard-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
}

.wizard-header {
  border-bottom: 1px solid var(--line);
}

.wizard-footer {
  border-top: 1px solid var(--line);
}

.wizard-steps {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
}

.wizard-steps button {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--muted);
  padding: 7px;
  font-size: 12px;
  font-weight: 700;
}

.wizard-steps button.active {
  border-color: rgba(27, 111, 112, 0.45);
  background: var(--accent-soft);
  color: var(--accent);
}

.wizard-steps span {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: currentColor;
  color: #ffffff;
  font-size: 11px;
}

.wizard-body {
  display: grid;
  gap: 14px;
  min-height: 280px;
  padding: 16px;
}

.wizard-source-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.wizard-source-list button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  padding: 11px;
  text-align: left;
}

.wizard-source-list button.selected {
  border-color: rgba(27, 111, 112, 0.45);
  background: #f7fbfa;
}

.wizard-columns,
.auth-box {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.auth-box {
  align-items: start;
}

.auth-box .field:last-child {
  grid-column: 1 / -1;
}

.self-serve-form .wide-field {
  grid-column: 1 / -1;
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.check-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  padding: 7px 9px;
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
}

.check-grid input {
  accent-color: var(--accent);
}

.test-sync-box {
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 14px;
}

.test-sync-box p {
  color: var(--muted);
  line-height: 1.5;
}

.test-spinner {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: 4px solid #d7e8e6;
  border-top-color: var(--accent);
  border-radius: 50%;
}

.sync-preview {
  display: grid;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}

.sync-preview span {
  color: var(--muted);
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(15, 23, 32, 0.24);
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  width: min(520px, 100vw);
  overflow: auto;
  border-left: 1px solid var(--line);
  background: #ffffff;
  box-shadow: -16px 0 32px rgba(24, 34, 48, 0.12);
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.drawer-header h2 {
  margin-top: 8px;
  font-size: 18px;
}

.post-preview {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 230px;
  margin: 18px;
  border-radius: 8px;
  color: #ffffff;
  padding: 18px;
}

.post-preview div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 800;
}

.post-preview p {
  max-width: 38ch;
  color: rgba(255, 255, 255, 0.9);
  line-height: 1.55;
}

.drawer-actions,
.drawer-section {
  margin: 18px;
}

.drawer-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.drawer-section {
  display: grid;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.metric {
  display: grid;
  gap: 4px;
  min-height: 62px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px;
}

.metric strong {
  font-size: 17px;
}

.detail-list {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 9px;
  align-items: center;
}

.drawer-tags {
  margin-top: 2px;
}

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

  .content-grid,
  .insights-layout,
  .product-posts,
  .integration-grid,
  .brand-summary-grid {
    grid-template-columns: 1fr 1fr;
  }

  .overview-grid .wide {
    grid-column: span 2;
  }

  .daily-layout {
    grid-template-columns: 1fr;
  }

  .segment-layout {
    grid-template-columns: 1fr;
  }

  .segment-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

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

  .sidebar {
    position: static;
    height: auto;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .source-panel {
    display: none;
  }

  .main {
    padding: 14px;
  }

  .topbar,
  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    justify-content: flex-start;
  }

  .top-actions select,
  .top-actions .primary-button {
    flex: 1 1 150px;
  }

  .kpi-grid,
  .integration-summary,
  .content-grid,
  .insights-layout,
  .posts-layout,
  .product-posts,
  .integration-grid,
  .brand-summary-grid,
  .settings-grid,
  .integration-checkline,
  .wizard-source-list,
  .wizard-columns,
  .auth-box {
    grid-template-columns: 1fr;
  }

  .wizard-steps {
    grid-template-columns: 1fr;
  }

  .integration-actions {
    grid-template-columns: 1fr;
  }

  .overview-grid .wide {
    grid-column: auto;
  }

  .chart {
    grid-template-columns: repeat(4, minmax(52px, 1fr));
    min-height: 260px;
  }

  .segment-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filters {
    position: static;
  }
}

/* ─────────────────────────────────────────────
   Phase 0: SNS別グルーピング共通コンポーネント
   renderPlatformGroups() が出力する HTML に対応
   ───────────────────────────────────────────── */

.platform-group {
  margin-bottom: 12px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  overflow: hidden;
}

.platform-group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  background: var(--surface-secondary, #f9fafb);
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: left;
  color: var(--text, #111827);
}

.platform-group-header:hover {
  background: var(--surface-hover, #f3f4f6);
}

.platform-group-label {
  flex: 1;
}

.platform-group-meta {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--text-muted, #6b7280);
}

.platform-group-chevron {
  font-size: 0.7rem;
  color: var(--text-muted, #6b7280);
}

.platform-group-body {
  padding: 0;
}

.platform-group-empty {
  padding: 16px;
  color: var(--text-muted, #6b7280);
  font-size: 0.875rem;
}

/* Phase 2: プラットフォームグループ内のテーブル（投稿行） */
.platform-group-table {
  width: 100%;
  border: none;
  table-layout: fixed;
}

.platform-group-table td:nth-child(1) { width: 22%; }
.platform-group-table td:nth-child(2) { width: 18%; }
.platform-group-table td:nth-child(3) { width: 10%; }
.platform-group-table td:nth-child(4) { width: 13%; }
.platform-group-table td:nth-child(5) { width: 7%; }
.platform-group-table td:nth-child(6) { width: 6%; }
.platform-group-table td:nth-child(7) { width: 8%; }
.platform-group-table td:nth-child(8) { width: 8%; }
.platform-group-table td:nth-child(9) { width: 8%; }

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

/* Phase 2 (revised): 商品別SNSアコーディオン — テーブル方式 */
.platform-groups-wrap {
  padding: 12px 16px;
}

/* 商品別テーブル: 列幅固定（table-layout: fixed で揃える） */
.product-platform-table {
  min-width: 640px;
  table-layout: fixed;
}

.product-platform-table th,
.product-platform-table td {
  vertical-align: middle;
}

/* 商品列: 残り幅を全部使う */
.product-platform-table th:nth-child(1),
.product-platform-table td:nth-child(1) {
  width: auto;
}

/* 数値列: 幅を固定して右寄せ */
.product-platform-table .num-col {
  width: 110px;
  text-align: right;
  white-space: nowrap;
}

/* 主指標の数値を太く・やや大きめに強調 */
.product-platform-table .metric-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text, #17202a);
}

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

  .kpi-grid {
    gap: 8px;
  }

  .drawer-actions,
  .metric-grid,
  .integration-meta {
    grid-template-columns: 1fr 1fr;
  }

  .detail-list {
    grid-template-columns: 1fr;
  }

  .post-preview {
    min-height: 190px;
  }
}

/* ─── Phase 3: クリエイター分析 フィルター・ソート ─── */

.creator-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0 12px;
}

.sortable-col {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.sortable-col:hover {
  background: var(--surface-soft);
}

.sort-icon {
  font-size: 11px;
  margin-left: 3px;
}

.sort-icon.inactive {
  opacity: 0.35;
}

.sort-icon.active {
  color: var(--blue);
  opacity: 1;
}

/* ─────────────────────────────────────────────
   B: データテーブル — 数値の視覚的強弱 & 右寄せ
   ───────────────────────────────────────────── */

/* クリエイター分析テーブル: 数値列を右寄せ */
#creators-table th:nth-child(n+4),
#creators-table td:nth-child(n+4) {
  text-align: right;
}

/* クリエイター分析: 主指標（平均Imp・最高Imp）を太字・濃色で強調 */
#creators-table td:nth-child(5),
#creators-table td:nth-child(6) {
  font-weight: 700;
  color: var(--text);
}

/* クリエイター分析: 補助テキスト（投稿数・反応率・売上列ラベル）は muted で制御済み */
/* 投稿数・クーポン売上・GA売上は標準の text スタイル維持（階層を保つ） */

/* 日別分析テーブル: 数値列を右寄せ */
.compact-table th:nth-child(n+2),
.compact-table td:nth-child(n+2) {
  text-align: right;
}

/* 日別分析: 合計列（2列目）を太字・濃色で主指標強調 */
.compact-table td:nth-child(2) {
  font-weight: 700;
  color: var(--text);
}

/* 日別分析: 日付列は左寄せ維持（1列目のみ上書き） */
.compact-table th:nth-child(1),
.compact-table td:nth-child(1) {
  text-align: left;
}

/* ─────────────────────────────────────────────
   C: 概要の上位リスト — 値カラム縦揃え & 補助テキスト整形
   ───────────────────────────────────────────── */

/* rank-value: 数値(大)＋単位(小)を上下2段で右揃え。固定幅にしないので長い単位ラベルでも見切れない */
.rank-value {
  flex: 0 0 auto;
  margin-left: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  white-space: nowrap;
  font-weight: 750;
}

.rank-value b {
  font-weight: 750;
}

.rank-value small {
  margin-top: 1px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

/* rank-main の名前行: 省略(ellipsis)が確実に効くよう min-width:0 を強制 */
.rank-main {
  min-width: 0;
  flex: 1;
}

/* サブテキスト(SKU/ブランド名): muted + ellipsis で控えめに */
.rank-main small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
}
