/* FJ Group 経営ダッシュボード - Modern SaaS Design */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Noto+Sans+JP:wght@300;400;500;600;700&display=swap');

:root {
    --bg: #f8f9fb;
    --bg-card: #ffffff;
    --bg-sidebar: #0f172a;
    --bg-hover: #f1f5f9;
    --text: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --accent: #6366f1;
    --accent-light: #eef2ff;
    --accent-green: #10b981;
    --accent-red: #ef4444;
    --accent-orange: #f59e0b;
    --accent-purple: #8b5cf6;
    --accent-cyan: #06b6d4;
    --accent-blue: #3b82f6;
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);
    --radius: 12px;
    --radius-sm: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ===== サイドバー ===== */
.sidebar {
    width: 240px;
    background: var(--bg-sidebar);
    color: #e2e8f0;
    padding: 1.5rem 0;
    position: fixed;
    height: 100vh;
    z-index: 100;
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255,255,255,0.06);
}

.sidebar-header {
    padding: 0 1.5rem 2rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 0.5rem;
}

.logo {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 14px;
    color: #fff;
    flex-shrink: 0;
}

.logo-text {
    font-size: 15px;
    font-weight: 700;
    color: #f1f5f9;
    letter-spacing: -0.3px;
}

.nav-menu { list-style: none; flex: 1; padding: 0.5rem 0; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1.5rem;
    cursor: pointer;
    color: #94a3b8;
    font-size: 13.5px;
    font-weight: 500;
    transition: all 0.15s ease;
    border-left: 3px solid transparent;
    margin: 1px 0;
}

.nav-item:hover { background: rgba(255,255,255,0.05); color: #cbd5e1; }
.nav-item.active { color: #fff; background: rgba(99,102,241,0.12); border-left-color: #6366f1; font-weight: 600; }

/* ===== メインコンテンツ ===== */
.main-content {
    margin-left: 240px;
    flex: 1;
    padding: 1.5rem 2rem;
    min-height: 100vh;
    max-width: calc(100% - 240px);
    min-width: 0;  /* flex子要素でoverflowを有効にする */
    box-sizing: border-box;
}

/* ===== ヘッダー ===== */
.top-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.top-header h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.5px;
}

.month-select, .store-select {
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    color: var(--text);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.15s;
}

.month-select:focus, .store-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }

/* ===== ページ切替 ===== */
.page { display: none; }
.page.active { display: block; }

/* ===== KPIグリッド ===== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 0.875rem;
    margin-bottom: 1.5rem;
}

.kpi-grid-8 { grid-template-columns: repeat(4, 1fr); }
@media (min-width: 1400px) { .kpi-grid-8 { grid-template-columns: repeat(8, 1fr); } }

.kpi-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.125rem 1.25rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 3px;
    background: var(--accent-blue);
}

.kpi-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.kpi-label { font-size: 11.5px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 0.375rem; }
.kpi-value { font-size: 22px; font-weight: 800; color: var(--text); letter-spacing: -0.5px; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 0.25rem; }

/* KPIカラー */
.gradient-blue::before { background: var(--accent-blue); }
.gradient-purple::before { background: var(--accent-purple); }
.gradient-green::before { background: var(--accent-green); }
.gradient-orange::before { background: var(--accent-orange); }
.gradient-red::before { background: var(--accent-red); }
.gradient-cyan::before { background: var(--accent-cyan); }
.gradient-purple { background: linear-gradient(135deg, #7c3aed 0%, #a78bfa 100%); color: #fff; }
.gradient-purple .kpi-label, .gradient-purple .kpi-value, .gradient-purple .kpi-sub { color: #fff; }
.gradient-purple::before { background: rgba(255,255,255,0.3); }
.gradient-cyan { background: linear-gradient(135deg, #0891b2 0%, #22d3ee 100%); color: #fff; }
.gradient-cyan .kpi-label, .gradient-cyan .kpi-value, .gradient-cyan .kpi-sub { color: #fff; }
.gradient-cyan::before { background: rgba(255,255,255,0.3); }

/* ===== セクションタイトル ===== */
.section-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    margin: 0.5rem 0 1rem;
    padding-left: 0.75rem;
    border-left: 3px solid var(--accent);
}

/* ===== 店舗KPIカード ===== */
.store-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 0.875rem;
    margin-bottom: 1.5rem;
}

.store-kpi-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    cursor: pointer;
    transition: all 0.2s ease;
    border-top: 3px solid #94a3b8;
}

.store-kpi-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.store-kpi-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.375rem; }
.store-kpi-name { font-size: 13px; font-weight: 700; }
.store-kpi-main { font-size: 20px; font-weight: 800; color: var(--text); margin-bottom: 0.5rem; letter-spacing: -0.5px; }
.store-kpi-pct { font-size: 11px; font-weight: 600; color: var(--text-muted); background: var(--bg); padding: 2px 8px; border-radius: 10px; }
.store-kpi-body { display: grid; grid-template-columns: 1fr 1fr; gap: 0.2rem 0.75rem; }
.store-kpi-item { display: flex; justify-content: space-between; font-size: 12px; }
.skpi-label { color: var(--text-muted); }
.skpi-value { font-weight: 600; color: var(--text-secondary); font-variant-numeric: tabular-nums; }

/* ===== テキストカラー ===== */
.text-green { color: var(--accent-green) !important; }
.text-red { color: var(--accent-red) !important; }
.text-yellow { color: var(--accent-orange) !important; }

/* ===== チャート ===== */
.chart-row { display: grid; grid-template-columns: 1.5fr 1fr; gap: 1rem; margin-bottom: 1.5rem; }
/* グリッド子は min-width:auto 既定のため canvas 固有幅以下に縮まず、
   1280px幅で横スクロールが発生していた (chart-pie はみ出し問題) */
.chart-row > .chart-card { min-width: 0; }

.chart-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    position: relative;
}
.chart-card canvas { max-height: 280px; max-width: 100%; }

.chart-card.large { grid-column: span 1; }
.chart-card.small { grid-column: span 1; }
.chart-card h3 { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 0.75rem; }

/* ===== テーブルカード ===== */
.table-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    overflow-x: auto;
    margin-bottom: 1rem;
}

.table-card h3 {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 1rem;
}

/* ===== データテーブル ===== */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; white-space: nowrap; }

.data-table th {
    text-align: left;
    padding: 0.6rem 0.75rem;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}

.data-table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-secondary);
}

.data-table td.num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
.data-table td.store-name { font-weight: 600; cursor: pointer; text-align: left !important; }
.data-table td.store-name:hover { color: var(--accent); }
.data-table tr:hover { background: var(--bg-hover); }

/* ===== 目標 vs 実績 ===== */
.target-overview { display: flex; gap: 1.5rem; align-items: center; padding: 0.75rem 0 0.5rem; flex-wrap: wrap; }
.target-progress-wrap { flex: 2; min-width: 300px; }
.target-progress-label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 0.5rem; color: var(--text-secondary); font-weight: 500; }
.target-stats { display: flex; gap: 1.5rem; flex: 1; }
.target-stat { text-align: center; min-width: 80px; }
.ts-label { display: block; font-size: 10px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.ts-value { display: block; font-size: 17px; font-weight: 800; color: var(--text); letter-spacing: -0.3px; }
.ts-sub { display: block; font-size: 10px; color: var(--text-muted); font-weight: 500; }

/* プログレスバー */
.progress-bar { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 4px; transition: width 0.8s ease; }

/* 凡例 */
.color-legend { display: flex; gap: 1rem; padding: 0.5rem 0; font-size: 11px; color: var(--text-muted); font-weight: 500; }
.legend-item { display: flex; align-items: center; gap: 0.3rem; }
.legend-dot { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* ===== 経営サマリー ===== */
.exec-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.875rem;
}

@media (min-width: 1400px) {
    .exec-grid { grid-template-columns: repeat(3, 1fr); }
    /* 前月同日比較は広めに（2カラム分） */
    .exec-grid .exec-block-wide { grid-column: span 1; }
}

/* 前月同日比較カード: 増減列を強調 */
.exec-block-wide .exec-table th:last-child,
.exec-block-wide .exec-table td:last-child {
    min-width: 140px;
}

.exec-block {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 1rem 1.125rem;
    border: 1px solid var(--border);
}

.exec-block h4 {
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--accent);
}

.exec-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.exec-table th {
    background: transparent;
    padding: 0.25rem 0.5rem;
    text-align: right;
    font-weight: 700;
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}
.exec-table th:first-child { text-align: left; }
.exec-table td { padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--border-light); }
.exec-table td.label { font-weight: 600; color: var(--text-secondary); font-size: 12px; white-space: nowrap; }
.exec-table td.num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text); }

/* ===== ストアセレクタ ===== */
.store-selector-bar { margin-bottom: 1rem; }
.clickable { cursor: pointer; }
.clickable:hover { text-decoration: underline; }

/* ===== ヒートマップ ===== */
.heatmap-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.heatmap-table th { text-align: center; padding: 0.5rem 0.4rem; font-size: 11px; font-weight: 700; color: var(--text-muted); border-bottom: 1px solid var(--border); white-space: nowrap; text-transform: uppercase; }
.heatmap-table td { padding: 0.375rem 0.3rem; }
.heatmap-table td:first-child { text-align: left; font-weight: 600; padding-left: 0.5rem; white-space: nowrap; }
.hm-cell { text-align: center; font-variant-numeric: tabular-nums; font-weight: 500; border-radius: 4px; transition: all 0.15s ease; }
.hm-cell:hover { transform: scale(1.05); box-shadow: var(--shadow-sm); }
.hm-total td { font-weight: 700; border-top: 2px solid var(--border); color: var(--accent); }

/* ===== 相関チャート ===== */
.corr-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.5rem; }
.corr-card { background: var(--bg-card); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow-sm); border: 1px solid var(--border-light); height: 320px; }
.corr-card h3 { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 0.5rem; }

/* ===== キャスト稼働ダッシュボード ===== */
.cast-section { background: transparent; }
.cast-section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; gap: 0.75rem; flex-wrap: wrap; }
.cast-section-header h3 { font-size: 16px; font-weight: 700; color: var(--text); }
.cast-section-note { font-size: 12px; color: var(--text-muted); }

.cast-kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.75rem; margin-bottom: 1rem; }

.cast-lower-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 900px) { .cast-lower-grid { grid-template-columns: 1fr; } }

.cast-panel { background: var(--bg-card); border-radius: var(--radius); box-shadow: var(--shadow-sm); border: 1px solid var(--border-light); overflow: hidden; }
.cast-panel-header { display: flex; align-items: center; justify-content: space-between; padding: 0.75rem 1rem; border-bottom: 1px solid var(--border-light); gap: 0.5rem; flex-wrap: wrap; }
.cast-panel-header h4 { font-size: 13px; font-weight: 700; color: var(--text); }
.cast-panel-hint { font-size: 11px; color: var(--text-muted); }
.cast-panel-body { padding: 0.5rem; max-height: 420px; overflow-y: auto; }
.cast-empty { padding: 1rem; text-align: center; color: var(--text-muted); font-size: 12px; }

