/* ==========================================================================
   Cross Cart Seller Hub — light theme, faithful to Cross Cart Dashboard
   (~/dev/want/cross-cart-dashboard/app/static/Dashboard.html).

   Same DOM vocabulary / CSS variable names as Dashboard (.sidebar, .sb-*,
   .page-head, .kpi*, .panel*, .rank*, .tabs, .chart-*) so the two apps read
   as one design system. Dashboard's tokens default to a *light* root and
   only override to dark via `:root[data-theme="dark"]` — Seller Hub simply
   never applies that override, so this file hard-codes the light values
   Dashboard itself ships as defaults (see Dashboard.html lines ~28-55).
   Built on top of colors_and_type.css (shared, already identical to
   Dashboard's copy).
   ========================================================================== */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: var(--cc-font-sans);
  background: var(--surface-2);
  color: var(--ink-1);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

:root {
  /* ---------- Surfaces (Dashboard's light-root defaults) ---------- */
  /* 背景はほぼ白、わずかに生成り寄り（温かみ）。カードは白のまま */
  --surface-1: #ffffff;
  --surface-2: #fefefd;
  --surface-3: #f8f8f6;
  --surface-4: #eeeeeb;
  --hairline: #e7e7e4;
  --hairline-soft: #f1f1ef;
  --ink-1: var(--cc-fg-main);
  --ink-2: var(--cc-fg-sub);
  --ink-3: var(--cc-fg-muted);
  --ink-faint: var(--cc-fg-faint);
  --shadow-card: var(--cc-shadow-card);
  --shadow-hover: var(--cc-shadow-hover);

  /* Seller Hub のアクセント = ネオンオレンジ（Dashboard=白 / Ops Hub=紫 と見分ける）。
     生成り寄りの背景に合わせて暖色にした */
  --lane: #FF7A1A;
  --lane-light: rgba(255, 122, 26, 0.08);
  --lane-border: rgba(255, 122, 26, 0.20);

  /* Trend semantics — identical tokens/colors to Dashboard's KPI delta pill
     (lime "up", danger-red "down"; not a generic green). */
  --accent-up: #84CC16;
  --accent-up-bg: rgba(132,204,22,0.10);
  --accent-warn: #FBBF24;
  --accent-warn-bg: rgba(251,191,36,0.12);

  --pad-card: 22px;
  --pad-tile: 20px;
  --gap: 16px;
}

/* ============================================================
   APP SHELL — sidebar + main, matches Dashboard's .app grid
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
  padding: 16px;
  gap: 16px;
}

/* ---------- Sidebar — floating white card ---------- */
.sidebar {
  background: var(--surface-1);
  color: var(--ink-1);
  display: flex; flex-direction: column;
  position: sticky; top: 16px;
  height: calc(100vh - 32px);
  border: 1px solid var(--tool-border);
  border-radius: var(--cc-r-2xl);
  box-shadow: var(--shadow-card), 0 0 22px var(--tool-glow);
  overflow: hidden;
}
/* ツール色: Dashboard=白 / Ops Hub=紫 / Seller Hub=ネオンオレンジ。Seller Hub はショップ向けなので
   ツール名は黒文字・枠は他のカードと同じグレーにし、アクセント（--lane）のオレンジで見分ける */
:root {
  --tool-border: var(--hairline);
  --tool-glow: transparent;
}
.sb-brand {
  padding: 20px 20px 18px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 0;
  border-bottom: 1px solid var(--hairline-soft);
}
/* ロゴ: 上に小さく SELLER（アクセントのオレンジ）、大きく Hub（黒）、下に Cross Cart。
   Hub には色や囲みを付けない（大きさだけで見せる） */
.sb-brand-pre {
  font-size: 10px; font-weight: 700; letter-spacing: 0.28em; line-height: 1;
  text-transform: uppercase; color: var(--lane);
  margin-bottom: 3px;
}
.sb-brand-tag {
  font-size: 34px; font-weight: 500; letter-spacing: -0.03em; line-height: 0.95;
  color: var(--ink-1);
}
.sb-brand img { height: 8px; opacity: 0.55; margin-top: 7px; }

