/* ============================================================
 * dashboard.css
 * --------------------------------------------------------------
 * 役割: PC レイアウト全般
 *   - ヘッダーアクション（フィルタトグル・ログアウト）
 *   - フィルターバー / Pull-to-refresh インジケータ / 遮光オーバーレイ
 *   - KPI カード / グリッド / パネル
 *   - 稼働場所ランキング（横棒バー）
 *   - 人別ランキング（レベルバッジ・バー着色・sticky 合計行）
 *   - 選択人物の推移グラフ / レベル分布ファネル
 *   - カレンダー（5段階ヒートマップ）/ コメントテーブル / Sankey / ドーナツ
 *   - ローディング / ステータスバー
 * 依存: base.css
 * 元: ui/index.html L251-615
 * ============================================================ */

.header-actions { display: flex; gap: 8px; align-items: center; }

/* フィルタボタン：メニューオープン時にサッと消える */
.btn-filter-toggle { display: inline-flex; align-items: center; gap: 6px; height: 36px; background: transparent; border: 1px solid rgba(255,255,255,0.4); color: #fff; padding: 0 12px; border-radius: 8px; font-size: 12px; font-weight: 600; cursor: pointer; transform-origin: right center; transition: background 0.15s, border-color 0.15s, opacity 0.18s ease, transform 0.2s cubic-bezier(0.23,1,0.32,1); }
.btn-filter-toggle.overlay-hidden { opacity: 0; transform: scaleX(0.6) translateX(8px); pointer-events: none; }
.btn-filter-toggle:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.6); }
.btn-filter-toggle.active { background: #6c69b4; border-color: #6c69b4; }
.btn-filter-toggle .material-symbols-outlined { font-size: 18px; }

/* マイページオーバーレイ（ヘッダー直下から全画面） */
.account-overlay { position: fixed; top: var(--header-h); left: 0; right: 0; bottom: 0; z-index: 60; background: #f0f0f0; overflow-y: auto; -webkit-overflow-scrolling: touch; transform: translateY(10px); opacity: 0; pointer-events: none; transition: transform 0.2s cubic-bezier(0.23,1,0.32,1), opacity 0.18s ease; }
.account-overlay.active { transform: translateY(0); opacity: 1; pointer-events: auto; }

/* ハンバーガー → X アニメーション（dashboard のみ） */
.btn-menu.active .btn-menu-bar:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
.btn-menu.active .btn-menu-bar:nth-child(2) { opacity: 0; transform: scaleX(0); }
.btn-menu.active .btn-menu-bar:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }
.btn .material-symbols-outlined { font-size: 16px; }
.btn-refresh .material-symbols-outlined { font-size: 16px; }
.btn-capture .material-symbols-outlined { font-size: 16px; }

/* フィルターバー（ヘッダーのトグルで開閉・ヘッダーに追従） */
.filter-bar { background: #e8e8e8; border-bottom: 1px solid #ccc; padding: 10px 20px; display: flex; flex-direction: column; gap: 8px; align-items: stretch; box-shadow: 0 4px 12px rgba(0,0,0,0.08); border-radius: 0 0 14px 14px; overflow: hidden; transform-origin: top center; max-height: 800px; opacity: 1; transition: max-height 0.32s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.22s ease, transform 0.32s cubic-bezier(0.22, 1, 0.36, 1), padding 0.32s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.22s ease, border-bottom-width 0.22s ease; }
.filter-bar.collapsed { max-height: 0; opacity: 0; transform: translateY(-10px); padding-top: 0; padding-bottom: 0; border-bottom-width: 0; box-shadow: none; pointer-events: none; }

/* ダッシュボード遮光（フィルタ開いてる間だけ） */
.filter-backdrop { position: fixed; inset: 0; background: rgba(17, 24, 39, 0.32); z-index: 30; opacity: 0; pointer-events: none; transition: opacity 0.22s ease; }
.filter-backdrop.active { opacity: 1; pointer-events: auto; }

/* Pull-to-refresh インジケータ（モバイル：ページ最上部で下フリック→更新） */
#pull-refresh-indicator { position: fixed; top: 8px; left: 50%; width: 40px; height: 40px; border-radius: 50%; background: #fff; box-shadow: 0 4px 14px rgba(0,0,0,0.18); display: flex; align-items: center; justify-content: center; z-index: 10000; opacity: 0; pointer-events: none; color: #6c69b4; transform: translate(-50%, -60px); }
#pull-refresh-indicator.ready { background: #6c69b4; color: #fff; }
#pull-refresh-indicator .material-symbols-outlined { font-size: 22px; font-variation-settings: 'FILL' 0, 'wght' 600; }
.filter-row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; justify-content: center; }
/* 適用・リセット行：右寄せ */
.filter-row-actions { justify-content: flex-end; width: 100%; }
.filter-field { display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; }
.filter-label { font-size: 12px; color: #555; font-weight: 600; }
.filter-bar select { background: #fff; border: 1px solid #bbb; color: #333; padding: 4px 8px; border-radius: 3px; font-size: 12px; cursor: pointer; min-width: 130px; }
.filter-bar select:focus { outline: none; border-color: #6c69b4; box-shadow: 0 0 0 2px rgba(108,105,180,0.18); }
.btn { padding: 4px 14px; border-radius: 3px; font-size: 12px; font-weight: 600; cursor: pointer; border: none; display: inline-flex; align-items: center; gap: 4px; }
.btn-primary { background: #6c69b4; color: #fff; }
.btn-primary:hover { background: #55529a; }
.btn-ghost { background: #fff; color: #555; border: 1px solid #bbb; }
.btn-ghost:hover { background: #f0f0f0; }
.btn-refresh { background: #fff; color: #555; border: 1px solid #999; }
.btn-refresh:hover { background: #f5f5f5; border-color: #666; }
.btn-refresh:disabled { color: #bbb; border-color: #ddd; cursor: not-allowed; background: #fafafa; }
.btn-capture { background: #fff; color: #555; border: 1px solid #999; }
.btn-capture:hover { background: #f5f5f5; border-color: #666; }
.btn-capture:disabled { color: #bbb; border-color: #ddd; cursor: not-allowed; background: #fafafa; }

/* 更新情報（フィルタ内に移動） */
.filter-row-update { justify-content: flex-end; gap: 10px; padding-top: 6px; border-top: 1px dashed #ccc; width: 100%; }
.filter-row-update .updated { font-size: 11px; color: #666; }

/* メインレイアウト */
.container { padding: 16px 20px; max-width: 1200px; margin: 0 auto; }

/* ポジショントグル（KPI上・大きめタブ） */
.position-toggle-wrap { display: flex; justify-content: center; margin: 0 auto 10px; }
.position-toggle { display: inline-flex; background: #fff; border: 1px solid #ddd; border-radius: 999px; padding: 3px; gap: 2px; box-shadow: 0 1px 2px rgba(0,0,0,0.04); }
.position-toggle button { border: none; background: transparent; color: #6b7280; padding: 7px 22px; border-radius: 999px; cursor: pointer; font-weight: 700; font-size: 13px; letter-spacing: 0.04em; transition: all 0.18s; }
.position-toggle button.active { background: #6c69b4; color: #fff; box-shadow: 0 1px 2px rgba(108,105,180,0.3); }
/* キャッチャー選択時はドーナツ・Sankey 非表示 */
body.position-catcher #donut-panel,
body.position-catcher #sankey-panel { display: none !important; }
/* サンキー（獲得経路）パネルは一時非表示（練り直しのため） */
#sankey-panel { display: none !important; }

/* KPI カード（横幅を縮める） */
.kpi-row { display: grid; grid-template-columns: repeat(3, minmax(0, 200px)); gap: 12px; margin: 0 auto 14px; justify-content: center; }
.kpi-card { background: #fff; border: 1px solid #ddd; border-radius: 4px; padding: 12px 16px; text-align: center; }
.kpi-card .label { font-size: 11px; color: #888; font-weight: 600; margin-bottom: 4px; }
.kpi-card .value { font-size: 32px; font-weight: 700; color: #222; line-height: 1; }

/* グリッド */
.grid-main   { display: grid; grid-template-columns: 1fr 320px; gap: 14px; margin-bottom: 14px; }
.grid-bottom { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }

/* パネル */
.panel { background: #fff; border: 1px solid #ddd; border-radius: 4px; padding: 14px 16px; }
.panel-title { font-size: 11px; font-weight: 700; color: #555; background: #f5f5f5; border-left: 3px solid #6c69b4; padding: 4px 8px; margin-bottom: 12px; letter-spacing: 0.04em; }
.panel-subtitle { font-size: 11px; color: #999; font-weight: 500; }

/* スクロールエリア（スクロール発生時のみバー表示・非発生時は全幅使用） */
.scroll-area { max-height: 320px; overflow-y: auto; }
/* 人別ランキングはヘッダー+合計行+15行分の高さ */
.scroll-area--person { max-height: 500px; }
.scroll-area::-webkit-scrollbar { width: 8px; }
.scroll-area::-webkit-scrollbar-track { background: #f5f5f5; border-radius: 4px; }
.scroll-area::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }
.scroll-area::-webkit-scrollbar-thumb:hover { background: #aaa; }

/* フィルタ中バッジ（プレーンテキスト） */
.filter-status-badge { display: inline-block; margin-left: 10px; padding: 0 4px; font-size: 11px; font-weight: 600; color: #6c69b4; letter-spacing: 0.02em; vertical-align: baseline; }

/* 稼働場所ランキング（縦積み：名前1行フル幅・下にバー＋件数） */
.loc-row { display: flex; flex-direction: column; gap: 4px; padding: 8px 0; border-bottom: 1px solid #f5f5f5; }
.loc-row:last-child { border-bottom: none; }
.loc-row.clickable { cursor: pointer; transition: background 0.12s; }
@media (hover: hover) and (pointer: fine) {
  .loc-row.clickable:hover { background: #f5f4fb; }
}
.loc-row.selected .loc-name { font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.loc-row.selected .loc-count { font-weight: 700; }
.loc-name { color: #333; line-height: 1.35; width: 100%; white-space: nowrap; overflow: hidden; display: block; transform-origin: left center; font-size: 12px; }
.loc-meta { display: flex; align-items: center; gap: 8px; }
.loc-bar-wrap { flex: 1; background: #e8e8e8; border-radius: 2px; height: 10px; }
.loc-bar { height: 10px; border-radius: 2px; background: #6c69b4; }
.loc-count { font-size: 12px; font-weight: 700; color: #333; white-space: nowrap; }

/* 人別ランキングテーブル（列幅固定） */
.person-table { width: 100%; border-collapse: collapse; font-size: 12px; table-layout: fixed; }
/* sticky thead: border-bottom はスクロール時に隙間から文字列が透けるため box-shadow で内側に描く */
.person-table th { background: #f5f5f5; border-bottom: 0; box-shadow: inset 0 -2px 0 #ddd; padding: 5px 8px; text-align: right; color: #666; font-weight: 600; position: sticky; top: 0; height: 28px; z-index: 2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-table thead tr.head-row th:first-child,
.person-table thead tr.head-row th:nth-child(2),
.person-table thead tr.head-row th:nth-child(3) { text-align: left; }
/* 合計行（ヘッダー直下・sticky・隙間なし） */
.person-table thead tr.total-row th { background: #fafafa; color: #333; font-weight: 700; border-bottom: 0; box-shadow: inset 0 -1px 0 #e5e5e5; text-align: right; padding: 5px 8px; position: sticky; top: 28px; height: 28px; z-index: 1; }
.person-table thead tr.total-row th.col-rank,
.person-table thead tr.total-row th.col-name { text-align: left; color: #555; }
.person-table thead tr.total-row th.col-bar { padding: 5px 4px; }
/* 合計行の数値は body 行の col-value と 1 桁目位置をそろえる */
.person-table thead tr.total-row th.col-value { padding-right: 20px; }
.person-table thead tr.total-row .person-bar-wrap { background: #e8e8e8; border-radius: 2px; height: 10px; }
.person-table thead tr.total-row .person-bar { height: 10px; border-radius: 2px; background: #6c69b4; width: 100%; }
/* 合計行バー: レベル別人数スタック（上位%分布） */
.level-stack-bar { display: flex; height: 10px; width: 100%; border-radius: 2px; overflow: hidden; background: var(--level-1); }
.level-stack-bar .seg { height: 100%; min-width: 0; transition: width .6s ease; }
.level-stack-bar .seg.lv4 { background: var(--level-4); }
.level-stack-bar .seg.lv3 { background: var(--level-3); }
.level-stack-bar .seg.lv2 { background: var(--level-2); }
.level-stack-bar .seg.lv1 { background: var(--level-1); }
.level-stack-legend { display: inline-flex; gap: 6px; font-size: 10px; color: #666; font-weight: 500; margin-left: 6px; vertical-align: middle; }
.level-stack-legend .swatch { display: inline-block; width: 8px; height: 8px; border-radius: 1px; margin-right: 2px; vertical-align: middle; }
/* クロスフィルタ時のラベル拡張（合計 + % or 中央値比） */
.total-label-wrap { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.total-label-extra { font-size: 10px; color: #6c69b4; font-weight: 700; white-space: nowrap; }
.total-label-extra.below { color: #d48442; }
/* 過去月履歴行（選択氏名の直下に階層表示） */
.person-table tbody tr.history-row td { background: #fafafa; color: #888; font-size: 11px; font-weight: 500; padding-top: 3px; padding-bottom: 3px; cursor: default; }
.person-table tbody tr.history-row td.col-rank { color: transparent; }
.person-table tbody tr.history-row td.col-name { padding-left: 18px; color: #666; }
.person-table tbody tr.history-row td.col-work,
.person-table tbody tr.history-row td.col-count,
.person-table tbody tr.history-row td.col-seisan { color: #444; font-weight: 600; }
.person-table tbody tr.history-row:hover td { background: #fafafa; }
/* 当月ハイライト（対象期間で絞ってる月を薄紫で） */
.person-table tbody tr.history-row.current-month td { background: #eeecfa; color: #4a3fa0; }
.person-table tbody tr.history-row.current-month td.col-name { color: #4a3fa0; font-weight: 700; }
/* 選択人物行のメトリクス別パーセンタイル & トレンド矢印 */
.cell-val-wrap { display: inline-flex; align-items: baseline; gap: 3px; justify-content: flex-end; width: 100%; }
.cell-sub { display: block; font-size: 9px; color: #9090a5; font-weight: 500; margin-top: 1px; letter-spacing: 0.02em; }
.cell-sub.percentile-top { color: #6c69b4; }
.trend-arrow { font-size: 10px; font-weight: 700; letter-spacing: 0; }
.trend-arrow.up { color: #4a9f4a; }
.trend-arrow.down { color: #d14e4e; }
.trend-arrow.flat { color: #999; }
/* 選択中はスクロール枠を緩和（履歴 12 行 + 対象 1 行 + ヘッダー 2 行 ≒ 380px） */
.scroll-area--person.has-history { max-height: 380px; }
.person-table td { padding: 5px 8px; border-bottom: 1px solid #f0f0f0; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-table td:first-child,
.person-table td:nth-child(2),
.person-table td:nth-child(3) { text-align: left; }
.person-table tr:last-child td { border-bottom: none; }
/* 人名行はクリック可能（クロスフィルタ） */
.person-table tbody tr.clickable { cursor: pointer; transition: background 0.12s; }
@media (hover: hover) and (pointer: fine) {
  .person-table tbody tr.clickable:hover td { background: #f5f4fb; }
}
/* 選択中のハイライト着色は行わない。太字＋下線で控えめに示す */
.person-table tbody tr.selected td { font-weight: 700; vertical-align: middle; }
.person-table tbody tr.selected td.col-name { text-decoration: none; }
.person-table tbody tr.selected td.col-name .person-name-label { text-decoration: underline; text-underline-offset: 3px; font-weight: 700; }
.person-table tbody tr.selected td.col-bar { padding: 5px 4px !important; }
.person-table tbody tr.selected td.col-work,
.person-table tbody tr.selected td.col-count,
.person-table tbody tr.selected td.col-seisan { white-space: normal; overflow: visible; text-overflow: clip; }
/* 2行スタック（「上位」小 + N% 大） — 狭いセル幅に対応 */
.pct-stacked { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; }
.pct-stacked .pct-lbl { font-size: 9px; color: #9694b8; font-weight: 600; letter-spacing: 0.02em; white-space: nowrap; }
.pct-stacked .pct-val { font-size: 11.5px; color: #6c69b4; font-weight: 700; white-space: nowrap; }
/* レベルバッジ（選択行の各メトリクスに表示） */
.lv-badge { display: inline-flex; align-items: baseline; gap: 2px; padding: 2px 5px; border-radius: 4px; font-weight: 700; font-size: 10.5px; line-height: 1.2; white-space: nowrap; }
.lv-badge.lv4 { background: var(--level-4); color: #fff; }
.lv-badge.lv3 { background: var(--level-3); color: #fff; }
.lv-badge.lv2 { background: var(--level-2); color: #2a2a5a; }
.lv-badge.lv1 { background: var(--level-1); color: #555; }
.lv-badge.lv-none { background: transparent; color: #bbb; font-weight: 500; }
.lv-badge .lv-lbl { font-size: 9px; font-weight: 500; opacity: 0.85; letter-spacing: 0.02em; }
/* パネル凡例（固定表示・右寄せ） */
.panel-legend { display: flex; justify-content: flex-end; flex-wrap: nowrap; align-items: center; gap: 8px; padding: 6px 12px; font-size: 10px; color: #666; font-weight: 600; overflow-x: auto; }
.panel-legend .legend-item { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; line-height: 1; margin-bottom: 0; }
.panel-legend .legend-item em { font-style: normal; color: #999; font-weight: 500; margin-left: 2px; }
.panel-legend .legend-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.panel-legend .legend-swatch.lv4 { background: var(--level-4); }
.panel-legend .legend-swatch.lv3 { background: var(--level-3); }
.panel-legend .legend-swatch.lv2 { background: var(--level-2); }
.panel-legend .legend-swatch.lv1 { background: var(--level-1); }
/* 総合上位ラベル（氏名の右セル） */
.total-pct-inline { display: flex; align-items: center; gap: 4px; }
.total-pct-inline .pct-stacked { align-items: flex-start; flex-shrink: 0; }
/* 平均Lv バッジの外出し「平均」ラベル（バッジ左横にはみ出させる） */
.lv-avg-prefix { font-size: 9px; color: #666; font-weight: 600; letter-spacing: 0.02em; margin-right: 4px; white-space: nowrap; flex-shrink: 0; }
/* 選択行の col-bar は 50px しかなく平均バッジが見切れるため、左方向へオーバーフローを許可 */
.person-table.cross-filter tbody tr.selected td.col-bar { overflow: visible; }
.person-table.cross-filter tbody tr.selected .total-pct-inline { margin-left: -80px; white-space: nowrap; }

/* 選択人物の推移グラフパネル（常時表示・メトリクス切替式） */
.person-graph-wrap { display: block; padding: 14px; background: #fff; border: 1px solid #e5e5e5; border-radius: 6px; margin-top: 10px; margin-bottom: 10px; }
.graph-metric-toggle { display: flex; gap: 2px; background: #f3f4f6; border-radius: 999px; padding: 2px; }
.graph-metric-toggle button { flex: 1; border: none; background: transparent; color: #6b7280; padding: 5px 10px; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: 11px; transition: all 0.15s; }
.graph-metric-toggle button.active { background: #6c69b4; color: #fff; box-shadow: 0 1px 2px rgba(108,105,180,0.25); }
/* グラフモード/指標トグル2段 */
.graph-toggle-row { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.graph-mode-toggle { display: inline-flex; background: #37359a22; border-radius: 999px; padding: 2px; gap: 2px; }
.graph-mode-toggle button { border: none; background: transparent; color: #37359a; padding: 4px 12px; border-radius: 999px; cursor: pointer; font-weight: 700; font-size: 11px; transition: all 0.15s; }
.graph-mode-toggle button.active { background: #37359a; color: #fff; box-shadow: 0 1px 2px rgba(55,53,154,0.3); }
/* グラフコンテンツのフェードイン */
.graph-content { animation: graphFadeIn .25s ease; }
@keyframes graphFadeIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
.graph-main { position: relative; }
.graph-main svg { display: block; width: 100%; height: 140px; }
.graph-x-labels { display: flex; justify-content: space-between; margin-top: 4px; font-size: 10px; color: #888; padding: 0 2px; }
.graph-latest { margin-top: 6px; text-align: right; font-size: 11px; color: #6c69b4; font-weight: 700; }
.graph-latest .period-avg { margin-left: 10px; color: #37359a; }
.graph-latest .period-avg::before { content: '／'; color: #bbb; font-weight: 400; margin-right: 8px; }
/* レベル分布ファネル（折れ線の下） */
.funnel-wrap { margin-top: 14px; padding: 12px 10px 0; border-top: 1px dashed #e0e0e0; }
.funnel-title { font-size: 11px; color: #666; font-weight: 600; margin-bottom: 8px; text-align: left; }
.funnel-chart { width: 100%; border-collapse: collapse; table-layout: fixed; }
.funnel-chart td { border: none; padding: 3px 0; vertical-align: middle; }
.funnel-label-cell { width: 72px; text-align: right; padding-right: 10px !important; font-size: 10px; color: #666; font-weight: 600; white-space: nowrap; vertical-align: middle; }
.funnel-label-top { font-weight: 600; color: #555; }
.funnel-label-count { font-weight: 500; color: #888; }
.funnel-bar-cell { text-align: center; }
/* ファネルのバー: Lv.N が中央、チェックマークは Lv.N の左にオーバーレイ配置 */
.funnel-bar { display: inline-flex; align-items: center; justify-content: center; height: 26px; border-radius: 4px; padding: 0 10px; position: relative; }
.funnel-bar.lv4 { background: var(--level-4); color: #fff; }
.funnel-bar.lv3 { background: var(--level-3); color: #fff; }
.funnel-bar.lv2 { background: var(--level-2); color: #2a2a5a; }
.funnel-bar.lv1 { background: var(--level-1); color: #555; }
.funnel-lv { font-size: 12px; font-weight: 700; line-height: 1; letter-spacing: 0.02em; position: relative; }
.funnel-lv .funnel-self-icon { position: absolute; right: calc(100% + 4px); top: 50%; transform: translateY(-50%); }
.funnel-self-icon { font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24; color: #65c000; font-size: 17px !important; line-height: 1; }
.graph-legend { display: flex; gap: 14px; justify-content: center; margin-top: 6px; font-size: 10px; color: #666; }
.graph-legend .swatch { display: inline-block; width: 14px; height: 2px; vertical-align: middle; margin-right: 4px; }
.graph-legend .swatch.person { background: #6c69b4; height: 2px; }
.graph-legend .swatch.median { background: transparent; border-top: 2px dashed #aaa; height: 0; }
.viz-person-line { fill: none; stroke: #6c69b4; stroke-width: 1.8; }
.viz-median-line { fill: none; stroke: #aaa; stroke-dasharray: 3,2; stroke-width: 1.2; }
.viz-axis-line { stroke: #ddd; stroke-width: 1; }
.viz-point-last { fill: #6c69b4; }
.person-table .col-rank  { width: 34px; padding-right: 4px; }
.person-table .col-name  { width: 130px; }
.person-table .col-bar   { width: calc((100% - 164px) / 2); }
.person-table .col-work  { width: 60px; }
.person-table .col-count { width: 52px; }
.person-table .col-seisan{ width: 52px; }
.person-table .col-value { width: calc((100% - 164px) / 2); text-align: right; padding-right: 20px; font-weight: 700; color: #333; }
/* 氏名セル内のバッジ付き名前レイアウト */
.person-name-cell { display: flex; align-items: center; gap: 4px; min-width: 0; }
.person-name-cell .name-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 0 0 5.5em; max-width: 5.5em; }
/* クロスフィルタ時の全指標列幅 */
.person-table.cross-filter .col-bar { width: 50px; min-width: 50px; }
.person-table.cross-filter tbody tr:not(.selected) .person-bar-wrap,
.person-table.cross-filter thead tr.total-row .level-stack-bar { width: 100%; }
.person-table.cross-filter .col-work { width: 44px; min-width: 44px; }
.person-table.cross-filter .col-count { width: 38px; min-width: 38px; }
.person-table.cross-filter .col-seisan { width: 38px; min-width: 38px; }
/* Lv.ミニバッジ（バー左横） */
.person-bar-lvwrap { display: flex; align-items: center; gap: 4px; }
.lv-mini { font-size: 9px; font-weight: 700; padding: 1px 4px; border-radius: 3px; white-space: nowrap; flex-shrink: 0; }
.lv-mini.lv4 { background: var(--level-4); color: #fff; }
.lv-mini.lv3 { background: var(--level-3); color: #fff; }
.lv-mini.lv2 { background: var(--level-2); color: #2a2a5a; }
.lv-mini.lv1 { background: var(--level-1); color: #555; }
/* バー着色（レベルカラー） */
.person-bar.lv4 { background: var(--level-4); }
.person-bar.lv3 { background: var(--level-3); }
.person-bar.lv2 { background: var(--level-2); }
.person-bar.lv1 { background: var(--level-1); }
/* バー幅統一: col-bar セル幅いっぱいに広げる（iPhone 各幅でもバランス維持） */
.person-table tbody tr:not(.selected) .person-bar-wrap { width: 100%; }
.person-table thead tr.total-row .level-stack-bar { width: 100%; }
.person-table .rank { color: #aaa; }
.bar-cell { padding: 5px 4px !important; }
.person-bar-wrap { background: #e8e8e8; border-radius: 2px; height: 10px; }
.person-bar { height: 10px; border-radius: 2px; background: #6c69b4; }
/* 件数・生産は同じフォントカラー */
.person-table .count-val,
.person-table .seisan-val { font-weight: 700; color: #333; }

/* カレンダー（月曜始まり・マス高さ統一） */
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-header { font-size: 10px; color: #888; text-align: center; padding: 3px 0; font-weight: 600; }
.cal-header.sat { color: #4a7fc1; }
.cal-header.sun { color: #c14a4a; }
.cal-day { background: #fafafa; border: 1px solid #eee; border-radius: 2px; padding: 4px 3px; text-align: center; height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.cal-day.empty { background: transparent; border-color: transparent; }
.cal-day .day-num { font-size: 10px; color: #bbb; }
/* 5段階ヒートマップ（グレー #e8e8e8 → ブルー #37359a グラデ） */
.cal-day.lv1 { background: #e8e8e8; border-color: #d8d8d8; }
.cal-day.lv1 .day-num { color: #555; font-weight: 600; }
.cal-day.lv1 .day-count { color: #6c69b4; }
.cal-day.lv2 { background: #c4c3d7; border-color: #b3b2cb; }
.cal-day.lv2 .day-num { color: #333; font-weight: 700; }
.cal-day.lv2 .day-count { color: #55529a; }
.cal-day.lv3 { background: #9f9ec4; border-color: #8d8cb6; }
.cal-day.lv3 .day-num { color: #fff; font-weight: 700; text-shadow: 0 1px 1px rgba(0,0,0,0.22); }
.cal-day.lv3 .day-count { color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.18); }
.cal-day.lv4 { background: #6c69b4; border-color: #5854a4; }
.cal-day.lv4 .day-num { color: #fff; font-weight: 700; text-shadow: 0 1px 1px rgba(0,0,0,0.26); }
.cal-day.lv4 .day-count { color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.2); }
.cal-day.lv5 { background: #37359a; border-color: #2a2880; }
.cal-day.lv5 .day-num { color: #fff; font-weight: 700; text-shadow: 0 1px 1px rgba(0,0,0,0.3); }
.cal-day.lv5 .day-count { color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.25); }
.cal-day .day-count { font-size: 17px; font-weight: 700; color: #555; margin-top: 2px; }
/* クリック可能な日付（opacity初期0、JS + RAFで段階表示） */
.cal-day.has-data { cursor: pointer; transition: transform 0.1s, box-shadow 0.1s; }
@media (hover: hover) and (pointer: fine) {
  .cal-day.has-data:hover { transform: translateY(-1px); box-shadow: 0 2px 6px rgba(0,0,0,0.15); }
}
.cal-day.has-data:focus { outline: none; }
.cal-day.has-data:focus-visible { outline: 2px dashed #6c69b4; outline-offset: 1px; }
.cal-day.selected { background: #fddc03 !important; border-color: transparent !important; box-shadow: none !important; z-index: 2; position: relative; }
.cal-day.selected .day-num,
.cal-day.selected .day-count { color: #414141 !important; text-shadow: none !important; }

/* コメントテーブル */
.comment-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.comment-table th { background: #f5f5f5; border-bottom: 2px solid #ddd; padding: 5px 8px; text-align: center; color: #666; font-weight: 600; position: sticky; top: 0; z-index: 1; }
.comment-table td { padding: 5px 8px; border-bottom: 1px solid #f0f0f0; vertical-align: top; }
.comment-table tr:last-child td { border-bottom: none; }
.comment-date { color: #333; white-space: nowrap; font-size: 12px; }
.comment-name { color: #333; white-space: nowrap; }
.comment-text { color: #333; }

/* Sankey（獲得経路） */
#sankey-chart-wrap { position: relative; width: 100%; height: 260px; padding: 4px 0 0; }
#sankey-chart { display: block; }

/* ドーナツ（左右バランス: 円と凡例を中央に対称配置） */
#carrier-chart-wrap { display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 18px; padding: 8px 0; flex-wrap: wrap; }
#carrier-chart-box { width: 170px; height: 170px; flex-shrink: 0; position: relative; }
#carrier-chart { display: block; }
#carrier-legend { font-size: 11px; color: #555; display: flex; flex-direction: column; justify-content: center; flex-shrink: 0; min-width: 0; gap: 6px; }
.legend-group { display: flex; flex-direction: column; gap: 2px; }
.legend-parent { display: flex; align-items: center; gap: 6px; font-weight: 700; color: #333; white-space: nowrap; }
.legend-child { display: flex; align-items: center; gap: 6px; padding-left: 14px; white-space: nowrap; color: #666; }
.legend-item { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; white-space: nowrap; }
.legend-item:last-child { margin-bottom: 0; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; border: 1px solid rgba(0,0,0,0.08); }

/* ドーナツ表示モード切替（件/%） */
.chart-toggle-group { display: inline-flex; align-items: center; gap: 6px; }
.chart-toggle-label { font-size: 10px; color: #888; font-weight: 600; letter-spacing: 0.02em; }
.chart-toggle { display: inline-flex; background: #f3f4f6; border-radius: 999px; padding: 2px; gap: 2px; font-size: 11px; font-weight: 600; }
.chart-toggle button { border: none; background: transparent; color: #6b7280; padding: 4px 12px; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: 11px; transition: all 0.15s; }
.chart-toggle button.active { background: #6c69b4; color: #fff; box-shadow: 0 1px 2px rgba(108,105,180,0.25); }
.panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 8px; flex-wrap: wrap; }
.panel-header .panel-title { margin-bottom: 0; }
.panel-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.person-close-btn { border: none; background: transparent; color: #999; font-size: 16px; cursor: pointer; padding: 2px 6px; border-radius: 4px; line-height: 1; transition: color .15s; }
.person-close-btn:hover { color: #333; }

/* クロスフィルタ解除時の「ふわっと戻る」演出（×閉じ → 全体表示復帰）
   translateY を使わず opacity のみ — transform だとスクロール位置がビクビクする */
.cross-reset-fade { animation: crossResetFade .38s ease; }
@keyframes crossResetFade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
/* ソートトグル（稼働・件数・生産）の出現フェード */
.sort-toggle-fade-in { animation: crossResetFade .28s ease; }

/* ローディング */
.loading { text-align: center; padding: 32px; color: #aaa; font-size: 13px; }
.loading-spinner { display: inline-block; width: 20px; height: 20px; border: 2px solid #ddd; border-top-color: #e07b39; border-radius: 50%; animation: spin 0.8s linear infinite; margin-right: 8px; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ステータス */
.status-bar { padding: 5px 20px; font-size: 10px; color: #aaa; border-top: 1px solid #ddd; text-align: right; background: #f8f8f8; }