.cast-filter-bar { display: flex; gap: 0.5rem; align-items: center; }
.cast-search-input { padding: 0.35rem 0.6rem; border: 1px solid var(--border); border-radius: 6px; font-size: 12px; width: 140px; font-family: inherit; }
.cast-search-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-light); }
.cast-filter-clear-btn { padding: 0.35rem 0.7rem; border: 1px solid var(--border); border-radius: 6px; font-size: 11px; background: #fff; cursor: pointer; color: var(--text-secondary); font-family: inherit; }
.cast-filter-clear-btn:hover { background: var(--bg-hover); border-color: var(--accent); color: var(--accent); }
.cast-filter-count { font-size: 11px; color: var(--text-muted); margin-left: 0.25rem; }

/* ソータブルヘッダー */
.cast-table thead tr.sort-row th[data-sort] { cursor: pointer; user-select: none; position: relative; padding-right: 1.1rem; transition: background 0.1s; }
.cast-table thead tr.sort-row th[data-sort]:hover { background: var(--bg-hover); color: var(--text); }
.cast-table thead tr.sort-row th[data-sort]::after { content: '⇅'; position: absolute; right: 0.35rem; opacity: 0.3; font-size: 10px; }
.cast-table thead tr.sort-row th.sort-asc::after { content: '▲'; opacity: 1; color: var(--accent); font-size: 9px; }
.cast-table thead tr.sort-row th.sort-desc::after { content: '▼'; opacity: 1; color: var(--accent); font-size: 9px; }

/* 列フィルタ行 */
.cast-table thead tr.filter-row th { background: #f8fafc; border-bottom: 1px solid var(--border); padding: 0.25rem 0.3rem; position: sticky; top: 29px; z-index: 1; }
.cast-table .col-filter { width: 100%; max-width: 62px; padding: 0.2rem 0.4rem; font-size: 10.5px; border: 1px solid var(--border); border-radius: 4px; background: #fff; font-family: inherit; text-align: right; }
.cast-table .col-filter:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-light); }
.cast-table .col-filter::-webkit-outer-spin-button, .cast-table .col-filter::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ランカー行 */
.ranker-row { display: grid; grid-template-columns: 30px 1fr auto auto auto auto auto; align-items: center; gap: 0.4rem; padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--border-light); font-size: 12px; }
.ranker-row:last-child { border-bottom: none; }
.ranker-rank { font-weight: 700; text-align: center; color: var(--text-secondary); }
.ranker-name { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranker-grade { font-size: 10px; padding: 1px 6px; border-radius: 4px; background: #fef3c7; color: #92400e; font-weight: 600; }
.ranker-shukkin, .ranker-hon { color: var(--text-muted); font-size: 11px; }
.ranker-ratio { font-weight: 700; font-size: 11px; padding: 2px 6px; border-radius: 4px; }
.ratio-high { background: #d1fae5; color: #065f46; }
.ratio-mid { background: #fef3c7; color: #92400e; }
.ratio-low { background: #fee2e2; color: #991b1b; }
.ratio-zero { background: #f1f5f9; color: #64748b; }
.ranker-pt { font-weight: 700; color: #6366f1; font-size: 12px; min-width: 60px; text-align: right; }

/* 警戒リスト */
.warning-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--border-light); font-size: 12px; flex-wrap: wrap; }
.warning-row:last-child { border-bottom: none; }
.warning-name { font-weight: 600; color: var(--text); }
.warning-meta { color: var(--text-muted); font-size: 11px; margin-left: auto; }
.warning-meta strong { color: #dc2626; font-weight: 700; }

/* キャスト一覧テーブル */
.cast-table { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.cast-table thead { position: sticky; top: 0; background: var(--bg-card); z-index: 1; }
.cast-table th { padding: 0.45rem 0.6rem; text-align: left; font-weight: 700; color: var(--text-secondary); border-bottom: 2px solid var(--border); font-size: 11px; white-space: nowrap; }
.cast-table td { padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--border-light); color: var(--text); }
.cast-table tr:hover td { background: var(--bg-hover); }
/* 数値列のヘッダーも右寄せに揃える（4列目以降：出勤/本指名/総本数/本指率/来店/パネル/HP/オキニ/日記/欠勤/合計PT） */
.cast-table thead th:nth-child(n+4) { text-align: right; }
.cell-center { text-align: center; }
.cell-num { text-align: right; }
.cell-muted { color: var(--text-muted); }
.cell-warn { color: #dc2626; font-weight: 600; }
.ratio-badge { display: inline-block; padding: 1px 6px; border-radius: 4px; font-weight: 700; font-size: 11px; min-width: 42px; text-align: center; }

/* ===== AI OCR 経費入力 ===== */
.ocr-container { max-width: 1100px; }
.ocr-upload-area { border: 2px dashed #cbd5e1; border-radius: var(--radius); padding: 2.5rem; text-align: center; background: var(--bg-card); transition: all 0.3s; cursor: pointer; }
.ocr-upload-area:hover, .ocr-upload-area.drag-over { border-color: var(--accent); background: var(--accent-light); transform: translateY(-2px); box-shadow: 0 8px 25px rgba(99,102,241,0.15); }
.ocr-upload-area h3 { font-size: 1.1rem; font-weight: 600; color: var(--text); margin: 0.75rem 0 0.25rem; }
.ocr-upload-area p { font-size: 0.85rem; color: var(--text-muted); margin: 0; }
.btn-upload { margin-top: 1rem; padding: 0.6rem 1.8rem; background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; border: none; border-radius: var(--radius-sm); font-size: 0.9rem; font-weight: 600; cursor: pointer; transition: all 0.2s; }
.btn-upload:hover { transform: translateY(-1px); box-shadow: 0 4px 15px rgba(99,102,241,0.4); }
.ocr-status { display: flex; align-items: center; gap: 1rem; padding: 1.25rem; background: var(--accent-light); border-radius: var(--radius-sm); margin-top: 1rem; font-weight: 500; color: #4338ca; }
.spinner { width: 28px; height: 28px; border: 3px solid #c7d2fe; border-top-color: #6366f1; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.ocr-results { margin-top: 1.25rem; background: var(--bg-card); border-radius: var(--radius); box-shadow: var(--shadow-sm); border: 1px solid var(--border-light); overflow: hidden; }
.ocr-results-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.ocr-results-header h3 { font-size: 1rem; font-weight: 600; margin: 0; }
.btn-approve { padding: 0.5rem 1.2rem; background: linear-gradient(135deg, #10b981, #059669); color: #fff; border: none; border-radius: var(--radius-sm); font-size: 0.85rem; font-weight: 600; cursor: pointer; transition: all 0.2s; }
.btn-approve:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(16,185,129,0.3); }
.table-wrapper { overflow-x: auto; }
.ocr-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.ocr-table th { background: var(--bg); padding: 0.65rem 0.75rem; text-align: left; font-weight: 600; font-size: 0.8rem; color: var(--text-secondary); border-bottom: 1px solid var(--border); white-space: nowrap; }
.ocr-table td { padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border-light); color: var(--text); }
.ocr-table tr:hover td { background: var(--bg-hover); }
.ocr-table td.amount { font-variant-numeric: tabular-nums; text-align: right; font-weight: 600; }
.badge { padding: 0.2rem 0.5rem; border-radius: 4px; font-size: 0.75rem; font-weight: 600; }
.badge-high { background: #dcfce7; color: #166534; }
.badge-medium { background: #fef3c7; color: #92400e; }
.badge-low { background: #fee2e2; color: #991b1b; }
.badge-approved { background: #dbeafe; color: #1e40af; }
.badge-pending { background: #fef3c7; color: #92400e; }
.ocr-table select { padding: 0.3rem 0.5rem; border: 1px solid var(--border); border-radius: 6px; font-size: 0.8rem; background: #fff; cursor: pointer; }
.ocr-history { margin-top: 1.25rem; background: var(--bg-card); border-radius: var(--radius); box-shadow: var(--shadow-sm); border: 1px solid var(--border-light); padding: 1rem 1.25rem; }
.ocr-history h3 { font-size: 1rem; font-weight: 600; margin: 0 0 0.75rem; }
.text-right { text-align: right; font-variant-numeric: tabular-nums; }
.text-truncate { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reason-cell { max-width: 180px; font-size: 0.78rem; color: var(--text-secondary); }
.btn-approve-single { padding: 0.25rem 0.7rem; background: linear-gradient(135deg, #10b981, #059669); color: #fff; border: none; border-radius: 6px; font-size: 0.75rem; font-weight: 600; cursor: pointer; transition: all 0.2s; }
.btn-approve-single:hover { box-shadow: 0 2px 8px rgba(16,185,129,0.3); }
.btn-approve-single:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-edit-expense, .btn-delete-expense { padding: 0.2rem 0.5rem; border: none; border-radius: 4px; font-size: 0.85rem; cursor: pointer; transition: all 0.15s; background: transparent; }
.btn-edit-expense:hover { background: #dbeafe; }
.btn-delete-expense:hover { background: #fee2e2; }
.th-group { text-align: center; font-size: 0.85rem; padding: 0.4rem 0.5rem !important; border-bottom: 2px solid; }
.th-group-blue { background: #eff6ff; color: #1d4ed8; border-bottom-color: #3b82f6; }
.th-group-red { background: #fef2f2; color: #dc2626; border-bottom-color: #ef4444; }
.th-group-orange { background: #fff7ed; color: #c2410c; border-bottom-color: #f97316; }
.th-group-green { background: #f0fdf4; color: #15803d; border-bottom-color: #22c55e; }
.total-row { background: var(--bg); border-top: 2px solid var(--border); }
.total-row td { padding: 0.7rem 0.75rem !important; }

/* ===== ハンバーガーメニューボタン ===== */
.menu-toggle {
    display: none;
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 200;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--bg-sidebar);
    border: none;
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    box-shadow: var(--shadow-md);
}
.menu-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: #e2e8f0;
    border-radius: 2px;
    transition: all 0.3s;
}
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 90;
}

/* ===== 経費配賦ビュー ===== */
.alloc-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.875rem;
}

.alloc-kpi-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    transition: all 0.2s ease;
}
.alloc-kpi-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.alloc-kpi-grand { grid-column: span 1; border-top: 3px solid var(--accent); }
.alloc-kpi-fj { border-top: 3px solid var(--accent-orange); }

.alloc-kpi-icon { font-size: 1.5rem; flex-shrink: 0; margin-top: 2px; }
.alloc-kpi-body { flex: 1; min-width: 0; }
.alloc-kpi-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.alloc-kpi-value { font-size: 20px; font-weight: 800; color: var(--text); letter-spacing: -0.5px; font-variant-numeric: tabular-nums; }
.alloc-kpi-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.alloc-kpi-badges { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }

.alloc-badge { padding: 2px 8px; border-radius: 10px; font-size: 10px; font-weight: 700; letter-spacing: 0.3px; }
.alloc-badge-fixed { background: #dbeafe; color: #1e40af; }
.alloc-badge-variable { background: #fef3c7; color: #92400e; }

.alloc-table-card { overflow: visible; }
.alloc-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; gap: 0.75rem; }
.alloc-source-toggle { display: flex; align-items: center; gap: 0.75rem; }
.alloc-source-label { font-size: 13px; color: var(--text-secondary); }
.alloc-toolbar-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.alloc-section-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 0.75rem; }
.alloc-section-header h3 { margin: 0; }

.alloc-filter-bar { display: flex; gap: 4px; }
.alloc-filter-btn {
    padding: 0.3rem 0.9rem;
    border: 1px solid var(--border);
    background: var(--bg);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}
.alloc-filter-btn:hover { background: var(--bg-hover); border-color: var(--accent); }
.alloc-filter-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.alloc-matrix { font-size: 12px; }
.alloc-matrix th { text-align: center; font-size: 10px; padding: 0.5rem 0.4rem; white-space: nowrap; }
.alloc-cat-col { text-align: left !important; min-width: 120px; }
.alloc-type-col { text-align: center !important; min-width: 50px; }
.alloc-store-col { min-width: 52px; text-align: center; }
.alloc-total-col { min-width: 80px; text-align: right !important; background: #f0fdf4 !important; }
.alloc-fj-col { min-width: 70px; text-align: right !important; background: #fff7ed !important; }

.alloc-cat-name { font-weight: 600; color: var(--text); white-space: nowrap; font-size: 12px; }

.alloc-cell {
    text-align: center !important;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    transition: background 0.15s;
    cursor: default;
}
.alloc-cell:hover { opacity: 0.8; }

.alloc-total-cell { font-weight: 700 !important; color: var(--text) !important; background: #f0fdf4; }
.alloc-fj-cell { font-weight: 600; color: var(--accent-orange) !important; background: #fff7ed; }

.alloc-grand-row { background: var(--bg) !important; border-top: 2px solid var(--border); }
.alloc-grand-row td { padding: 0.7rem 0.5rem !important; }

.alloc-row { transition: background 0.1s; }
.alloc-row:hover { background: var(--bg-hover) !important; }

.alloc-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1.5fr 1fr;
    gap: 1rem;
}
.alloc-detail-total { font-size: 14px; font-weight: 800; color: var(--text); margin-left: 8px; }

.form-input {
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.85rem;
    font-family: inherit;
    background: #fff;
    transition: border-color 0.15s;
}
.form-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-light); }

/* ===== タブレット (768px以下) ===== */
@media (max-width: 768px) {
    .menu-toggle { display: flex; }
    .sidebar-overlay.active { display: block; }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 150;
    }
    .sidebar.open { transform: translateX(0); }

    .main-content {
        margin-left: 0;
        max-width: 100%;
        padding: 1rem;
        padding-top: 3.5rem;
    }

    .top-header { flex-direction: column; gap: 0.5rem; align-items: flex-start; }
    .top-header h1 { font-size: 17px; }

    .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 0.625rem; }
    .kpi-value { font-size: 18px; }
    .kpi-label { font-size: 10px; }

    .chart-row { grid-template-columns: 1fr; }
    .chart-card canvas { max-height: 250px; }

    .store-cards-grid { grid-template-columns: repeat(2, 1fr); gap: 0.625rem; }
    .store-kpi-main { font-size: 16px; }
    .store-kpi-body { gap: 0.15rem 0.5rem; }
    .store-kpi-item { font-size: 11px; }

    .table-card { padding: 0.75rem; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .data-table { font-size: 12px; }
    .data-table th { font-size: 10px; padding: 0.4rem 0.5rem; }
    .data-table td { padding: 0.4rem 0.5rem; }

    .exec-grid { grid-template-columns: 1fr 1fr; gap: 0.625rem; }
    .exec-block { padding: 0.75rem; }
    .exec-block h4 { font-size: 11px; }
    .exec-table { font-size: 11px; }

    .target-overview { flex-direction: column; gap: 0.75rem; }
    .target-stats { flex-wrap: wrap; gap: 0.75rem; }
    .ts-value { font-size: 14px; }

    .corr-grid { grid-template-columns: 1fr; }
    .section-title { font-size: 14px; }
}

/* ===== スマホ小画面 (480px以下) ===== */
@media (max-width: 480px) {
    .main-content { padding: 0.75rem; padding-top: 3.5rem; }

    .kpi-grid { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
    .kpi-card { padding: 0.75rem; }
    .kpi-value { font-size: 16px; }

    .store-cards-grid { grid-template-columns: 1fr; }
    .store-kpi-card { padding: 0.75rem 1rem; }
    .store-kpi-body { grid-template-columns: repeat(3, 1fr); }

    .exec-grid { grid-template-columns: 1fr; }

    .data-table { font-size: 11px; }
    .data-table th, .data-table td { padding: 0.3rem 0.4rem; }
}

/* Koike Watch - collapsed detail */
.koike-detail { transition: max-height 0.3s ease, opacity 0.3s ease; max-height: 1000px; opacity: 1; overflow: hidden; }
.koike-detail.collapsed { max-height: 0; opacity: 0; margin: 0 !important; }

/* ===== 経費入力画面 ===== */
.expense-input-container { max-width: 1400px; }

.expense-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.expense-toolbar-left { display: flex; gap: 4px; flex-wrap: wrap; }
.expense-toolbar-right { display: flex; gap: 8px; }

.expense-tab-btn {
    padding: 0.6rem 1.2rem;
    border: 1px solid var(--border);
    background: var(--bg);
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    min-height: 44px;
}
.expense-tab-btn:hover { background: var(--bg-hover); border-color: var(--accent); color: var(--accent); }
.expense-tab-btn.active {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(99,102,241,0.3);
}

.btn-expense-action {
    padding: 0.6rem 1.4rem;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    min-height: 44px;
}
.btn-copy-prev { background: #f1f5f9; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-copy-prev:hover { background: #e2e8f0; }
.btn-save { background: linear-gradient(135deg, #10b981, #059669); color: #fff; }
.btn-save:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(16,185,129,0.3); }

.expense-tab-content { display: none; }
.expense-tab-content.active { display: block; }

.expense-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding: 0 0.25rem;
}
.expense-section-header h3 { font-size: 16px; font-weight: 700; color: var(--text); margin: 0; }
.expense-section-total { font-size: 14px; color: var(--text-secondary); }
.expense-section-total strong { font-size: 18px; color: var(--text); font-variant-numeric: tabular-nums; }

.expense-table-wrap {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    overflow-x: auto;
}

.expense-edit-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 15px;
}
.expense-edit-table th {
    text-align: left;
    padding: 0.7rem 0.5rem;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-bottom: 2px solid var(--border);
    background: var(--bg);
    white-space: nowrap;
}
.expense-edit-table td {
    padding: 0.35rem 0.35rem;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}
.expense-edit-table tr:hover { background: #fafbfe; }
.expense-edit-table tr.modified { background: #fffbeb; }

.expense-edit-table input[type="text"],
.expense-edit-table input[type="number"] {
    width: 100%;
    padding: 0.5rem 0.6rem;
    min-height: 38px;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: transparent;
    transition: all 0.15s;
    color: var(--text);
}
.expense-edit-table input[type="text"]:hover,
.expense-edit-table input[type="number"]:hover {
    border-color: var(--border);
    background: #fff;
}
.expense-edit-table input[type="text"]:focus,
.expense-edit-table input[type="number"]:focus {
    outline: none;
    border-color: var(--accent);
    background: #fff;
    box-shadow: 0 0 0 2px var(--accent-light);
}
.expense-edit-table input[type="number"] {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}

.expense-edit-table select {
    padding: 0.45rem 0.5rem;
    min-height: 38px;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: transparent;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.15s;
}
.expense-edit-table select:hover { border-color: var(--border); background: #fff; }
.expense-edit-table select:focus { outline: none; border-color: var(--accent); background: #fff; }

.expense-row-num {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    width: 30px;
}

.btn-delete-row {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    padding: 6px;
    border-radius: 4px;
    opacity: 0.7;
    transition: all 0.15s;
}
.btn-delete-row:hover { opacity: 1; background: #fee2e2; }

.btn-add-row {
    display: block;
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.75rem;
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    min-height: 44px;
}
.btn-add-row:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}

/* 広告費マトリックス */
.ad-matrix-table th { font-size: 10px; text-align: center !important; padding: 0.5rem 0.25rem; }
.ad-matrix-table td { padding: 0.2rem; }
.ad-matrix-table input[type="number"] {
    text-align: center;
    font-size: 11px;
    padding: 0.3rem 0.2rem;
    width: 70px;
}
.ad-matrix-table .vendor-name-cell { min-width: 120px; font-weight: 600; }
.ad-matrix-table .ad-total-cell { font-weight: 700; background: #f0fdf4; text-align: center; font-size: 11px; font-variant-numeric: tabular-nums; }
.ad-matrix-table .vendor-total-cell { font-weight: 700; background: #eff6ff; text-align: center; font-size: 11px; font-variant-numeric: tabular-nums; }

/* AI OCR アコーディオン */
.ocr-accordion {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.ocr-accordion-summary {
    padding: 0.75rem 1.25rem;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    color: var(--text);
    background: var(--bg);
    list-style: none;
    transition: background 0.15s;
}
.ocr-accordion-summary:hover { background: var(--bg-hover); }
.ocr-accordion-summary::-webkit-details-marker { display: none; }
.ocr-accordion-summary::before { content: '▶ '; font-size: 10px; margin-right: 6px; transition: transform 0.2s; display: inline-block; }
.ocr-accordion[open] .ocr-accordion-summary::before { transform: rotate(90deg); }
.ocr-accordion-content { padding: 1rem 1.25rem; }

/* 保存成功トースト通知 */
.toast-notify {
    position: fixed;
    bottom: 5rem;
    right: 2rem;
    padding: 1rem 2rem;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    z-index: 9999;
    animation: toastIn 0.3s ease, toastOut 0.3s ease 4.5s forwards;
    box-shadow: 0 8px 25px rgba(0,0,0,0.2);
    max-width: 90vw;
    /* デフォルト背景: type未指定時でも見えるように（青系） */
    background: linear-gradient(135deg, #3b82f6, #2563eb);
}
.toast-success { background: linear-gradient(135deg, #10b981, #059669); }
.toast-error { background: linear-gradient(135deg, #ef4444, #dc2626); }
@keyframes toastIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(20px); } }

/* ===== OCR-First Section ===== */
.ocr-first-section {
    background: var(--bg-card);
    border: 2px dashed var(--accent);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
    transition: all 0.3s ease;
}

.ocr-first-section.collapsed .ocr-step-content,
.ocr-first-section.collapsed .ocr-results,
.ocr-first-section.collapsed .ocr-status,
.ocr-first-section.collapsed .ocr-step-badges {
    display: none !important;
}

.ocr-step-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.ocr-first-section.collapsed .ocr-step-header {
    margin-bottom: 0;
}

.ocr-step-badges {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.ocr-step-badge {
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    background: var(--bg);
    color: var(--text-muted);
    border: 1px solid var(--border);
    transition: all 0.2s ease;
}

.ocr-step-badge.active {
    background: var(--accent-light);
    color: var(--accent);
    border-color: var(--accent);
    font-weight: 600;
}

.ocr-toggle-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.85rem;
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.ocr-toggle-btn:hover {
    background: var(--bg);
    border-color: var(--accent);
    color: var(--accent);
}

.btn-ocr-apply {
    background: linear-gradient(135deg, #6366f1, #8b5cf6) !important;
    color: #fff !important;
    border: none !important;
    font-weight: 600 !important;
    padding: 0.5rem 1.25rem !important;
    border-radius: var(--radius-sm) !important;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-ocr-apply:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99,102,241,0.3);
}

/* ===== OCR-Filled Row Highlight ===== */
tr.ocr-filled {
    border-left: 3px solid var(--accent-purple);
    background: linear-gradient(90deg, rgba(139,92,246,0.06) 0%, transparent 40%);
}

tr.ocr-filled td:first-child {
    position: relative;
}

tr.ocr-filled td:first-child::before {
    content: 'AI';
    position: absolute;
    top: 2px;
    left: 2px;
    font-size: 8px;
    font-weight: 700;
    color: var(--accent-purple);
    background: rgba(139,92,246,0.12);
    padding: 1px 3px;
    border-radius: 3px;
    line-height: 1;
}

/* ===== Allocation Preview Panel ===== */
.alloc-preview-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-top: 1.25rem;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.alloc-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, rgba(99,102,241,0.05), rgba(139,92,246,0.05));
    cursor: pointer;
    border-bottom: 1px solid var(--border-light);
    user-select: none;
}

.alloc-preview-header h3 {
    font-size: 14px;
    font-weight: 600;
    margin: 0;
    color: var(--text);
}

.alloc-preview-status {
    font-size: 12px;
    font-weight: 400;
    color: var(--text-muted);
    margin-left: 8px;
}

.alloc-preview-toggle {
    font-size: 12px;
    color: var(--text-muted);
    transition: transform 0.2s;
}

.alloc-preview-body.collapsed {
    display: none;
}

.alloc-preview-summary {
    display: flex;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-light);
    flex-wrap: wrap;
}

.alloc-preview-kpi {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.apk-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.apk-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.alloc-preview-table-wrap {
    overflow-x: auto;
    padding: 0 0.5rem 0.5rem;
}

.alloc-preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.alloc-preview-table th {
    text-align: right;
    padding: 0.4rem 0.5rem;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.alloc-preview-table th:first-child {
    text-align: left;
}

.alloc-preview-table td {
    padding: 0.35rem 0.5rem;
    border-bottom: 1px solid var(--border-light);
}

.alloc-preview-table td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.alloc-preview-table .alloc-cat-name {
    font-weight: 500;
    white-space: nowrap;
}

/* ===== Smart Copy Change Highlights ===== */
tr.change-amount {
    background: rgba(245,158,11,0.08);
}

tr.change-new {
    background: rgba(16,185,129,0.08);
    border-left: 3px solid var(--accent-green);
}

tr.change-removed {
    background: rgba(239,68,68,0.06);
    opacity: 0.6;
    text-decoration: line-through;
}

.prev-amount-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: 4px;
}

/* ===== 経費ガイドテキスト ===== */
.expense-guide-text {
    background: linear-gradient(135deg, #eff6ff, #eef2ff);
    border: 1px solid #bfdbfe;
    border-radius: var(--radius-sm);
    padding: 0.85rem 1.25rem;
    margin-bottom: 1rem;
    font-size: 15px;
    font-weight: 500;
    color: #1e40af;
    line-height: 1.6;
}

.expense-guide-text strong {
    font-weight: 700;
}

/* ===== タブバッジ ===== */
.tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(99,102,241,0.15);
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
    min-width: 22px;
    height: 22px;
    border-radius: 11px;
    padding: 0 6px;
    margin-left: 6px;
}

.expense-tab-btn.active .tab-badge {
    background: rgba(255,255,255,0.3);
    color: #fff;
}

/* ===== 一括保存 Sticky Footer ===== */
.expense-save-footer {
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(8px);
    border-top: 2px solid var(--border);
    padding: 0.75rem 1.25rem;
    z-index: 50;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: 0 -4px 12px rgba(0,0,0,0.06);
}

.btn-save-large {
    padding: 0.85rem 2.5rem;
    border: none;
    border-radius: 10px;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    background: linear-gradient(135deg, #059669, #047857);
    color: #fff;
    min-height: 52px;
    box-shadow: 0 4px 12px rgba(5,150,105,0.3);
}

.btn-save-large:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(5,150,105,0.4);
}

.btn-save-large:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.save-footer-hint {
    font-size: 13px;
    color: var(--text-muted);
}

/* ===========================
   経理モジュール
   =========================== */
.nav-divider {
    height: 1px;
    background: rgba(255,255,255,0.08);
    margin: 0.5rem 1rem;
}

.acct-container {
    padding: 0;
}

.acct-tabs {
    display: flex;
    gap: 4px;
    padding: 0 0 1rem;
    overflow-x: auto;
    flex-wrap: wrap;
}

.acct-tab {
    padding: 0.55rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
    color: var(--text-secondary);
    min-height: 42px;
}

.acct-tab:hover {
    background: #f1f5f9;
}

.acct-tab.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.acct-panel {
    display: none;
}

.acct-panel.active {
    display: block;
}

.acct-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.acct-panel-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.acct-panel-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.acct-total {
    font-size: 15px;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
}

.btn-acct-save {
    padding: 0.6rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    background: linear-gradient(135deg, #059669, #047857);
    color: #fff;
    min-height: 44px;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(5,150,105,0.25);
}

.btn-acct-save:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(5,150,105,0.35);
}

.btn-acct-save:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.acct-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
}

.acct-edit-table {
    width: 100%;
    font-size: 14px;
    box-shadow: none;
}

.acct-edit-table th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f8fafc;
    font-size: 12px;
    white-space: nowrap;
    padding: 0.5rem 0.4rem;
}

.acct-edit-table td {
    padding: 0.3rem 0.25rem;
    vertical-align: middle;
}

.acct-edit-table input[type="text"],
.acct-edit-table input[type="number"] {
    width: 100%;
    padding: 0.35rem 0.4rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 14px;
    background: #fff;
    min-height: 36px;
    box-sizing: border-box;
}

.acct-edit-table input[type="number"] {
    text-align: right;
    width: 90px;
}

.acct-edit-table input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59,130,246,0.15);
}

.acct-edit-table select {
    padding: 0.35rem 0.4rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 14px;
    min-height: 36px;
    background: #fff;
}

.acct-edit-table .btn-delete-row {
    padding: 0.25rem 0.5rem;
    border: none;
    background: transparent;
    color: #ef4444;
    cursor: pointer;
    font-size: 16px;
    opacity: 0.6;
    transition: opacity 0.15s;
}

.acct-edit-table .btn-delete-row:hover {
    opacity: 1;
}

/* 月次サマリーカード */
.acct-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.acct-summary-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.25rem;
    transition: box-shadow 0.2s;
}

.acct-summary-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

.acct-summary-card h4 {
    margin: 0 0 0.75rem;
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 500;
}

.acct-summary-card .acct-summary-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}

.acct-summary-card .acct-summary-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 0.35rem;
}

/* Phase 3: 自動集計タブ */
.acct-tab-divider {
    color: #cbd5e1;
    font-size: 14px;
    line-height: 32px;
    padding: 0 2px;
    user-select: none;
}

.acct-tab-auto {
    background: linear-gradient(135deg, #eff6ff, #f0fdf4) !important;
    border: 1px solid #93c5fd !important;
}
.acct-tab-auto.active {
    background: linear-gradient(135deg, #2563eb, #059669) !important;
    color: #fff !important;
    border-color: transparent !important;
}

.btn-acct-refresh {
    padding: 6px 14px;
    border: 1px solid #93c5fd;
    background: #eff6ff;
    border-radius: 6px;
    color: #2563eb;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-acct-refresh:hover {
    background: #dbeafe;
}

/* FJ-G P&L カードグリッド */
.fjg-pl-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    margin: 1rem 0;
}

.fjg-pl-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    transition: box-shadow 0.2s;
}
.fjg-pl-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}

.fjg-pl-company {
    margin: 0;
    padding: 0.75rem 1rem;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    font-size: 15px;
    font-weight: 700;
    color: #1e293b;
}

.fjg-pl-section {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f1f5f9;
}

.fjg-pl-section-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.fjg-pl-line {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    font-size: 13px;
    color: #475569;
}
.fjg-pl-line span:last-child {
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.fjg-pl-subtotal {
    display: flex;
    justify-content: space-between;
    padding: 6px 0 2px;
    margin-top: 4px;
    border-top: 1px dashed #e2e8f0;
    font-weight: 700;
    font-size: 14px;
}

.fjg-pl-profit {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    font-weight: 700;
    font-size: 15px;
}

/* レスポンシブ */
@media (max-width: 768px) {
    .expense-toolbar { flex-direction: column; align-items: stretch; }
    .expense-toolbar-left { overflow-x: auto; }
    .expense-toolbar-right { justify-content: flex-end; }
    .expense-section-header { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
    .ad-matrix-table input[type="number"] { width: 55px; font-size: 10px; }
    .alloc-detail-grid { grid-template-columns: 1fr; }
    .ocr-step-header { flex-direction: column; gap: 0.5rem; }
    .ocr-step-badges { justify-content: center; }
    .expense-save-footer { padding: 0.75rem; }
    .btn-save-large { width: 100%; }
    .fjg-pl-grid { grid-template-columns: 1fr; }
    .acct-tabs { flex-wrap: wrap; }
}

/* ===========================================================
   経理モジュール UI/UX 改善（v2）
   - 数値の見切れ防止（tabular-nums + 適切な幅）
   - 1列目（科目・店舗名）をsticky固定
   - 最右列（合計）をsticky固定で常時表示
   - タブを1行に収めて縦スペース節約
   - 店舗名ヘッダを縦書きから水平方向へ（読みやすく）
   =========================================================== */

/* 数値は等幅で揃える */
.acct-edit-table td,
.acct-edit-table th,
#spg-matrix-body td,
#spg-matrix-head th,
#spg-matrix-foot td,
.data-table td,
.data-table th {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
}

/* SP-G経費一覧: テーブル見直し */
#acct-panel-spg-matrix .acct-table-wrap {
    overflow: auto;
    max-height: calc(100vh - 260px);
    border: 1px solid #e2e8f0;
    border-radius: 10px;
}

#acct-panel-spg-matrix table {
    width: max-content;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

/* ヘッダー: 横書き読みやすく */
#spg-matrix-head th {
    writing-mode: horizontal-tb !important;
    height: auto !important;
    min-width: 88px !important;
    padding: 10px 8px !important;
    font-size: 12px !important;
    background: #f1f5f9 !important;
    border-bottom: 2px solid #cbd5e1;
    position: sticky;
    top: 0;
    z-index: 2;
}

/* 1列目（科目）を固定 */
#spg-matrix-head th:first-child,
#spg-matrix-body td:first-child,
#spg-matrix-foot td:first-child {
    position: sticky;
    left: 0;
    z-index: 3;
    background: #fff;
    box-shadow: 2px 0 4px -2px rgba(0,0,0,0.1);
    min-width: 140px !important;
    text-align: left !important;
}

#spg-matrix-head th:first-child {
    z-index: 4;
    background: #e2e8f0 !important;
}

#spg-matrix-foot td:first-child {
    background: #ecfdf5 !important;
}

/* 最終列（合計）を右固定 */
#spg-matrix-head th:last-child,
#spg-matrix-body td:last-child,
#spg-matrix-foot td:last-child {
    position: sticky;
    right: 0;
    z-index: 3;
    background: #fef3c7 !important;
    font-weight: 700;
    box-shadow: -2px 0 4px -2px rgba(0,0,0,0.1);
    min-width: 110px !important;
}

#spg-matrix-head th:last-child {
    z-index: 4;
    background: #fde68a !important;
}

#spg-matrix-foot td:last-child {
    background: #d1fae5 !important;
    color: #059669;
    font-size: 15px;
}

#spg-matrix-body td {
    padding: 8px 10px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 13px;
}

#spg-matrix-body tr:hover td {
    background: #f8fafc !important;
}

#spg-matrix-body tr:hover td:first-child {
    background: #f1f5f9 !important;
}

#spg-matrix-foot td {
    padding: 10px;
    border-top: 2px solid #cbd5e1;
    background: #f0fdf4 !important;
    font-weight: 700;
}

/* ========== 汎用: 編集テーブルの数値入力 ========== */
.acct-edit-table input[type="number"] {
    min-width: 90px !important;
    width: 100% !important;
    font-variant-numeric: tabular-nums;
    padding: 0.4rem 0.5rem !important;
}

/* 人数割りなど 小数入力専用の列は少し狭く */
.acct-edit-table input[data-hc-type="headcount"] {
    min-width: 70px !important;
    width: 70px !important;
    text-align: center !important;
}

/* 人数割りテーブル: 金額列の幅確保 */
#acct-panel-headcount .acct-table-wrap {
    overflow-x: auto;
    max-height: calc(100vh - 220px);
    overflow-y: auto;
}

#acct-panel-headcount table {
    min-width: 100%;
}

#acct-panel-headcount th {
    position: sticky;
    top: 0;
    background: #f1f5f9 !important;
    z-index: 2;
    min-width: 90px;
    padding: 10px 8px;
}

#acct-panel-headcount th:first-child,
#acct-panel-headcount td:first-child {
    position: sticky;
    left: 0;
    background: #fff;
    z-index: 3;
    box-shadow: 2px 0 4px -2px rgba(0,0,0,0.1);
    min-width: 100px;
    font-weight: 600;
}

#acct-panel-headcount th:first-child {
    z-index: 4;
    background: #e2e8f0 !important;
}

#acct-panel-headcount td {
    padding: 6px 8px;
}

#acct-panel-headcount input[type="number"] {
    min-width: 100px !important;
    width: 100% !important;
    text-align: right !important;
    padding: 0.4rem 0.5rem !important;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

/* 人数入力だけは中央寄せで幅狭めに（2.5人など小数2桁） */
#acct-panel-headcount input[data-hc-type="headcount"] {
    min-width: 70px !important;
    width: 70px !important;
    text-align: center !important;
}

/* 人数割りテーブル: 列幅を確実に確保 */
#acct-panel-headcount th {
    min-width: 110px !important;
}
#acct-panel-headcount th:first-child,
#acct-panel-headcount td:first-child {
    min-width: 120px !important;
}

/* 合計列が最後にある場合 */
#acct-panel-headcount th:last-child,
#acct-panel-headcount td:last-child {
    position: sticky;
    right: 0;
    background: #fef3c7 !important;
    z-index: 3;
    min-width: 110px;
    font-weight: 700;
    box-shadow: -2px 0 4px -2px rgba(0,0,0,0.1);
}

/* ========== 家賃・広告費・雑収入タブの改善 ========== */
#acct-panel-rent .acct-table-wrap,
#acct-panel-ad .acct-table-wrap,
#acct-panel-misc .acct-table-wrap {
    overflow-x: auto;
    max-height: calc(100vh - 260px);
    overflow-y: auto;
}

#acct-panel-rent table,
#acct-panel-ad table,
#acct-panel-misc table {
    min-width: 100%;
    width: max-content;
}