.sb-section { padding: 16px 12px 6px; }
.sb-section-label {
  font-size: 9px; font-weight: 500; letter-spacing: 0.15em;
  text-transform: uppercase; color: var(--ink-3);
  padding: 0 10px 8px;
}
.sb-nav { display: flex; flex-direction: column; gap: 1px; }
.sb-link {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px;
  font-size: 13px; font-weight: 500;
  color: var(--ink-2);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s var(--cc-ease);
  position: relative;
}
.sb-link svg { width: 16px; height: 16px; stroke-width: 1.7; flex-shrink: 0; opacity: 0.85; }
.sb-link:hover { background: var(--surface-3); color: var(--ink-1); }
.sb-link.active {
  background: var(--lane-light);
  color: var(--lane);
  font-weight: 400;
}
.sb-link.active svg { opacity: 1; }
.sb-link.active::before {
  content: "";
  position: absolute; left: -12px; top: 8px; bottom: 8px;
  width: 3px; background: var(--lane);
  border-radius: 0 3px 3px 0;
}

.sb-footer {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--hairline-soft);
  background: var(--surface-3);
}
.sb-user {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px; border-radius: 8px;
}
.sb-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--lane); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 400; letter-spacing: 0.02em;
  flex-shrink: 0;
}
.sb-user-text { display: flex; flex-direction: column; min-width: 0; }
.sb-user-name {
  font-size: 12px; font-weight: 400; color: var(--ink-1); line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sb-user-role {
  font-size: 10px; color: var(--ink-3); font-weight: 500; line-height: 1.2;
  margin-top: 2px;
}
.sb-logout {
  display: flex; align-items: center; gap: 8px;
  margin-top: 4px; padding: 8px 8px;
  font-size: 12px; color: var(--ink-3);
  border-radius: 6px;
  transition: background 0.15s var(--cc-ease), color 0.15s var(--cc-ease);
}
.sb-logout:hover { background: var(--surface-1); color: var(--ink-1); }
.sb-logout svg { width: 14px; height: 14px; stroke-width: 1.7; opacity: 0.85; flex-shrink: 0; }

/* ---------- Main content ---------- */
.main { padding: 20px 4px 32px 4px; width: 100%; }
/* Consistent vertical rhythm between top-level cards. Bare `.panel` sections
   (国・地域別 / 購入ファネル / 月次推移 / 新規vsリピート / 商品 …) had no
   bottom margin of their own, so adjacent cards touched. Scoped to `.main`'s
   DIRECT-child sections so panels nested inside a `.row` grid (which handle
   their own spacing via the grid gap) are never double-spaced. */
.main > section { margin-bottom: var(--gap); }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 20px; margin-bottom: 24px; flex-wrap: wrap;
}
.page-head-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.page-title { font-size: 28px; font-weight: 400; letter-spacing: -0.02em; }
.page-sub { font-size: 13px; color: var(--ink-2); margin-top: 4px; }
.page-actions { display: flex; align-items: center; gap: 10px; }

/* ---------- Segmented tabs (period switch, chart metric tabs) ---------- */
.tabs { display: inline-flex; gap: 2px; background: var(--surface-3); border-radius: 8px; padding: 3px; }
.tabs button {
  padding: 5px 10px; font-size: 11px; font-weight: 500;
  color: var(--ink-2); background: transparent; border: none;
  border-radius: 5px; cursor: pointer;
  transition: all 0.2s var(--cc-ease);
}
.tabs button.active { background: var(--surface-1); color: var(--ink-1); box-shadow: 0 1px 2px rgba(0,0,0,0.04); }

/* ============================================================
   KPI CARDS — same structure as Dashboard: label / value / delta pill
   ============================================================ */
