/* 運営：売上と傾向（/admin/analytics）
 *
 *  色は3つだけ。見分けやすさを機械で確かめたもの（色覚のちがいがあっても区別できる並び）。
 *    1 青 #2a78d6 ／ 2 橙 #eb6834 ／ 3 緑 #1baf7a
 *  数字と文字は、系列の色では塗らない。色は棒だけが持ち、文字は黒・灰で読む。
 */

.an-page {
  --an-ink: #1b2733;
  --an-ink-2: #55657a;
  --an-ink-3: #8294a8;
  --an-line: #dde4ec;
  --an-line-soft: #eef2f7;
  --an-surface: #fff;
  --an-surface-2: #f7f9fc;
  --an-up: #1d6b45;
  --an-down: #9a3b33;
 
  color: var(--an-ink);
}

/* ---------------------------------------------------------------- 見出し */

.an-head { margin-bottom: 18px; }
.an-head h1 { margin: 0 0 6px; }

.an-page h2 {
  font-size: 17px;
  margin: 0 0 4px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--an-line);
}

.an-page h3 {
  font-size: 14px;
  color: var(--an-ink-2);
  margin: 20px 0 2px;
  font-weight: 600;
}

.an-section {
  margin: 0 0 34px;
  padding: 18px 20px 20px;
  background: var(--an-surface);
  border: 1px solid var(--an-line);
  border-radius: 10px;
}

/* 説明文。.muted は10pxで小さすぎるので、この画面では使わない */
.an-page .an-lead {
  color: var(--an-ink-2);
  font-size: 13px;
  line-height: 1.85;
  margin: 8px 0 14px;
}

.an-page .an-note {
  color: var(--an-ink-2);
  font-size: 12px;
  line-height: 1.9;
  margin: 10px 0 0;
  padding: 10px 12px;
  background: var(--an-surface-2);
  border-radius: 6px;
}

/* ---------------------------------------------------------------- 切り替え */

.an-control {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 16px;
}

.an-control-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--an-ink-2);
}

.an-control-note {
  font-size: 12px;
  color: var(--an-ink-3);
}

.an-seg {
  display: inline-flex;
  flex-wrap: wrap;
  border: 1px solid var(--an-line);
  border-radius: 7px;
  overflow: hidden;
  background: var(--an-surface);
}

.an-page a.an-seg-item {
  display: inline-block;
  padding: 5px 12px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--an-ink-2);
  text-decoration: none;
  border-left: 1px solid var(--an-line);
  white-space: nowrap;
}

.an-page a.an-seg-item:first-child { border-left: 0; }
.an-page a.an-seg-item:hover { background: var(--an-surface-2); }

.an-page a.an-seg-item.is-on {
  background: #2a78d6;
  border-left-color: #2a78d6;
  color: #fff;
  font-weight: 600;
}

/* ---------------------------------------------------------------- 数字のタイル */

.an-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin: 14px 0 0;
}

.an-tile {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 14px;
  background: var(--an-surface-2);
  border: 1px solid var(--an-line-soft);
  border-radius: 8px;
}

.an-tile.is-total {
  background: #eef4fd;
  border-color: #cfe0f7;
}

.an-tile-label {
  font-size: 11.5px;
  color: var(--an-ink-2);
  line-height: 1.5;
}

.an-tile-value {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}

.an-tile-sub {
  font-size: 11px;
  color: var(--an-ink-3);
  line-height: 1.6;
}

.an-delta {
  font-weight: 700;
  margin-right: 4px;
  font-variant-numeric: tabular-nums;
}

.an-delta.is-up { color: var(--an-up); }
.an-delta.is-down { color: var(--an-down); }

/* ---------------------------------------------------------------- グラフ */

.an-chart {
  margin: 6px 0 4px;
}

.an-chart svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.an-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin: 0 0 6px;
  font-size: 12px;
  color: var(--an-ink-2);
}

.an-key {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.an-swatch {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  display: inline-block;
}

.an-chart .an-grid { stroke: var(--an-line-soft); stroke-width: 1; }
.an-chart .an-base { stroke: var(--an-line); stroke-width: 1; }

.an-chart .an-axis,
.an-chart .an-rowlabel,
.an-chart .an-rowvalue {
  font-size: 11px;
  fill: var(--an-ink-3);
  font-variant-numeric: tabular-nums;
}

.an-chart .an-rowlabel { font-size: 12px; fill: var(--an-ink-2); }
.an-chart .an-rowvalue { font-size: 12px; fill: var(--an-ink); }

.an-chart path:hover { opacity: 0.82; }

/* ---------------------------------------------------------------- 表 */

.an-page .an-table {
  font-size: 12.5px;
}

.an-page .an-table th,
.an-page .an-table td {
  padding: 7px 10px;
}

.an-page .an-table td.num,
.an-page .an-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.an-page .an-table tbody tr:nth-child(even) { background: var(--an-surface-2); }

/* ---------------------------------------------------------------- そのほか */

.an-details {
  margin: 12px 0 0;
  border: 1px solid var(--an-line);
  border-radius: 8px;
  background: var(--an-surface-2);
}

.an-details > summary {
  padding: 9px 14px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--an-ink-2);
  cursor: pointer;
  list-style: none;
}

.an-details > summary::before {
  content: "▸ ";
  color: var(--an-ink-3);
}

.an-details[open] > summary::before { content: "▾ "; }
.an-details[open] > summary { border-bottom: 1px solid var(--an-line); }
.an-details > *:not(summary) { padding: 10px 14px 14px; background: var(--an-surface); }

.an-defs {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 2px 14px;
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--an-ink-2);
  line-height: 1.8;
}

.an-defs dt { font-weight: 600; color: var(--an-ink); }
.an-defs dd { margin: 0; }

.an-sub {
  font-size: 11.5px;
  color: var(--an-ink-3);
  line-height: 1.7;
}

.an-rank {
  margin: 22px 0 0;
}

.an-rank:first-of-type { margin-top: 8px; }

.an-rank h3 {
  margin-top: 0;
  font-size: 14.5px;
  color: var(--an-ink);
}

.an-tag {
  display: inline-block;
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 4px;
  background: #eef4fd;
  color: #244a8f;
  margin-left: 4px;
  vertical-align: 1px;
}

@media (max-width: 760px) {
  .an-section { padding: 14px 12px 16px; }
  .an-tile-value { font-size: 18px; }
}

/* ---------------------------------------------------------------- その場で切り替える部分
 *  turbo-frame は、そのままだと inline なので、囲みの余白が崩れる。block にしておく。
 *  読み込み中は少し薄くして、押したことが分かるようにする。
 */

.an-page turbo-frame {
  display: block;
}

.an-page turbo-frame[busy] {
  opacity: 0.55;
  transition: opacity 0.12s ease-in;
}

/* 月次レポートの月えらび（期間の切り替えと同じ行に並べる） */

.an-page .an-inline {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0;
}

.an-page .an-select {
  font-size: 12.5px;
  padding: 4px 7px;
  border: 1px solid var(--an-line);
  border-radius: 6px;
  background: var(--an-surface);
  color: var(--an-ink);
}