/* ヘッダー行固定 */
#acct-panel-rent thead th,
#acct-panel-ad thead th,
#acct-panel-misc thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #1e293b !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    text-align: center;
}

/* 1列目固定（ビル名 / 代理店名 / 項目名） */
#acct-panel-rent tbody td:first-child,
#acct-panel-rent thead th:first-child,
#acct-panel-misc tbody td:first-child,
#acct-panel-misc thead th:first-child {
    position: sticky;
    left: 0;
    background: #fff;
    z-index: 3;
    min-width: 150px;
    box-shadow: 2px 0 4px -2px rgba(0,0,0,0.1);
}

#acct-panel-rent thead th:first-child,
#acct-panel-misc thead th:first-child {
    z-index: 4;
    background: #0f172a !important;
    color: #ffffff !important;
    text-align: left;
}

/* 広告費は区分+代理店の2列を固定 */
#acct-panel-ad tbody td:first-child,
#acct-panel-ad tbody td:nth-child(2),
#acct-panel-ad thead th:first-child,
#acct-panel-ad thead th:nth-child(2) {
    position: sticky;
    background: #fff;
    z-index: 3;
}
#acct-panel-ad tbody td:first-child,
#acct-panel-ad thead th:first-child {
    left: 0;
    min-width: 100px;
}
#acct-panel-ad tbody td:nth-child(2),
#acct-panel-ad thead th:nth-child(2) {
    left: 100px;
    min-width: 140px;
    box-shadow: 2px 0 4px -2px rgba(0,0,0,0.1);
}
#acct-panel-ad thead th:first-child,
#acct-panel-ad thead th:nth-child(2) {
    z-index: 4;
    background: #0f172a !important;
    color: #ffffff !important;
    text-align: left;
}