.kpi-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: var(--gap); margin-bottom: var(--gap);
}
.kpi {
  background:
    linear-gradient(180deg, color-mix(in oklch, var(--surface-3) 55%, transparent) 0%, transparent 70%),
    var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--cc-r-xl);
  padding: var(--pad-tile);
  box-shadow: var(--shadow-card);
  position: relative;
  transition: all 0.3s var(--cc-ease);
  overflow: hidden;
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); border-color: var(--ink-3); }
.kpi-head { margin-bottom: 14px; }
.kpi-label { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; color: var(--ink-1); }
.kpi-label-note { display: block; font-size: 11px; font-weight: 400; color: var(--ink-3); margin-top: 2px; }
.kpi-value {
  font-size: 30px; font-weight: 400; letter-spacing: -1.5px;
  line-height: 1.1; font-variant-numeric: tabular-nums;
  color: var(--ink-1);
  display: flex; align-items: baseline; gap: 4px;
}
.kpi-value .unit { font-size: 14px; font-weight: 400; color: var(--ink-3); letter-spacing: 0; }
.kpi-value .prefix { font-size: 15px; font-weight: 400; color: var(--ink-3); letter-spacing: 0; }
.kpi-foot {
  margin-top: 10px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
}
.kpi-delta {
  display: inline-flex; align-items: center; gap: 2px;
  font-size: 11px; font-weight: 400;
  padding: 2px 7px; border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.kpi-delta.up   { background: var(--accent-up-bg); color: var(--accent-up); }
.kpi-delta.down { background: rgba(220,38,38,0.06); color: var(--cc-danger); }
.kpi-delta.flat { background: var(--surface-3); color: var(--ink-3); }
.kpi-delta svg { width: 10px; height: 10px; stroke-width: 2.5; }
.kpi-period { font-size: 10px; color: var(--ink-3); font-weight: 500; }

/* ============================================================
   PANELS / ROWS — same grid + card chrome as Dashboard
   ============================================================ */
.row { display: grid; gap: var(--gap); margin-bottom: var(--gap); }
.row.r-chart { grid-template-columns: 2fr 1fr; }
.row.r-split { grid-template-columns: 1fr 1fr; align-items: start; }
.row.r-chart > .panel { height: 340px; }

/* Full-width order-trend panel (moved out of the r-split row so it isn't
   squeezed next to the country ranking anymore — see summary.html).
   Height trimmed ~20% from its previous 360px so the chart draws in a
   ~200-240px band (panel chrome — the shared 64px .panel-head plus the
   chart-container's own 14px vertical padding — accounts for the rest.) */
.panel-trend { height: 296px; margin-bottom: var(--gap); }

.panel {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--cc-r-2xl);
  box-shadow: var(--shadow-card);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 18px var(--pad-card) 14px;
  min-height: 64px;
  border-radius: var(--cc-r-2xl) var(--cc-r-2xl) 0 0;
}
.panel-title-wrap { display: flex; align-items: center; }
/* Panel titles carry a short lane-colored accent bar (Dashboard's section-
   heading cue) so they read as structural headings, distinct from the plain
   KPI labels (配送先国数 etc.) that otherwise share the same weight/size. */
.panel-title {
  font-size: 15px; font-weight: 600; letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 9px;
}
.panel-title::before {
  content: ""; flex: 0 0 auto;
  width: 4px; height: 15px; border-radius: 2px;
  background: var(--lane);
}
.panel-sub { font-size: 11px; color: var(--ink-3); font-weight: 500; margin-top: 2px; }
.panel-body { padding: var(--pad-card); flex: 1; }

/* ---------- Loading feedback for period changes ----------
   A slow /api/summary (BigQuery cache miss) used to change nothing on screen
   for a beat. While a fetch is in flight we dim the data regions and float a
   spinner centered over the content column. Toggled via body.is-loading; the
   spinner is only shown after a short delay in JS so fast (cached) responses
   don't flash it. */