/* 最右列（行合計）固定 */
#acct-panel-rent tbody td:last-child,
#acct-panel-rent thead th:last-child,
#acct-panel-ad tbody td:last-child,
#acct-panel-ad thead th:last-child,
#acct-panel-misc tbody td:last-child,
#acct-panel-misc thead th:last-child {
    position: sticky;
    right: 0;
    z-index: 3;
    background: #fef3c7 !important;
    font-weight: 700;
    min-width: 110px;
    box-shadow: -2px 0 4px -2px rgba(0,0,0,0.1);
    text-align: right;
}
#acct-panel-rent thead th:last-child,
#acct-panel-ad thead th:last-child,
#acct-panel-misc thead th:last-child {
    z-index: 4;
    background: #1e293b !important;
    color: #fde68a !important;
}

/* フッター合計行 */
#acct-panel-rent tfoot td,
#acct-panel-ad tfoot td,
#acct-panel-misc tfoot td {
    position: sticky;
    bottom: 0;
    background: #f0fdf4 !important;
    font-weight: 700;
    border-top: 2px solid #cbd5e1;
    z-index: 2;
}
#acct-panel-rent tfoot td:first-child,
#acct-panel-misc tfoot td:first-child,
#acct-panel-ad tfoot td:first-child {
    left: 0;
    z-index: 3;
    background: #ecfdf5 !important;
}
#acct-panel-rent tfoot td:last-child,
#acct-panel-ad tfoot td:last-child,
#acct-panel-misc tfoot td:last-child {
    right: 0;
    z-index: 3;
    background: #d1fae5 !important;
    color: #059669;
}

/* ========== タブのコンパクト化 ========== */
.acct-tabs {
    gap: 2px !important;
    padding-bottom: 0.75rem !important;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 0.5rem !important;
    margin-bottom: 1rem;
}

.acct-tab {
    padding: 0.45rem 0.7rem !important;
    font-size: 13px !important;
    min-height: 36px !important;
    border-radius: 6px !important;
}

.acct-tab-divider {
    display: none !important;  /* 区切り線を非表示にしてコンパクト化 */
}

/* ========== パネルヘッダーの改善 ========== */
.acct-panel-header {
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, #f8fafc, #fff);
    border: 1px solid #e2e8f0;
    border-radius: 10px 10px 0 0;
    margin-bottom: 0 !important;
    border-bottom: none;
}

.acct-panel-header + .acct-table-wrap {
    border-radius: 0 0 10px 10px !important;
    border-top: none !important;
}

.acct-panel-header h3 {
    font-size: 15px !important;
}

.acct-total {
    font-size: 16px !important;
    padding: 6px 12px;
    background: #dbeafe;
    border-radius: 6px;
    color: #1e40af !important;
}

/* ========== メインコンテンツの余白調整（経理モジュール時のみ広く） ========== */
body.acct-active .main-content {
    padding: 1rem 1.25rem !important;
}
@media (max-width: 768px) {
    body.acct-active .main-content {
        padding: 3.5rem 1rem 1rem !important;
    }
}
@media (max-width: 480px) {
    body.acct-active .main-content {
        padding: 3.5rem 0.75rem 0.75rem !important;
    }
}

/* スクロールバーを見やすく */
.acct-table-wrap::-webkit-scrollbar {
    height: 10px;
    width: 10px;
}
.acct-table-wrap::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 5px;
}
.acct-table-wrap::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border-radius: 5px;
}
.acct-table-wrap::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* ========== 広告費: 区分の色分け ========== */
/* 営業広告 = ブルー系 */
.ad-row.ad-type-eigyo td.ad-type-cell {
    background: linear-gradient(90deg, #dbeafe 0%, #eff6ff 100%);
    border-left: 4px solid #3b82f6;
}
.ad-type-select.ad-type-eigyo {
    background: #dbeafe !important;
    color: #1e40af !important;
    border: 1px solid #60a5fa !important;
    font-weight: 700;
}

/* 女子求人 = ピンク系 */
.ad-row.ad-type-joshi td.ad-type-cell {
    background: linear-gradient(90deg, #fce7f3 0%, #fdf2f8 100%);
    border-left: 4px solid #ec4899;
}
.ad-type-select.ad-type-joshi {
    background: #fce7f3 !important;
    color: #9f1239 !important;
    border: 1px solid #f472b6 !important;
    font-weight: 700;
}

/* 男子求人 = パープル系 */
.ad-row.ad-type-danshi td.ad-type-cell {
    background: linear-gradient(90deg, #ede9fe 0%, #f5f3ff 100%);
    border-left: 4px solid #8b5cf6;
}
.ad-type-select.ad-type-danshi {
    background: #ede9fe !important;
    color: #5b21b6 !important;
    border: 1px solid #a78bfa !important;
    font-weight: 700;
}

/* select共通スタイル */
#acct-panel-ad .ad-type-select {
    padding: 0.4rem 0.5rem;
    border-radius: 6px;
    font-size: 13px;
    min-width: 110px;
    cursor: pointer;
    transition: all 0.15s;
}
#acct-panel-ad .ad-type-select:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* 行ホバー時も区分色を維持 */
#acct-panel-ad .ad-row:hover td.ad-type-cell {
    filter: brightness(0.98);
}

/* 同じ区分が連続する場合、行間の視覚的区切り */
#acct-panel-ad .ad-row[data-ad-type] + .ad-row[data-ad-type]:not([data-ad-type=""]) {
    border-top: 1px solid #e2e8f0;
}

/* ========== 達成ラインバッジ ========== */
.tier-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    letter-spacing: 0.02em;
}

.tier-badge.tier-none {
    background: #f1f5f9;
    color: #94a3b8;
    border: 1px dashed #cbd5e1;
    box-shadow: none;
}

/* 選択ボーナス金額タグ（tier-badgeの右横に常時表示） */
.chosen-bonus-tag {
    display: inline-block;
    margin-left: 4px;
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    white-space: nowrap;
    background: #e2e8f0;
    color: #475569;
    letter-spacing: 0.02em;
    vertical-align: middle;
}

/* バッジを含むセルでも店舗名は左揃え（バッジは店舗名横に表示するため） */

/* ========== 前月コピーボタン ========== */
.btn-copy-prev {
    padding: 0.5rem 1rem;
    border: 1px solid #f59e0b;
    border-radius: 8px;
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    color: #92400e;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    min-height: 40px;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-copy-prev:hover {
    background: linear-gradient(135deg, #fde68a, #fcd34d);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(245,158,11,0.3);
}

.btn-copy-prev:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ========== ドライバー給: 自動計算セルのスタイル ========== */
#acct-panel-driver .acct-table-wrap {
    overflow-x: auto;
    max-height: calc(100vh - 220px);
    overflow-y: auto;
}

#acct-panel-driver thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f1f5f9 !important;
    min-width: 85px;
    font-size: 12px;
    padding: 10px 6px;
}

/* 入力セル: 白背景 */
#acct-panel-driver input.dr-input {
    min-width: 80px;
    width: 100%;
    text-align: right;
    padding: 0.4rem 0.5rem;
    font-variant-numeric: tabular-nums;
}

#acct-panel-driver input[data-f="name"] {
    text-align: left;
    min-width: 90px;
}