.cc-loading {
  position: fixed; top: 0; bottom: 0; left: 248px; right: 0;
  display: none; align-items: center; justify-content: center;
  pointer-events: none; z-index: 50;
}
body.is-loading .cc-loading { display: flex; }
.cc-spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid var(--surface-4); border-top-color: var(--lane);
  animation: cc-spin 0.7s linear infinite;
}
@keyframes cc-spin { to { transform: rotate(360deg); } }
.kpi-grid, .panel-trend, #funnelSection, #monthlySection, #buyers, #accessBody, #productsBody { transition: opacity 0.15s var(--cc-ease); }
body.is-loading .kpi-grid,
body.is-loading .panel-trend,
body.is-loading #funnelSection,
body.is-loading #monthlySection,
body.is-loading #buyers,
body.is-loading #newRepeatSection,
body.is-loading #purchaseFreqSection,
body.is-loading #accessBody,
body.is-loading #productsBody { opacity: 0.45; pointer-events: none; }
@media (max-width: 860px) { .cc-loading { left: 0; } }

/* ---------- Line Chart ---------- */
.chart-container {
  position: relative;
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
  padding: 10px 6px 4px;
}
.line-chart { width: 100%; height: 100%; display: block; }
.chart-hover-line {
  stroke: var(--lane); stroke-width: 1; stroke-dasharray: 3 3;
  opacity: 0.5; pointer-events: none;
}
.chart-hover-dot {
  fill: var(--lane); stroke: var(--surface-1); stroke-width: 2.5;
  pointer-events: none;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.15));
}
.chart-tooltip {
  position: absolute; pointer-events: none;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--cc-r-md);
  padding: 8px 12px;
  font-size: 12px; line-height: 1.4;
  box-shadow: var(--shadow-hover);
  white-space: nowrap;
  transform: translate(-50%, calc(-100% - 12px));
  z-index: 10;
}
.chart-tooltip[hidden] { display: none; }
.chart-tooltip .tt-date { font-weight: 700; color: var(--ink-1); margin-bottom: 4px; }
.chart-tooltip .tt-val  { color: var(--lane); font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
.chart-tooltip .tt-sub  { color: var(--ink-2); font-weight: 500; font-size: 11px; margin-top: 2px; font-variant-numeric: tabular-nums; }

/* ---------- Stacked bar chart (購入ファネル) — shares the .chart-*
   vocabulary with the line chart above; only the marks differ. ---------- */
.bar-chart { width: 100%; height: 100%; display: block; }
.bar-chart .seg-orders { fill: var(--lane); }
.bar-chart .seg-visits { fill: var(--surface-4); }
.bar-hover-band { fill: var(--lane); opacity: 0.06; pointer-events: none; }

/* ============================================================
   購入ファネル — 最上部の全幅ブロック（2ステップ + 積み上げ棒）
   ============================================================ */
.panel-funnel { margin-bottom: var(--gap); }
.funnel-legend { display: flex; align-items: center; gap: 14px; font-size: 11px; color: var(--ink-3); font-weight: 500; }
.funnel-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.funnel-legend .lg { width: 10px; height: 10px; border-radius: 2px; display: inline-block; flex-shrink: 0; }
.funnel-legend .lg-orders { background: var(--lane); }
.funnel-legend .lg-visits { background: var(--surface-4); }

.funnel-steps { display: flex; align-items: stretch; gap: 12px; margin-bottom: 6px; }
.funnel-step {
  flex: 1 1 0; min-width: 0;
  background:
    linear-gradient(180deg, color-mix(in oklch, var(--surface-3) 55%, transparent) 0%, transparent 70%),
    var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--cc-r-xl);
  padding: 16px 18px;
}
.funnel-step-label { font-size: 13px; font-weight: 600; color: var(--ink-1); display: flex; align-items: center; gap: 8px; }
.funnel-step-no {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--lane-light); color: var(--lane);
  font-size: 11px; font-weight: 600; flex-shrink: 0;
}
.funnel-step-value {
  margin-top: 12px;
  font-size: 30px; font-weight: 400; letter-spacing: -1.5px; line-height: 1.1;
  font-variant-numeric: tabular-nums; color: var(--ink-1);
  display: flex; align-items: baseline; gap: 4px;
}
.funnel-step-value .unit { font-size: 14px; font-weight: 400; color: var(--ink-3); letter-spacing: 0; }
.funnel-conv {
  flex: 0 0 auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 0 8px; text-align: center;
}
.funnel-arrow-svg { width: 22px; height: 22px; stroke-width: 1.7; color: var(--ink-3); margin-bottom: 4px; }
.funnel-conv-label { font-size: 10px; color: var(--ink-3); font-weight: 500; letter-spacing: 0.04em; }
.funnel-conv-value { font-size: 18px; font-weight: 500; color: var(--lane); font-variant-numeric: tabular-nums; }
.funnel-chart-container { flex: none; height: 216px; }