/* 自動計算セル: グレー背景+電卓アイコン風でreadonlyを示す */
#acct-panel-driver td.dr-calc {
    background: #f1f5f9;
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: #475569;
    padding: 8px 10px;
    position: relative;
    cursor: not-allowed;
    user-select: text;
    border-left: 1px dashed #cbd5e1;
    border-right: 1px dashed #cbd5e1;
    min-width: 90px;
}

/* 合計(gross): 強調 */
#acct-panel-driver td.dr-calc-gross {
    background: #dbeafe !important;
    color: #1e40af !important;
    font-weight: 700 !important;
    font-size: 14px;
}

/* 源泉2%: 赤系 */
#acct-panel-driver td.dr-calc-tax {
    background: #fee2e2 !important;
    color: #b91c1c !important;
}

/* 差引: 緑系 */
#acct-panel-driver td.dr-calc-net {
    background: #d1fae5 !important;
    color: #047857 !important;
    font-weight: 700 !important;
    font-size: 14px;
}

/* 入力セルは明示的に白背景 */
#acct-panel-driver td:not(.dr-calc):not(:first-child):not(:last-child) {
    background: #fff;
}

/* 最初の列（グループ）を固定 */
#acct-panel-driver tbody td:first-child,
#acct-panel-driver thead th:first-child {
    position: sticky;
    left: 0;
    background: #fff;
    z-index: 3;
    min-width: 80px;
}
#acct-panel-driver thead th:first-child {
    z-index: 4;
    background: #e2e8f0 !important;
}

/* 2列目（氏名）も固定 */
#acct-panel-driver tbody td:nth-child(2),
#acct-panel-driver thead th:nth-child(2) {
    position: sticky;
    left: 80px;
    background: #fff;
    z-index: 3;
    min-width: 100px;
    box-shadow: 2px 0 4px -2px rgba(0,0,0,0.1);
}
#acct-panel-driver thead th:nth-child(2) {
    z-index: 4;
    background: #e2e8f0 !important;
}

/* 最終列（操作）も固定 */
#acct-panel-driver tbody td:last-child,
#acct-panel-driver thead th:last-child {
    position: sticky;
    right: 0;
    background: #fff;
    z-index: 3;
    min-width: 50px;
    box-shadow: -2px 0 4px -2px rgba(0,0,0,0.1);
}
#acct-panel-driver thead th:last-child {
    z-index: 4;
    background: #e2e8f0 !important;
}

/* calc セルにツールチップヒント */
#acct-panel-driver td.dr-calc::after {
    content: "";
    position: absolute;
    top: 2px;
    right: 3px;
    width: 8px;
    height: 8px;
    background: #94a3b8;
    border-radius: 50%;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
}
#acct-panel-driver td.dr-calc[title]::after { opacity: 0.4; }

/* 経費配賦ページ: 配賦表の右側見切れ対策 */
#acct-panel-expense-alloc .alloc-summary-table,
.alloc-summary-table {
    width: max-content;
    min-width: 100%;
}

#acct-panel-expense-alloc .table-wrapper,
.alloc-summary-wrapper {
    overflow-x: auto;
}

/* 全画面表示でもテーブルがはみ出さないよう */
.acct-panel {
    min-width: 0;  /* flex子要素のoverflow対策 */
}
}

/* ===== タレント管理 ===== */
#page-talent { padding-bottom: 2rem; }
.talent-toolbar { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.talent-toolbar-spacer { flex: 1; }
.talent-summary { font-size: 13px; font-weight: 600; color: var(--text); padding: 0 0.5rem; }
.talent-summary strong { color: var(--accent); font-size: 16px; }
.talent-help { background: linear-gradient(135deg, #eef2ff, #f1f5f9); border-left: 3px solid var(--accent); padding: 0.6rem 1rem; border-radius: 6px; font-size: 12px; color: var(--text-secondary); margin-bottom: 1rem; }

.talent-board { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0.875rem; }
.talent-store { background: var(--bg-card); border: 2px solid var(--border); border-radius: 12px; padding: 0.75rem; box-shadow: var(--shadow-sm); transition: border-color 0.15s, box-shadow 0.15s; min-height: 160px; }
.talent-store.drag-over { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-light); background: var(--accent-light); }
.talent-store-header { display: flex; align-items: center; justify-content: space-between; padding-bottom: 0.5rem; margin-bottom: 0.5rem; border-bottom: 1px solid var(--border-light); }
.talent-store-name { font-size: 14px; font-weight: 700; color: var(--text); }
.talent-store-count { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; background: var(--accent-light); color: var(--accent); }
.talent-store-payroll { font-size: 10px; color: var(--text-muted); }

.talent-staff-list { display: flex; flex-direction: column; gap: 0.4rem; min-height: 60px; }
.talent-staff { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 0.5rem 0.65rem; cursor: grab; transition: all 0.15s; user-select: none; position: relative; }
.talent-staff:hover { background: var(--bg-hover); border-color: var(--accent); transform: translateX(2px); }
.talent-staff:active { cursor: grabbing; }
.talent-staff.dragging { opacity: 0.4; }
.talent-staff.moved { border-color: var(--accent-orange); background: linear-gradient(90deg, #fffbeb, var(--bg)); }
.talent-staff.moved::before { content: "📍"; position: absolute; top: -6px; left: -6px; background: var(--accent-orange); color: #fff; font-size: 10px; padding: 1px 5px; border-radius: 8px; }
.talent-staff-name { font-size: 13px; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 0.35rem; }
.talent-staff-position { font-size: 10px; padding: 1px 6px; border-radius: 4px; font-weight: 700; }
.position-店長 { background: #fef3c7; color: #92400e; }
.position-副店長 { background: #dbeafe; color: #1e40af; }
.position-主任 { background: #e0f2fe; color: #075985; }
.position-本部 { background: #f3e8ff; color: #6b21a8; }
.position-バイト { background: #f1f5f9; color: var(--text-muted); }
.talent-staff-meta { font-size: 10px; color: var(--text-muted); margin-top: 2px; display: flex; gap: 0.5rem; flex-wrap: wrap; }
.talent-staff-salary { font-size: 11px; font-weight: 700; color: var(--accent-green); }
.talent-staff-note { font-size: 10px; color: var(--text-muted); font-style: italic; }


/* スタッフカードのアクションボタン */
.talent-staff-actions { position: absolute; top: 4px; right: 4px; display: none; gap: 2px; z-index: 2; }
.talent-staff:hover .talent-staff-actions { display: flex; }
.talent-staff-action { width: 22px; height: 22px; padding: 0; border: none; border-radius: 4px; background: rgba(255,255,255,0.95); cursor: pointer; font-size: 12px; line-height: 1; box-shadow: 0 1px 3px rgba(0,0,0,0.15); transition: all 0.15s; }
.talent-staff-action:hover { background: var(--accent); color: #fff; transform: scale(1.1); }
.talent-staff-action.delete:hover { background: var(--accent-red); }

/* メモ表示 */
.talent-staff-memo { font-size: 10px; color: var(--text-secondary); margin-top: 4px; padding: 3px 6px; background: #fef9c3; border-left: 2px solid #eab308; border-radius: 3px; }

/* 編集モーダル */
.talent-modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,0.55); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.talent-modal { background: #fff; border-radius: 12px; width: 420px; max-width: 90vw; max-height: 90vh; overflow: auto; box-shadow: 0 20px 50px rgba(0,0,0,0.3); }
.talent-modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.talent-modal-header h3 { font-size: 15px; font-weight: 700; color: var(--text); }
.talent-modal-close { width: 28px; height: 28px; border: none; background: transparent; font-size: 22px; cursor: pointer; color: var(--text-muted); line-height: 1; border-radius: 6px; }
.talent-modal-close:hover { background: var(--bg-hover); color: var(--text); }
.talent-modal-body { padding: 1rem 1.25rem; }
.talent-form-row { margin-bottom: 0.85rem; }
.talent-form-row label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 0.3rem; }
.talent-form-row .form-input { width: 100%; padding: 0.5rem 0.7rem; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; font-family: inherit; }
.talent-form-row .form-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-light); }
.talent-modal-footer { display: flex; justify-content: flex-end; gap: 0.5rem; padding: 0.75rem 1.25rem; border-top: 1px solid var(--border); background: #f8fafc; }

/* 空店舗の見た目 */
.talent-store-empty { background: #f8fafc; border-style: dashed; }
.talent-store-empty .talent-store-name { color: var(--text-muted); }
.talent-store-empty .talent-store-count { background: var(--border-light); color: var(--text-muted); }
.talent-empty-msg { font-size: 11px; color: var(--text-muted); text-align: center; padding: 1.5rem 0.5rem; font-style: italic; }

/* シナリオ一覧 */
.talent-scenario-list { display: flex; flex-direction: column; gap: 0.5rem; }
.talent-scenario-row { display: flex; align-items: center; justify-content: space-between; padding: 0.75rem; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); transition: background 0.15s; }
.talent-scenario-row:hover { background: var(--bg-hover); border-color: var(--accent); }
.talent-scenario-info { flex: 1; }
.talent-scenario-name { font-weight: 700; font-size: 14px; color: var(--text); }
.talent-scenario-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.talent-scenario-actions { display: flex; gap: 0.4rem; }
.talent-scenario-actions button { padding: 0.35rem 0.7rem; font-size: 11px; border-radius: 6px; cursor: pointer; }

/* ===== ログイン画面 ===== */
.login-overlay { position: fixed; inset: 0; background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%); display: flex; align-items: center; justify-content: center; z-index: 9999; padding: 1rem; }
.login-card { background: #fff; border-radius: 16px; padding: 2.5rem 2rem; width: 100%; max-width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,0.4); }
.login-logo { font-size: 28px; font-weight: 800; text-align: center; background: linear-gradient(135deg, #6366f1, #8b5cf6); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; margin-bottom: 0.25rem; letter-spacing: -0.5px; }
.login-title { font-size: 16px; font-weight: 700; color: var(--text); text-align: center; margin-bottom: 0.25rem; }
.login-subtitle { font-size: 12px; color: var(--text-muted); text-align: center; margin-bottom: 1.75rem; }
.login-row { margin-bottom: 1rem; }
.login-row label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 0.35rem; }
.login-row input { width: 100%; padding: 0.65rem 0.85rem; border: 1.5px solid var(--border); border-radius: 8px; font-size: 14px; font-family: inherit; transition: border-color 0.15s, box-shadow 0.15s; }
.login-row input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.login-error { background: #fee2e2; color: #b91c1c; padding: 0.5rem 0.75rem; border-radius: 6px; font-size: 12px; margin-bottom: 0.75rem; border-left: 3px solid #dc2626; }
.login-btn { width: 100%; padding: 0.75rem 1rem; background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; font-weight: 700; font-size: 14px; border: none; border-radius: 8px; cursor: pointer; transition: transform 0.1s, box-shadow 0.15s; }
.login-btn:hover { box-shadow: 0 6px 16px rgba(99,102,241,0.4); transform: translateY(-1px); }
.login-btn:active { transform: translateY(0); }
.login-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* サイドバーのユーザー情報・ログアウト */
.sidebar-user { padding: 0.65rem 1.25rem; margin: 0 0.5rem 0.5rem; border-radius: 8px; background: rgba(255,255,255,0.04); display: flex; align-items: center; gap: 0.5rem; }
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: 13px; font-weight: 700; color: #fff; line-height: 1.2; }
.sidebar-user-role { font-size: 10px; color: #94a3b8; margin-top: 1px; }
.sidebar-user-role.admin { color: #fbbf24; }
.sidebar-user-role.viewer { color: #06b6d4; }
.sidebar-logout { width: 28px; height: 28px; padding: 0; background: rgba(239,68,68,0.15); border: 1px solid rgba(239,68,68,0.25); color: #f87171; border-radius: 6px; cursor: pointer; font-size: 14px; transition: all 0.15s; }
.sidebar-logout:hover { background: rgba(239,68,68,0.3); color: #fff; }

/* Viewer モード時の非表示要素 */
body.role-viewer .viewer-hidden { display: none !important; }
/* admin（管理者）モード時の非表示要素 = viewer 専用UI */
body.role-admin .admin-hidden { display: none !important; }
/* 未ログイン時は両方非表示 */
body:not(.role-admin):not(.role-viewer) .viewer-hidden,
body:not(.role-admin):not(.role-viewer) .admin-hidden { display: none !important; }

/* 健康度バッジ */
.health-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 700; }
.health-good { background: #dcfce7; color: #166534; }
.health-mid { background: #fef3c7; color: #92400e; }
.health-warn { background: #fee2e2; color: #b91c1c; }

/* カテゴリバッジ（高級店・新店） */
.cat-badge { display: inline-block; padding: 1px 6px; border-radius: 4px; font-size: 10px; font-weight: 700; margin-left: 4px; vertical-align: middle; cursor: help; }
.cat-premium { background: linear-gradient(135deg, #fef3c7, #fde68a); color: #92400e; border: 1px solid #f59e0b; }
.cat-new { background: linear-gradient(135deg, #dcfce7, #bbf7d0); color: #166534; border: 1px solid #22c55e; }

/* 店舗比較ヒートマップテーブル */
.heatmap-table { width: 100%; border-collapse: separate; border-spacing: 2px; font-size: 12px; font-variant-numeric: tabular-nums; }
.heatmap-table thead th { background: #1e293b; color: #e2e8f0; padding: 0.55rem 0.6rem; font-weight: 700; font-size: 11px; cursor: pointer; user-select: none; position: sticky; top: 0; text-align: center; border-radius: 6px; }
.heatmap-table thead th:first-child { text-align: left; padding-left: 0.85rem; }
.heatmap-table thead th:hover { background: #334155; }
.heatmap-table thead th.sort-asc::after { content: ' ▲'; opacity: 0.8; font-size: 9px; }
.heatmap-table thead th.sort-desc::after { content: ' ▼'; opacity: 0.8; font-size: 9px; }
.heatmap-table tbody td { padding: 0.5rem 0.6rem; text-align: center; border-radius: 4px; font-weight: 600; transition: transform 0.1s; }
.heatmap-table tbody td.name-cell { text-align: left; font-weight: 700; background: #f1f5f9; color: #0f172a; padding: 0.5rem 0.85rem; }
.heatmap-table tbody tr:hover td { transform: scale(1.02); }
.heatmap-table tbody tr:hover td.name-cell { background: #e2e8f0; cursor: pointer; }
.hm-cell-strong { background: #16a34a; color: #fff; }
.hm-cell-good { background: #86efac; color: #14532d; }
.hm-cell-mid { background: #fef9c3; color: #78350f; }
.hm-cell-weak { background: #fca5a5; color: #7f1d1d; }
.hm-cell-poor { background: #dc2626; color: #fff; }
.hm-cell-na { background: #f1f5f9; color: #94a3b8; }
.heatmap-legend { display: flex; gap: 0.75rem; font-size: 11px; color: #64748b; padding: 0.6rem 0.85rem 0.3rem; }

/* viewer ダッシュボード: 全店概要ボード */
.consult-overview { background: linear-gradient(135deg, #f0f9ff, #fdf4ff); border-left: 4px solid #6366f1; border-radius: 10px; padding: 1rem 1.25rem; margin-bottom: 1.25rem; }
.consult-overview h4 { margin: 0 0 0.5rem; color: #4338ca; font-size: 14px; }
.consult-watch-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 0.6rem; margin-top: 0.5rem; }
.consult-watch-card { background: #fff; border: 1px solid #fde68a; border-left: 3px solid #f59e0b; border-radius: 8px; padding: 0.55rem 0.75rem; }
.consult-watch-card.critical { border-color: #fca5a5; border-left-color: #dc2626; }
.consult-watch-name { font-weight: 700; font-size: 13px; color: #0f172a; }
.consult-watch-issues { font-size: 11px; color: #475569; margin-top: 3px; line-height: 1.5; }

/* 個別面談候補マーキング */
.meeting-flag { background: #fef3c7; color: #92400e; padding: 1px 5px; border-radius: 4px; font-size: 10px; font-weight: 700; margin-left: 4px; }
.meeting-flag.urgent { background: #fee2e2; color: #b91c1c; }

/* 店舗別ページ: 先月比サマリー */
.store-mom-summary { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.9rem 1.1rem; margin-bottom: 1rem; box-shadow: var(--shadow-sm); }
.store-mom-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.6rem; }
.store-mom-cell { padding: 0.4rem 0.6rem; background: var(--bg); border-radius: 6px; }
.store-mom-label { font-size: 10.5px; color: var(--text-muted); margin-bottom: 2px; }
.store-mom-value { font-size: 18px; font-weight: 800; color: var(--text); }
.store-mom-diff { font-size: 11px; margin-top: 1px; font-weight: 600; }
.store-mom-up { color: #16a34a; }
.store-mom-down { color: #dc2626; }
.store-mom-flat { color: #64748b; }

/* viewer 時: キャスト一覧テーブルから 時給/接客時給/給料 の列を非表示
   列順: 1.# 2.名前 3.グレード 4.出勤 5.時給 6.接客時給 7.時間 8.給料 9.本指名 ... */
body.role-viewer .cast-table thead th:nth-child(5),
body.role-viewer .cast-table thead th:nth-child(6),
body.role-viewer .cast-table thead th:nth-child(8),
body.role-viewer .cast-table tbody td:nth-child(5),
body.role-viewer .cast-table tbody td:nth-child(6),
body.role-viewer .cast-table tbody td:nth-child(8) { display: none; }

/* viewer 時に売上情報がチラ見えする経営サマリーKPIブロックを念のため再保証 */
body.role-viewer #target-section,
body.role-viewer #exec-summary-section { display: none !important; }


/* ===== Heaven Access Analysis ===== */
.heaven-section { background: var(--surface, #fff); border-radius: 12px; padding: 1rem; }
.heaven-kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.6rem; margin-bottom: 0.5rem; }
.heaven-kpi-card { background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%); border: 1px solid #bae6fd; border-radius: 8px; padding: 0.7rem 0.8rem; }
.heaven-kpi-card.cv { background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%); border-color: #fcd34d; }
.heaven-kpi-card.engage { background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%); border-color: #a7f3d0; }
.heaven-kpi-card.alert { background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%); border-color: #fca5a5; }
.heaven-kpi-card .label { font-size: 11px; color: #475569; font-weight: 600; margin-bottom: 0.2rem; }
.heaven-kpi-card .value { font-size: 18px; font-weight: 800; color: #0f172a; }
.heaven-kpi-card .sub { font-size: 10px; color: #64748b; margin-top: 0.15rem; }

.heaven-cast-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.heaven-cast-table thead th { background: #1e293b; color: #e2e8f0; padding: 0.5rem 0.5rem; text-align: left; font-size: 11px; font-weight: 700; }
.heaven-cast-table thead th.cell-num { text-align: right; }
.heaven-cast-table tbody td { padding: 0.45rem 0.5rem; border-bottom: 1px solid #f1f5f9; }
.heaven-cast-table tbody td.cell-num { text-align: right; font-variant-numeric: tabular-nums; }
.heaven-cast-table tbody tr.hot { background: #fef9c3; }
.heaven-cast-table tbody tr.hot td:first-child::before { content: "🔥"; }
.heaven-cast-table tbody tr.cool { background: #f1f5f9; color: #94a3b8; }
.heaven-cast-table tbody tr:hover { background: #e0f2fe; cursor: pointer; }
.heaven-cast-table .cast-link { color: #0369a1; font-weight: 600; }

.corr-row { display: flex; justify-content: space-between; padding: 0.35rem 0.25rem; border-bottom: 1px solid #f1f5f9; }
.corr-row:last-child { border-bottom: none; }
.corr-row .label { font-size: 12px; color: #475569; }
.corr-row .value { font-weight: 700; font-size: 13px; padding: 0.1rem 0.5rem; border-radius: 4px; min-width: 50px; text-align: center; }
.corr-row .value.strong-pos { background: #16a34a; color: #fff; }
.corr-row .value.pos { background: #86efac; color: #14532d; }
.corr-row .value.neutral { background: #f1f5f9; color: #64748b; }
.corr-row .value.neg { background: #fca5a5; color: #7f1d1d; }
.corr-row .value.strong-neg { background: #dc2626; color: #fff; }


/* ===== Consulting Trends View ===== */
.consult-trend-grid { display:grid; grid-template-columns:repeat(auto-fit, minmax(380px, 1fr)); gap:0.75rem; margin-top:0.5rem; }
.consult-trend-grid .chart-card { padding:0.6rem; }
.consult-trend-grid .chart-card h4 { margin:0 0 0.4rem; font-size:13px; color:#334155; }
.consult-trend-grid .chart-wrap { height:240px; position:relative; }

.consult-matrix { font-size:12px; }
.consult-matrix th { background:#1e293b; color:#e2e8f0; padding:0.5rem 0.5rem; text-align:center; font-size:11px; font-weight:700; }
.consult-matrix td { padding:0.4rem 0.5rem; text-align:right; font-variant-numeric:tabular-nums; }
.consult-matrix td:first-child { text-align:left; }
.consult-matrix tbody tr:hover { background:#f1f5f9; }

.ct-mom-grid { display:flex; flex-direction:column; gap:0.6rem; }
.ct-mom-section h4 { font-size:13px; font-weight:700; }
.ct-mom-row { display:grid; grid-template-columns:repeat(auto-fit, minmax(180px, 1fr)); gap:0.5rem; }
.ct-mom-card { background:#fff; border:1px solid #e2e8f0; border-left-width:4px; border-radius:6px; padding:0.55rem 0.7rem; cursor:pointer; transition:transform 0.15s; }
.ct-mom-card:hover { transform:translateY(-2px); box-shadow:0 4px 8px rgba(0,0,0,0.06); }
.ct-mom-card.good { border-left-color:#16a34a; }
.ct-mom-card.bad { border-left-color:#dc2626; }
.ct-mom-card .ct-mom-store { font-size:11px; color:#0f172a; }
.ct-mom-card .ct-mom-label { font-size:11px; color:#64748b; margin-top:0.1rem; }
.ct-mom-card .ct-mom-pct { font-size:18px; font-weight:800; margin:0.2rem 0; }
.ct-mom-card.good .ct-mom-pct { color:#16a34a; }
.ct-mom-card.bad .ct-mom-pct { color:#dc2626; }
.ct-mom-card .ct-mom-vals { font-size:11px; color:#475569; font-variant-numeric:tabular-nums; }


/* Pace projection indicators */
.ct-mom-proj { color:#92400e; background:#fef3c7; padding:1px 5px; border-radius:3px; font-size:9px; font-weight:600; margin-left:0.2rem; }
.ct-mom-actual { font-size:10px; color:#64748b; margin-top:0.15rem; font-style:italic; }


/* Trends range filter bar */
.trends-range-bar { display:flex; align-items:center; gap:0.5rem; padding:0.6rem 0.8rem; background:#fff; border-radius:8px; margin-bottom:1rem; box-shadow:0 1px 3px rgba(0,0,0,0.04); flex-wrap:wrap; }
.trends-range-label { font-size:13px; font-weight:600; color:#475569; margin-right:0.3rem; }
.trends-range-btn { background:#f1f5f9; border:1px solid #e2e8f0; color:#475569; padding:0.4rem 0.9rem; border-radius:6px; font-size:12px; font-weight:600; cursor:pointer; transition:all 0.15s; }
.trends-range-btn:hover { background:#e2e8f0; }
.trends-range-btn.active { background:linear-gradient(135deg,#2563eb,#1d4ed8); color:#fff; border-color:#1d4ed8; box-shadow:0 2px 4px rgba(37,99,235,0.3); }


/* Course breakdown KPI */
.cb-kpi-row { display:grid; grid-template-columns:repeat(auto-fit, minmax(140px, 1fr)); gap:0.6rem; }
.cb-kpi-card { background:linear-gradient(135deg,#f5f3ff,#ede9fe); border:1px solid #ddd6fe; border-radius:8px; padding:0.7rem 0.8rem; }
.cb-kpi-card.long { background:linear-gradient(135deg,#fef3c7,#fde68a); border-color:#fcd34d; }
.cb-kpi-card.short { background:linear-gradient(135deg,#dbeafe,#bfdbfe); border-color:#93c5fd; }
.cb-kpi-card .label { font-size:11px; color:#475569; font-weight:600; }
.cb-kpi-card .value { font-size:18px; font-weight:800; color:#0f172a; }
.cb-kpi-card .sub { font-size:10px; color:#64748b; margin-top:0.15rem; }


/* Course breakdown headline */
.cb-headline { display:grid; grid-template-columns:repeat(auto-fit, minmax(180px, 1fr)); gap:0.8rem; }
.cb-headline-card { padding:1rem 1.2rem; border-radius:10px; color:#fff; text-align:center; box-shadow:0 2px 8px rgba(0,0,0,0.08); }
.cb-headline-card.main { background:linear-gradient(135deg, #2563eb, #1e40af); }
.cb-headline-card.hon { background:linear-gradient(135deg, #f59e0b, #d97706); }
.cb-headline-card.avg { background:linear-gradient(135deg, #14b8a6, #0d9488); }
.cb-headline-card.long { background:linear-gradient(135deg, #ec4899, #db2777); }
.cb-headline-card .label { font-size:12px; font-weight:600; opacity:0.95; margin-bottom:0.3rem; letter-spacing:0.05em; }
.cb-headline-card .value { font-size:28px; font-weight:800; letter-spacing:-0.02em; line-height:1.1; }
.cb-headline-card .sub { font-size:11px; opacity:0.9; margin-top:0.3rem; }


/* === Store Manager mode (single-store view) === */
/* store selector を読み取り専用＆控えめに */
body.manager-single #store-selector { pointer-events:none; opacity:0.7; background:#f1f5f9; }
/* 複数店店長は selector で店切替可、視覚で強調 */
body.manager-multi #store-selector { border:2px solid #10b981; font-weight:700; }
/* ダッシュボード上の他店比較セクションを非表示 */
body.manager-mode .chart-row,
body.manager-mode #heatmap-container,
body.manager-mode #vc-heatmap,
body.manager-mode .consult-overview,
body.manager-mode #vc-watch-list,
body.manager-mode .ranking-card,
body.manager-mode #ranking-table,
body.manager-mode .table-card { display:none !important; }
/* ナビ: 月次推移は単店なら線グラフ意味あるので残す */
body.manager-mode .nav-item[data-page="trends"] { /* keep */ }
/* 店長モード時のヘッダーバッジ */
body.manager-mode #sidebar-user-role { background:linear-gradient(135deg,#10b981,#059669); color:#fff; }


/* === 経理担当者向け 請求書AI一括取込 (大きく使いやすく) === */
.acct-ocr-friendly { background:linear-gradient(135deg,#fffbeb,#fef3c7); border:2px solid #fcd34d; border-radius:14px; padding:1.4rem; margin-bottom:1.5rem; }
.acct-ocr-header h2 { margin:0 0 0.6rem; font-size:22px; color:#78350f; font-weight:800; }
.acct-ocr-header p { margin:0; font-size:15px; color:#92400e; line-height:1.6; }
.acct-ocr-drop { background:#fff; border:3px dashed #f59e0b; border-radius:12px; padding:2.4rem 1.5rem; text-align:center; transition:all 0.2s; margin-top:1rem; cursor:pointer; }
.acct-ocr-drop:hover { background:#fffbeb; border-color:#d97706; }
.acct-ocr-drop.dragover { background:#fef3c7; border-color:#d97706; transform:scale(1.01); }
.acct-ocr-drop-inner h3 { margin:0.6rem 0 0.4rem; font-size:20px; color:#78350f; }
.acct-ocr-drop-inner p { margin:0; color:#92400e; font-size:14px; }
.acct-ocr-buttons { margin-top:1.2rem; display:flex; gap:1rem; justify-content:center; }
.btn-acct-ocr-pri { background:linear-gradient(135deg,#f59e0b,#d97706); color:#fff; border:none; padding:0.8rem 1.6rem; border-radius:8px; font-size:16px; font-weight:700; cursor:pointer; box-shadow:0 2px 6px rgba(217,119,6,0.3); }
.btn-acct-ocr-pri:hover { transform:translateY(-1px); box-shadow:0 4px 10px rgba(217,119,6,0.4); }
.btn-acct-ocr-pri:disabled { background:#cbd5e1; cursor:not-allowed; box-shadow:none; transform:none; }
.btn-acct-ocr-sec { background:#fff; color:#78350f; border:2px solid #fcd34d; padding:0.8rem 1.4rem; border-radius:8px; font-size:15px; font-weight:600; cursor:pointer; }
.btn-acct-ocr-sec:hover { background:#fef3c7; }
.acct-ocr-loading { text-align:center; padding:2rem; background:#fff; border-radius:10px; margin-top:1rem; }
.spinner-lg { width:48px; height:48px; border:5px solid #fcd34d; border-top-color:#d97706; border-radius:50%; animation:spin 1s linear infinite; margin:0 auto; }
@keyframes spin { to { transform:rotate(360deg); } }

.acct-ocr-result { background:#fff; border:1px solid #e2e8f0; border-radius:10px; padding:1rem; margin-top:1rem; }
.acct-ocr-result-header { display:flex; justify-content:space-between; align-items:center; margin-bottom:0.6rem; flex-wrap:wrap; gap:0.6rem; }
.acct-ocr-result-header h3 { margin:0; font-size:17px; color:#1e293b; }
.acct-ocr-result-help { background:#f0f9ff; border-left:4px solid #0ea5e9; padding:0.7rem 0.9rem; margin-bottom:0.8rem; font-size:13px; color:#0c4a6e; border-radius:4px; }
.acct-ocr-table { width:100%; border-collapse:collapse; font-size:13px; }
.acct-ocr-table thead th { background:#1e293b; color:#e2e8f0; padding:0.55rem 0.5rem; text-align:left; font-size:11px; font-weight:700; }
.acct-ocr-table tbody td { padding:0.4rem 0.5rem; border-bottom:1px solid #f1f5f9; vertical-align:middle; }
.acct-ocr-table tbody tr:hover { background:#fffbeb; }
.acct-ocr-table tbody tr.row-disabled { opacity:0.4; text-decoration:line-through; }
.acct-ocr-table input[type=text], .acct-ocr-table input[type=number], .acct-ocr-table select {
    width:100%; padding:0.35rem 0.4rem; border:1px solid #cbd5e1; border-radius:4px; font-size:13px; background:#fff;
}
.acct-ocr-table input[type=number] { text-align:right; font-variant-numeric:tabular-nums; }
.acct-ocr-conf-high { background:#16a34a; color:#fff; padding:2px 6px; border-radius:3px; font-size:10px; font-weight:600; }
.acct-ocr-conf-medium { background:#f59e0b; color:#fff; padding:2px 6px; border-radius:3px; font-size:10px; font-weight:600; }
.acct-ocr-conf-low { background:#dc2626; color:#fff; padding:2px 6px; border-radius:3px; font-size:10px; font-weight:600; }


/* ===== AI Chat Floating Panel (admin only) ===== */
/* admin-only クラスは body.role-admin 配下でのみ表示 */
body:not(.role-admin) .admin-only { display:none !important; }

.aichat-fab {
    position:fixed; right:24px; bottom:24px; z-index:9000;
    width:56px; height:56px; border-radius:50%;
    background:linear-gradient(135deg, #f97316, #ea580c);
    color:#fff; border:none; cursor:pointer;
    box-shadow:0 4px 16px rgba(234,88,12,0.4);
    transition:all 0.2s;
}
.aichat-fab:hover { transform:scale(1.06); box-shadow:0 6px 24px rgba(234,88,12,0.5); }

.aichat-panel {
    position:fixed; right:24px; bottom:90px; z-index:9000;
    width:480px; max-width:calc(100vw - 40px);
    height:640px; max-height:calc(100vh - 120px);
    background:#fff; border-radius:14px;
    box-shadow:0 12px 48px rgba(0,0,0,0.2);
    border:1px solid #e2e8f0;
    display:flex; flex-direction:column; overflow:hidden;
}
.aichat-header {
    background:linear-gradient(135deg, #1e293b, #0f172a); color:#fff;
    padding:0.9rem 1.1rem; display:flex; justify-content:space-between; align-items:center;
}
.aichat-header h3 { margin:0; font-size:16px; }
.aichat-close-btn { background:transparent; border:none; color:#fff; font-size:24px; cursor:pointer; line-height:1; padding:0 6px; }
.aichat-close-btn:hover { color:#fbbf24; }

.aichat-help {
    background:#fef3c7; border-bottom:1px solid #fcd34d;
    padding:0.7rem 1rem; font-size:11.5px; color:#78350f; line-height:1.5;
}
.aichat-help ul { margin:0.3rem 0 0 1.2rem; padding:0; }
.aichat-help li { margin-bottom:0.15rem; }

.aichat-messages {
    flex:1; overflow-y:auto; padding:1rem; background:#f8fafc;
    display:flex; flex-direction:column; gap:0.7rem;
}
.aichat-msg { max-width:90%; padding:0.7rem 0.9rem; border-radius:10px; font-size:13.5px; line-height:1.6; }
.aichat-msg.user { align-self:flex-end; background:#2563eb; color:#fff; }
.aichat-msg.assistant { align-self:flex-start; background:#fff; border:1px solid #e2e8f0; color:#0f172a; }
.aichat-msg.error { align-self:center; background:#fee2e2; border:1px solid #fca5a5; color:#7f1d1d; font-size:12px; }
.aichat-msg table { border-collapse:collapse; margin:0.5rem 0; font-size:12px; }
.aichat-msg table th, .aichat-msg table td { border:1px solid #cbd5e1; padding:0.3rem 0.55rem; }
.aichat-msg table th { background:#f1f5f9; font-weight:700; }
.aichat-msg code { background:#f1f5f9; padding:1px 4px; border-radius:3px; font-size:11.5px; }
.aichat-msg pre { background:#0f172a; color:#e2e8f0; padding:0.6rem; border-radius:5px; overflow-x:auto; font-size:11px; }
.aichat-msg ul, .aichat-msg ol { margin:0.3rem 0 0.3rem 1.4rem; padding:0; }
.aichat-msg h1, .aichat-msg h2, .aichat-msg h3, .aichat-msg h4 { margin:0.6rem 0 0.3rem; }

.aichat-input-row {
    border-top:1px solid #e2e8f0; padding:0.7rem; background:#fff;
    display:flex; gap:0.5rem; align-items:flex-end;
}
.aichat-input-row textarea {
    flex:1; resize:none; border:1px solid #cbd5e1; border-radius:6px;
    padding:0.55rem 0.7rem; font-size:13px; font-family:inherit;
}
.aichat-input-row textarea:focus { outline:none; border-color:#2563eb; box-shadow:0 0 0 2px rgba(37,99,235,0.15); }
.aichat-send-btn {
    background:linear-gradient(135deg, #f97316, #ea580c); color:#fff;
    border:none; padding:0.6rem 1rem; border-radius:6px; font-weight:700;
    cursor:pointer; font-size:13px; white-space:nowrap;
}
.aichat-send-btn:hover { filter:brightness(1.08); }
.aichat-send-btn:disabled { background:#cbd5e1; cursor:not-allowed; }

.aichat-status { padding:0.3rem 1rem; font-size:11px; color:#64748b; min-height:1.4em; background:#f8fafc; }
.aichat-loading { color:#f97316; }
.aichat-loading::before { content:"⟳ "; display:inline-block; animation:spin 1.2s linear infinite; }

/* レスポンシブ */
@media (max-width: 640px) {
    .aichat-panel { right:8px; bottom:80px; width:calc(100vw - 16px); height:calc(100vh - 100px); }
    .aichat-fab { right:12px; bottom:12px; }
}


/* === AI Chat 音声入力 === */
.aichat-buttons { display:flex; flex-direction:column; gap:0.4rem; align-items:stretch; }
.aichat-mic-btn {
    background:#fff; color:#475569; border:2px solid #cbd5e1;
    width:42px; height:38px; border-radius:6px; font-size:18px;
    cursor:pointer; transition:all 0.15s; line-height:1;
    display:flex; align-items:center; justify-content:center;
}
.aichat-mic-btn:hover { background:#f1f5f9; border-color:#94a3b8; }
.aichat-mic-btn.recording {
    background:linear-gradient(135deg, #dc2626, #b91c1c);
    color:#fff; border-color:#b91c1c;
    animation:aichat-mic-pulse 1.2s ease-in-out infinite;
}
.aichat-mic-btn.unsupported { opacity:0.4; cursor:not-allowed; }
@keyframes aichat-mic-pulse {
    0%,100% { box-shadow:0 0 0 0 rgba(220,38,38,0.6); }
    50%     { box-shadow:0 0 0 8px rgba(220,38,38,0); }
}

/* マイク使用中の入力欄ヒント */
.aichat-input-row.recording textarea {
    background:#fef2f2; border-color:#fca5a5;
}
.aichat-mic-hint { color:#b91c1c; font-weight:700; }
.aichat-mic-hint::before { content:"● "; animation:aichat-mic-pulse 1.2s ease-in-out infinite; }

/* ===== 経理 P/L サマリー (経営ダッシュボード) ===== */
.pl-warn {
  background: #fef3c7; border: 1px solid #fcd34d; border-radius: 10px;
  padding: 14px 18px; margin-bottom: 18px; color: #92400e; font-size: 14px; line-height: 1.6;
}
/* --- ヒーロー3点セット --- */
.pl-hero {
  display: flex; align-items: stretch; gap: 12px; margin-bottom: 26px; flex-wrap: wrap;
}
.pl-hero-card {
  flex: 1 1 0; min-width: 200px; background: #fff; border-radius: 16px; padding: 22px 24px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06); border: 1px solid #eef2f7; position: relative;
}
.pl-hero-sales { border-top: 5px solid #2563eb; }
.pl-hero-expense { border-top: 5px solid #f59e0b; }
.pl-hero-profit { border-top: 5px solid var(--profit-color, #16a34a); }
.pl-hero-label { font-size: 14px; color: #64748b; font-weight: 600; margin-bottom: 10px; }
.pl-hero-value { font-size: 34px; font-weight: 800; letter-spacing: -0.5px; color: #0f172a; line-height: 1.1; }
.pl-hero-sub { font-size: 13px; color: #94a3b8; margin-top: 6px; }
.pl-hero-op {
  display: flex; align-items: center; font-size: 30px; font-weight: 300; color: #cbd5e1; padding: 0 4px;
}
.pl-na { font-size: 12px; color: #f59e0b; font-weight: 600; }
/* --- 前月比バッジ --- */
.pl-delta {
  display: inline-block; margin-top: 10px; font-size: 12px; font-weight: 700;
  padding: 3px 10px; border-radius: 20px;
}
.pl-delta-good { background: #dcfce7; color: #15803d; }
.pl-delta-bad { background: #fee2e2; color: #b91c1c; }
.pl-delta-flat { background: #f1f5f9; color: #64748b; }
/* --- P/L ステップ --- */
.pl-section-title {
  font-size: 16px; font-weight: 700; color: #1e293b; margin: 24px 0 14px; padding-bottom: 8px;
  border-bottom: 2px solid #f1f5f9;
}
.pl-waterfall { display: flex; flex-direction: column; gap: 6px; max-width: 560px; }
.pl-step {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px 18px; border-radius: 10px; background: #f8fafc;
}
.pl-step-label { font-size: 15px; font-weight: 600; color: #334155; flex: 0 0 auto; }
.pl-step-amt { font-size: 18px; font-weight: 700; color: #0f172a; font-variant-numeric: tabular-nums; margin-left: auto; }
.pl-step-sub { font-size: 12px; color: #94a3b8; flex: 0 0 auto; width: 110px; text-align: right; }
.pl-step-base { background: #eff6ff; }
.pl-step-base .pl-step-amt { color: #2563eb; }
.pl-step-minus .pl-step-amt { color: #dc2626; }
.pl-step-plus .pl-step-amt { color: #16a34a; }
.pl-step-subtotal { background: #f0f9ff; border: 1px dashed #7dd3fc; }
.pl-step-subtotal .pl-step-label, .pl-step-subtotal .pl-step-amt { color: #0369a1; font-weight: 800; }
.pl-step-final { background: linear-gradient(135deg, #dcfce7, #bbf7d0); border: 1px solid #4ade80; }
.pl-step-final .pl-step-label { color: #14532d; font-weight: 800; font-size: 16px; }
.pl-step-final .pl-step-amt { color: #15803d; font-weight: 900; font-size: 22px; }
/* --- 経費内訳テーブル --- */
.pl-exp-table { display: flex; flex-direction: column; gap: 2px; }
.pl-exp-row {
  display: grid; grid-template-columns: 150px 1fr 130px 60px 70px;
  align-items: center; gap: 12px; padding: 9px 12px; border-radius: 8px;
}
.pl-exp-row:hover { background: #f8fafc; }
.pl-exp-head { font-size: 12px; color: #94a3b8; font-weight: 700; border-bottom: 1px solid #e2e8f0; }
.pl-exp-name { font-size: 14px; font-weight: 600; color: #334155; }
.pl-exp-bar-wrap { background: #f1f5f9; border-radius: 6px; height: 10px; overflow: hidden; }
.pl-exp-bar { height: 100%; background: linear-gradient(90deg, #f59e0b, #fbbf24); border-radius: 6px; }
.pl-exp-amt { font-size: 14px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; color: #0f172a; }
.pl-exp-pct { font-size: 13px; text-align: right; color: #64748b; }
.pl-exp-deltacell { text-align: right; }
.pl-exp-delta { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 12px; }
.pl-exp-delta.up { background: #fee2e2; color: #b91c1c; }
.pl-exp-delta.down { background: #dcfce7; color: #15803d; }
.pl-exp-total { background: #f1f5f9; font-weight: 800; margin-top: 4px; }
.pl-exp-total .pl-exp-name, .pl-exp-total .pl-exp-amt { color: #0f172a; font-weight: 800; }
@media (max-width: 720px) {
  .pl-hero-op { display: none; }
  .pl-hero-card { flex-basis: 100%; }
  .pl-exp-row { grid-template-columns: 110px 1fr 100px 48px; }
  .pl-exp-deltacell { display: none; }
}

/* ===== 店舗別純利益テーブル (P/L) ===== */
.pl-store-table { display: flex; flex-direction: column; gap: 3px; max-width: 640px; }
.pl-store-row {
  display: grid; grid-template-columns: 130px 1fr 130px; align-items: center; gap: 12px;
  padding: 8px 12px; border-radius: 8px;
}
.pl-store-row:hover { background: #f8fafc; }
.pl-store-name { font-size: 14px; font-weight: 600; color: #334155; }
.pl-store-barwrap { position: relative; height: 14px; display: flex; align-items: center; }
.pl-store-bar { height: 100%; border-radius: 4px; min-width: 2px; }
.pl-store-bar.pos { background: linear-gradient(90deg, #4ade80, #16a34a); }
.pl-store-bar.neg { background: linear-gradient(90deg, #fca5a5, #dc2626); }
.pl-store-profit { font-size: 15px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.pl-store-profit.pos { color: #15803d; }
.pl-store-profit.neg { color: #dc2626; }
.pl-fjg-sales { font-size: 12px; color: #94a3b8; }
.pl-store-total { background: #f1f5f9; font-weight: 800; margin-top: 4px; }
.pl-store-total .pl-store-name { font-weight: 800; }
@media (max-width: 720px) {
  .pl-store-row { grid-template-columns: 100px 1fr 110px; }
}

/* ===== 経理タブ グループ化 ===== */
.acct-tabs-grouped { display: flex; gap: 12px; padding: 0 0 1rem; flex-wrap: wrap; align-items: stretch; }
.acct-tab-group {
  display: flex; flex-direction: column; gap: 6px;
  padding: 8px 10px 10px; border-radius: 12px; border: 1.5px solid #e2e8f0; background: #fafbfc;
}
.acct-tab-group-input { border-color: #bfdbfe; background: #eff6ff; }
.acct-tab-group-auto  { border-color: #e2e8f0; background: #f8fafc; }
.acct-tab-group-label { font-size: 11px; font-weight: 700; color: #64748b; letter-spacing: 0.03em; padding-left: 2px; }
.acct-tab-group-input .acct-tab-group-label { color: #2563eb; }
.acct-tab-group-btns { display: flex; gap: 4px; flex-wrap: wrap; }
/* 自動集計タブは閲覧専用なので控えめな見た目 */
.acct-tab-group-auto .acct-tab { background: #f1f5f9; color: #64748b; border-style: dashed; }
.acct-tab-group-auto .acct-tab.active { background: #475569; color: #fff; border-style: solid; border-color: #475569; }
@media (max-width: 900px) {
  .acct-tabs-grouped { flex-direction: column; }
  .acct-tab-group { width: 100%; }
}

/* ===== 経理 入力テーブル 操作性改善 ===== */
/* スクロール領域に高さ制限+縦横スクロール、ヘッダー固定 */
.acct-table-wrap { max-height: 70vh; overflow: auto; border: 1px solid #e2e8f0; border-radius: 10px; }
.acct-edit-table { border-collapse: separate; border-spacing: 0; }
/* ヘッダー行を上部固定 */
.acct-edit-table thead th {
  position: sticky; top: 0; z-index: 3;
  background: #1e293b; color: #e2e8f0; font-size: 12px; font-weight: 700;
  padding: 8px 6px; white-space: nowrap;
}
/* 1列目(ビル名/代理店/項目名/従業員名)を左固定 */
.acct-edit-table tbody td:first-child,
.acct-edit-table thead th:first-child {
  position: sticky; left: 0; z-index: 2; background: #fff;
  box-shadow: 2px 0 4px rgba(0,0,0,0.04); min-width: 150px; max-width: 200px;
}
.acct-edit-table thead th:first-child { z-index: 4; background: #1e293b; }
.acct-edit-table tbody tr:hover td:first-child { background: #f8fafc; }
/* 1列目のビル名等が見切れないよう text入力を全幅に */
.acct-edit-table tbody td:first-child input[type="text"] {
  width: 100%; min-width: 140px; font-weight: 600; border: none; background: transparent; font-size: 13px;
}
/* 合計列(最終列)を右固定して常に見える */
.acct-edit-table tbody td:last-child,
.acct-edit-table thead th:last-child {
  position: sticky; right: 0; z-index: 2; background: #fefce8;
  font-weight: 700; box-shadow: -2px 0 4px rgba(0,0,0,0.04);
}
.acct-edit-table thead th:last-child { z-index: 4; background: #1e293b; }
/* 数値入力欄: フォーカス時に強調して入力位置を見失わない */
.acct-edit-table input[type="number"] {
  width: 72px; padding: 6px 4px; text-align: right; border: 1px solid #e2e8f0; border-radius: 4px;
  font-size: 13px; font-variant-numeric: tabular-nums; transition: all 0.1s;
}
.acct-edit-table input[type="number"]:focus {
  border-color: #2563eb; background: #eff6ff; outline: 2px solid #bfdbfe; outline-offset: -1px;
}
/* 入力済セルは薄く色付けして空欄と区別 */
.acct-edit-table input[type="number"]:not(:placeholder-shown) { background: #f0fdf4; }

/* ===== 経理 入力テーブル フッター(店舗別合計) ===== */
.acct-edit-table tfoot td {
  position: sticky; bottom: 0; z-index: 3;
  background: #ecfdf5; color: #14532d; font-weight: 700; font-size: 13px;
  padding: 8px 6px; border-top: 2px solid #16a34a;
}
/* フッター1列目(ラベル)も左固定 */
.acct-edit-table tfoot td:first-child {
  left: 0; z-index: 4; box-shadow: 2px 0 4px rgba(0,0,0,0.04);
}
/* フッター最終列(総合計)も右固定 */
.acct-edit-table tfoot td:last-child {
  right: 0; z-index: 4; background: #d1fae5; box-shadow: -2px 0 4px rgba(0,0,0,0.04);
}

/* ===== 経理入力テーブル ヘッダー視認性 強制修正 ===== */
/* data-table の既存スタイルより詳細度を上げて、濃紺背景+白文字を確実に適用 */
.data-table.acct-edit-table thead th {
  background: #1e293b !important;
  color: #ffffff !important;
  font-weight: 700 !important;
  text-align: center !important;
}
/* 1列目ヘッダー(区分/ビル名/項目名等)も濃紺 */
.data-table.acct-edit-table thead th:first-child {
  background: #0f172a !important; color: #ffffff !important; text-align: left !important;
}
/* 最終列(合計)ヘッダーは濃紺背景に黄色文字でアクセント */
.data-table.acct-edit-table thead th:last-child {
  background: #1e293b !important; color: #fde68a !important;
}

/* ===== 目標達成履歴ヒートマップ ===== */
.ach-header { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:0.5rem; margin-bottom:0.75rem; }
.ach-legend { display:flex; gap:0.5rem; align-items:center; }
.ach-leg { font-size:11px; padding:2px 8px; border-radius:4px; font-weight:700; }
.ach-table-wrap { overflow:auto; max-height:calc(100vh - 200px); border:1px solid var(--border, #e2e8f0); border-radius:8px; }
.ach-table { border-collapse:separate; border-spacing:0; font-size:12px; }
.ach-table th, .ach-table td { padding:5px 7px; text-align:center; white-space:nowrap; border-bottom:1px solid #eef2f7; border-right:1px solid #eef2f7; }
.ach-table thead th { position:sticky; top:0; z-index:3; background:#1e293b; color:#fff; font-weight:700; }
.ach-store-col { position:sticky; left:0; z-index:2; background:#f8fafc; text-align:left !important; font-weight:700; min-width:120px; box-shadow:2px 0 4px -2px rgba(0,0,0,0.1); }
.ach-table thead th.ach-store-col { z-index:4; background:#0f172a; }
.ach-rate-col { position:sticky; left:120px; z-index:2; background:#f8fafc; min-width:64px; font-weight:800; box-shadow:2px 0 4px -2px rgba(0,0,0,0.1); }
.ach-table thead th.ach-rate-col { z-index:4; background:#0f172a; }
.ach-rate-sub { font-size:10px; font-weight:600; color:#64748b; }
.ach-month-col { min-width:46px; font-size:11px; }
.ach-cell-bonus { background:#c4b5fd; color:#4c1d95; font-weight:700; } /* ボーナス達成=紫(やや濃く) */
.ach-cell-inc { background:#f9a8d4; color:#831843; font-weight:700; }   /* インセン達成=ピンク(やや濃く) */
.ach-cell-ng { background:#ffffff; color:#111827; font-weight:800; border:1px solid #cbd5e1; } /* 未達=白(黒字) 達成色(紫/ピンク)と明確に区別 */
.ach-cell-none { background:#f1f5f9; color:#cbd5e1; }                   /* 目標なし=グレー */
.ach-rate-hi { color:#166534; }
.ach-rate-mid { color:#b45309; }
.ach-rate-lo { color:#991b1b; }

/* ===== 2026-06 改修: 未確定KPI / スケルトン / 進行月注記 / キャスト別損益 ===== */
/* 経費・純利益などデータ未確定月の表示 (¥0 と区別する) */
.kpi-pending {
    font-size: 18px;
    font-weight: 700;
    color: #b45309;
    background: #fef3c7;
    border: 1px dashed #f59e0b;
    border-radius: 6px;
    padding: 2px 10px;
    display: inline-block;
}

/* KPIカードのスケルトンローディング */
.kpi-grid.kpi-loading .kpi-value {
    color: transparent !important;
    background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
    background-size: 200% 100%;
    animation: kpi-shimmer 1.1s ease-in-out infinite;
    border-radius: 6px;
    min-height: 26px;
}
.kpi-grid.kpi-loading .kpi-value > * { visibility: hidden; }
@keyframes kpi-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* 月次推移: 進行月(途中集計)の注記 */
.trends-partial-note {
    font-size: 12px;
    color: #64748b;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 4px 10px;
    margin-left: auto;
}

/* キャスト別損益 */
.cb-kpi {
    background: #fff;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 0.7rem 0.8rem;
    box-shadow: var(--shadow-sm);
}
.cb-kpi-label { font-size: 11px; color: #64748b; font-weight: 600; }
.cb-kpi-value { font-size: 19px; font-weight: 800; color: #0f172a; margin-top: 2px; }
.cast-pnl-table th.clickable { cursor: pointer; user-select: none; }
.cast-pnl-table th.clickable:hover { background: #eef2ff; }
.cast-pnl-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.cast-pnl-table tbody tr:nth-child(even) { background: #f8fafc; }
.cast-pnl-table tbody tr:hover { background: #eef2ff; }
.cast-pnl-grade {
    font-size: 10px;
    color: #6d28d9;
    background: #ede9fe;
    border-radius: 4px;
    padding: 1px 5px;
    font-weight: 700;
}

/* ===== スタッフ紹介ボーナス ===== */
.referral-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}
.referral-toolbar-left { display: flex; flex-direction: column; gap: 4px; }
.referral-threshold-box { display: flex; align-items: center; gap: 8px; }
.referral-threshold-box label { font-size: 12px; color: #475569; font-weight: 600; }
.referral-threshold-box input {
    width: 130px; padding: 6px 10px; border: 1px solid var(--border);
    border-radius: 6px; font-size: 14px; text-align: right;
}

.ref-achieved-card {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    background: linear-gradient(135deg, #fff7ed, #ffedd5);
    border: 1px solid #fdba74; border-left: 4px solid #f97316;
    border-radius: 10px; padding: 0.9rem 1.1rem; margin-bottom: 0.6rem;
}
.ref-achieved-staff { font-size: 15px; font-weight: 800; color: #9a3412; }
.ref-achieved-detail { font-size: 13px; color: #475569; margin-top: 3px; }
.ref-arrow { color: #fb923c; margin: 0 2px; }
.ref-store { font-size: 12px; color: #64748b; font-weight: 500; }
.ref-pay-btn { white-space: nowrap; }
.ref-status-badge {
    display: inline-block; margin-left: 8px; padding: 2px 8px;
    border-radius: 10px; font-size: 11px; font-weight: 700;
}
.ref-status-applied { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
.ref-status-rejected { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.ref-applied-info { font-size: 12px; color: #64748b; font-style: italic; }
.btn-acct-cancel {
    background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5;
    padding: 6px 12px; border-radius: 6px; cursor: pointer; font-weight: 600;
    margin-left: 6px;
}
.btn-acct-cancel:hover { background: #fecaca; }

.ref-staff-group {
    border: 1px solid var(--border-light); border-radius: 10px;
    padding: 0.8rem 1rem; margin-bottom: 0.8rem; background: #fff;
}
.ref-staff-name { font-size: 14px; font-weight: 800; color: #0f172a; margin-bottom: 0.5rem; }
.ref-staff-count {
    font-size: 11px; color: #6d28d9; background: #ede9fe;
    border-radius: 10px; padding: 1px 8px; margin-left: 6px;
}
.ref-watch-row { padding: 0.5rem 0; border-top: 1px dashed #e2e8f0; }
.ref-watch-head { display: flex; align-items: center; gap: 10px; }
.ref-watch-cast { font-weight: 700; font-size: 13.5px; }
.ref-watch-meta { font-size: 11.5px; color: #64748b; margin-left: auto; }
.ref-progress {
    height: 8px; background: #f1f5f9; border-radius: 4px;
    overflow: hidden; margin: 6px 0 4px;
}
.ref-progress-bar {
    height: 100%; border-radius: 4px;
    background: linear-gradient(90deg, #60a5fa, #2563eb);
    transition: width 0.4s ease;
}
.ref-watch-detail { font-size: 12px; color: #475569; }
.ref-del-btn {
    border: 1px solid #e2e8f0; background: #fff; color: #94a3b8;
    border-radius: 6px; padding: 2px 8px; cursor: pointer; font-size: 12px;
}
.ref-del-btn:hover { color: #ef4444; border-color: #fca5a5; }

.referral-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.referral-form input, .referral-form select {
    padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13.5px;
}
.referral-form input[type="number"] { width: 150px; text-align: right; }

/* キャスト別損益テーブル内の紹介チップ */
.ref-chip {
    display: inline-block; font-size: 11px; font-weight: 700;
    border-radius: 10px; padding: 2px 8px; white-space: nowrap;
}
.ref-chip-watching { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.ref-chip-achieved { background: #fff7ed; color: #c2410c; border: 1px solid #fdba74; }
.ref-chip-paid { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.ref-add-btn {
    border: 1px dashed #cbd5e1; background: #fff; color: #94a3b8;
    border-radius: 10px; padding: 2px 8px; cursor: pointer; font-size: 11px;
}
.ref-add-btn:hover { color: #2563eb; border-color: #93c5fd; background: #eff6ff; }