/* 購入者の購入回数分布 — same single-block layout as the 新規vsリピート panel;
   the histogram reuses the .bar-chart marks (single lane series). */
.panel-freq { margin-bottom: var(--gap); }
.freq-chart-container { flex: none; height: 216px; }
@media (max-width: 860px) {
  .funnel-steps { flex-direction: column; }
  .funnel-conv { flex-direction: row; gap: 8px; padding: 4px 0; }
  .funnel-arrow-svg { transform: rotate(90deg); margin-bottom: 0; }
}

/* ============================================================
   RANK (horizontal bar list) — country rankings, matches
   Dashboard's .rank / .rank-row exactly
   ============================================================ */
.rank { display: flex; flex-direction: column; gap: 10px; }
.rank-row { display: grid; grid-template-columns: 24px 1fr 88px; align-items: center; gap: 10px; }
.rank-no { font-size: 10px; font-weight: 400; color: var(--ink-3); letter-spacing: 0.05em; font-variant-numeric: tabular-nums; }
.rank-body { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.rank-head-row { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 400; color: var(--ink-1); min-width: 0; }
.rank-head-row .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.flag-img {
  width: 20px; aspect-ratio: 3 / 2; height: auto;
  object-fit: cover; display: block; border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.12);
}
.rank-bar { height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.rank-bar > i { display: block; height: 100%; background: var(--lane); border-radius: 3px; transition: width 0.6s var(--cc-ease); }
.rank-val { font-size: 12px; font-weight: 400; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rank-val .sub { font-size: 10px; color: var(--ink-3); font-weight: 400; display: block; }
.rank-val .pct { font-size: 10px; color: var(--ink-2); font-weight: 500; }
.rank-empty { padding: 24px 12px; color: var(--ink-3); font-size: 13px; text-align: center; }

/* ============================================================
   PRODUCT TABLE — 商品ページ (商品 / 販売数 / 売上 / アクセス数).
   Shares the card chrome from .panel; the table itself reuses the
   hairline/ink/lane tokens so it reads as part of the same system.
   ============================================================ */
.prod-table-wrap { width: 100%; overflow-x: auto; }
.prod-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.prod-table th, .prod-table td {
  padding: 12px 10px; border-bottom: 1px solid var(--hairline-soft);
  text-align: left; vertical-align: middle;
}
.prod-table thead th {
  font-size: 11px; font-weight: 600; color: var(--ink-3);
  letter-spacing: 0.02em; border-bottom: 1px solid var(--hairline);
  white-space: nowrap;
}
.prod-table tbody tr:last-child td { border-bottom: none; }
.prod-table tbody tr { transition: background 0.15s var(--cc-ease); }
.prod-table tbody tr:hover { background: var(--surface-2); }
.prod-th-num, .prod-num { text-align: right; white-space: nowrap; }
.prod-num { font-size: 13px; color: var(--ink-1); }
.prod-num .prod-unit { font-size: 10px; color: var(--ink-3); margin-left: 2px; }
.prod-num .prod-yen { font-size: 11px; color: var(--ink-3); margin-right: 1px; }
.prod-access { color: var(--ink-1); }
.prod-cvr { color: var(--ink-1); font-variant-numeric: tabular-nums; }
.prod-pending { font-size: 11px; color: var(--ink-3); }
.prod-cell-main { min-width: 0; width: 100%; }
.prod-link {
  display: flex; align-items: center; gap: 12px;
  color: var(--ink-1); text-decoration: none; min-width: 0;
}
a.prod-link:hover .prod-name { color: var(--lane); text-decoration: underline; }
.prod-thumb {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: var(--cc-r-lg);
  background: var(--surface-3); overflow: hidden;
  box-shadow: 0 0 0 1px var(--hairline) inset;
}
.prod-thumb-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.prod-name {
  font-size: 13px; color: var(--ink-1); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.prod-empty { padding: 28px 12px; color: var(--ink-3); font-size: 13px; text-align: center; }
/* 月次推移 table (アクセス page) — reuses .prod-table chrome; the 月 column is
   a plain label rather than the 商品 page's thumbnail+link cell. */
.monthly-month { font-size: 13px; font-weight: 500; color: var(--ink-1); white-space: nowrap; }
@media (max-width: 860px) {
  .prod-table th, .prod-table td { padding: 10px 6px; }
  .prod-thumb { width: 34px; height: 34px; }
}

/* ============================================================
   国・地域別 — one panel, two-column body: world-map choropleth (left,
   ~60%) + country ranking list (right, ~40%). The ranking column's
   max-height is set by syncGeoRankColHeight() in app.js to whichever is
   taller: the map column's rendered height, or the space needed to show
   the first 10 ranked rows in full (measured from the actual rendered
   row heights, not a hardcoded pixel guess) — so at least #1–#10 are
   always visible without scrolling, and the map stays top-aligned
   (align-items: flex-start below) even when the ranking column grows
   past the map's height. 11th+ rows scroll within the column. Falls
   back to a single stacked column at ≤860px (same breakpoint as the
   sidebar drawer).
   ============================================================ */
.geo-body { display: flex; gap: var(--gap); align-items: stretch; }
/* Map column is a flex column so the map block (.geo-map-inner) can center
   vertically in whatever height the taller ranking column dictates — any
   leftover space splits evenly above/below the map instead of pooling as one
   dead gap beneath it. */
.geo-map-col { position: relative; flex: 5 1 0%; min-width: 0; display: flex; flex-direction: column; }
/* 配送先国数 — KPI-card-style figure (reuses .kpi-label/.kpi-value so its
   typography always tracks the top KPI cards) sitting above the map,
   inside its own inner wrapper (see .geo-map-inner) so the map/legend/
   tooltip's own coordinate space is unaffected. */
.geo-count { margin-bottom: 16px; }
.geo-count .kpi-value { margin-top: 6px; }
.geo-map-inner { position: relative; margin-block: auto; }
.geo-rank-col {
  flex: 5 1 0%;
  min-width: 0;
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-width: thin;
}
.geo-rank-col::-webkit-scrollbar { width: 6px; }
.geo-rank-col::-webkit-scrollbar-track { background: transparent; }
.geo-rank-col::-webkit-scrollbar-thumb { background: var(--surface-4); border-radius: 3px; }
.geo-rank-col::-webkit-scrollbar-thumb:hover { background: var(--ink-3); }

/* ---------- World map — SVG choropleth of buyer shipping countries
   (app/static/assets/world-map.svg, injected inline by app.js so
   individual <path>/<g> elements can be colored/queried at runtime;
   see attribution + provenance comment inside that file). ---------- */
.map-svg-wrap {
  width: 100%;
  aspect-ratio: 2752.766 / 1200; /* matches world-map.svg's cropped viewBox */
  display: block;
}
.map-svg-wrap svg { width: 100%; height: 100%; display: block; }
.map-svg-wrap .landxx,
.map-svg-wrap .coastxx { cursor: default; transition: filter 0.15s var(--cc-ease); }
.map-svg-wrap [data-has-orders="true"] { cursor: pointer; }
.map-svg-wrap [data-has-orders="true"]:hover { filter: brightness(0.92); }

/* Order-volume dot markers, positioned/sized by app.js via getBBox() —
   subtle pulse draws the eye to the top destination countries. */
.map-marker {
  fill: var(--lane);
  stroke: var(--surface-1);
  stroke-width: 1.5;
  pointer-events: none;
}
.map-marker-pulse {
  fill: none;
  stroke: var(--lane);
  stroke-width: 1.5;
  opacity: 0.55;
  pointer-events: none;
  animation: cc-map-pulse 2.2s var(--cc-ease) infinite;
  transform-box: fill-box;
  transform-origin: center;
}
@keyframes cc-map-pulse {
  0%   { transform: scale(1);   opacity: 0.55; }
  70%  { transform: scale(2.2); opacity: 0; }
  100% { transform: scale(2.2); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .map-marker-pulse { animation: none; opacity: 0; }
}

.map-legend {
  position: absolute; bottom: 8px; left: 8px;
  display: flex; align-items: center; gap: 6px;
  font-size: 10px; color: var(--ink-3); font-weight: 500;
  background: color-mix(in oklch, var(--surface-1) 92%, transparent);
  padding: 5px 8px; border-radius: 6px;
  border: 1px solid var(--hairline);
  pointer-events: none;
}
.map-legend .scale {
  width: 80px; height: 6px; border-radius: 3px;
  background: linear-gradient(to right, var(--surface-4), var(--lane));
}
.map-tooltip { transform: translate(-50%, calc(-100% - 14px)); }
.map-tooltip .tt-sub { color: var(--ink-2); font-size: 11px; margin-top: 2px; }

/* Typographic calm — numbers & headlines lean light, matches Dashboard's
   global weight overrides (Dashboard.html ~L1598-1608, ~L1727-1729). */
.kpi-value, .kpi-value .prefix, .kpi-value .unit,
.page-title, h1, h2, h3,
.rank-val, .kpi-delta { font-weight: 400 !important; }
.sb-section-label,
.sb-link.active, .tabs button.active { font-weight: 500 !important; }
/* Card header emphasis — panel titles and KPI labels read as the
   strongest text in their card now that .panel-head no longer has a
   background/border-bottom to set them apart (see .panel-head above). */
.kpi-label, .panel-title { font-weight: 600 !important; }

/* ============================================================
   AUTH PAGES (login / change-password) — Dashboard's centered
   ambient-grid card, flipped to light.
   ============================================================ */
.auth-body {
  min-height: 100vh;
  display: flex; flex-direction: column;
  position: relative; overflow: hidden;
  background: var(--surface-2);
}
.bg-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(0,0,0,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,0,0,0.025) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 70% 70% at 50% 50%, black 30%, transparent 90%);
  -webkit-mask-image: radial-gradient(ellipse 70% 70% at 50% 50%, black 30%, transparent 90%);
  pointer-events: none;
}
.auth-main {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  position: relative; z-index: 2;
}
.auth-card {
  width: 100%; max-width: 360px;
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
  animation: cc-fade-up 0.55s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes cc-fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.auth-logo {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  margin-bottom: 40px;
}
.auth-logo img { height: 18px; opacity: 0.95; }
.auth-logo .tag {
  font-size: 10px; font-weight: 500;
  letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--ink-3);
}
.auth-title { font-size: 18px; font-weight: 700; margin-bottom: 8px; color: var(--ink-1); }
.auth-lede { font-size: 13px; color: var(--ink-2); margin-bottom: 12px; }

.auth-form {
  width: 100%;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--cc-r-2xl);
  box-shadow: var(--shadow-card);
  padding: 28px 24px;
  display: flex; flex-direction: column; gap: 4px;
  text-align: left;
}
.auth-label { font-size: 11px; font-weight: 600; color: var(--ink-3); margin-top: 14px; }
.auth-label:first-child { margin-top: 0; }
.auth-input {
  width: 100%; margin-top: 6px; padding: 11px 12px;
  border: 1px solid var(--hairline);
  border-radius: var(--cc-r-lg);
  background: var(--surface-1);
  color: var(--ink-1);
  font-size: 14px; font-family: inherit;
  transition: border-color 0.2s var(--cc-ease), box-shadow 0.2s var(--cc-ease);
}
.auth-input:focus { outline: none; border-color: var(--lane); box-shadow: 0 0 0 3px var(--lane-light); }
.auth-submit { margin-top: 20px; width: 100%; }
.auth-help { margin-top: 18px; font-size: 12px; color: var(--ink-3); }

.btn-primary {
  display: flex; align-items: center; justify-content: center;
  width: 100%; padding: 13px 18px;
  background: var(--lane); color: #fff;
  border: none; border-radius: var(--cc-r-lg);
  font-family: inherit; font-size: 14px; font-weight: 500;
  cursor: pointer;
  transition: transform 0.2s var(--cc-ease), box-shadow 0.25s var(--cc-ease), opacity 0.2s var(--cc-ease);
  box-shadow: 0 4px 14px rgba(255, 122, 26, 0.28);
}
.btn-primary:hover { transform: translateY(-1px); opacity: 0.94; }
.btn-primary:active { transform: translateY(0); }

.err {
  width: 100%; margin-top: 18px; padding: 10px 12px;
  background: rgba(220,38,38,0.05); border: 1px solid rgba(220,38,38,0.18);
  color: var(--cc-danger); border-radius: 8px;
  font-size: 12px; line-height: 1.5; text-align: left;
}

/* ============================================================
   Responsive — mobile drawer (mirrors Dashboard's ≤860px behavior)
   ============================================================ */
.menu-toggle { display: none; }
@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .row.r-chart, .row.r-split { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; padding: 12px; gap: 12px; }
  .main { padding: 12px 4px 32px; }

  /* 国・地域別 — map + ranking stack vertically instead of side-by-side;
     the ranking list drops its map-height scroll clamp and simply flows
     full-height under the map (syncGeoRankColHeight() in app.js also
     no-ops in this width range). */
  .geo-body { flex-direction: column; }
  .geo-rank-col { max-height: none !important; overflow: visible; padding-right: 0; }

  .menu-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; margin-left: -10px;
    background: none; border: none; padding: 0;
    color: var(--ink-1); cursor: pointer; border-radius: 50%;
    flex-shrink: 0;
    transition: background 0.2s var(--cc-ease);
  }
  .menu-toggle:hover { background: var(--surface-3); }
  .menu-toggle .hb-bars { position: relative; width: 18px; height: 12px; display: block; }
  .menu-toggle .hb-bar {
    position: absolute; left: 0; right: 0; height: 1.5px;
    background: currentColor; border-radius: 2px;
    transition: top 0.2s var(--cc-ease), transform 0.25s var(--cc-ease) 0.05s;
  }
  .menu-toggle .hb-bar:nth-child(1) { top: 3px; }
  .menu-toggle .hb-bar:nth-child(2) { top: 9px; }
  .menu-toggle[aria-expanded="true"] .hb-bar:nth-child(1) { top: 6px; transform: rotate(45deg); }
  .menu-toggle[aria-expanded="true"] .hb-bar:nth-child(2) { top: 6px; transform: rotate(-45deg); }

  .sidebar {
    position: fixed; top: 0; left: 0;
    width: min(280px, 80vw); height: 100vh;
    margin: 0; border-radius: 0;
    transform: translateX(-100%);
    transition: transform 0.25s var(--cc-ease);
    z-index: 110;
  }
  .sidebar[data-drawer="open"] { transform: translateX(0); }

  /* Large yen amounts can outgrow a 2-col card at phone widths — shrink
     the numeral before it clips against the card edge. */
  .kpi-value { font-size: 24px; letter-spacing: -1px; flex-wrap: wrap; }

  .drawer-backdrop {
    display: block; position: fixed; inset: 0;
    background: rgba(0,0,0,0.35);
    opacity: 0; pointer-events: none;
    transition: opacity 0.2s var(--cc-ease);
    z-index: 105;
  }
  .drawer-backdrop[data-drawer="open"] { opacity: 1; pointer-events: auto; }
  body[data-drawer-open="true"] { overflow: hidden; }
}
.drawer-backdrop { display: none; }
