/* 加盟店Board のデザイン。
   写した元：直営Board（carseven-dashboard）kpi_dashboard_v22.html の :root の CSS 変数（ベース・テキスト・アクセント・買取の色）と
   .dl-funnel-* の見た目（v22.263 時点）。直営の店舗の色・源泉の色は持ってこない。 */

:root {
  --bg-base: #fafaf9;
  --bg-elevated: #ffffff;
  --bg-subtle: #f4f4f2;
  --border-subtle: rgba(0, 0, 0, 0.05);
  --border-default: rgba(0, 0, 0, 0.08);
  --border-emphasis: rgba(0, 0, 0, 0.14);
  --text-primary: #0a0a0a;
  --text-secondary: #525252;
  --text-tertiary: #a3a3a3;
  --accent-1: #3b82f6;
  --accent-3: #8b5cf6;
  --kaitori-1: #0284c7;
  --kaitori-gradient: linear-gradient(135deg, #0ea5e9, #0369a1);
  --warn: #b45309;
  --warn-bg: rgba(234, 88, 12, 0.10);
  --error: #dc2626;
  --radius: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter Tight', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-base); color: var(--text-primary); font-size: 13px; line-height: 1.5;
}
[hidden] { display: none !important; }
a { color: var(--kaitori-1); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--text-secondary); }
.small { font-size: 11px; }
.na { color: var(--text-tertiary); white-space: nowrap; }
.error-text { color: var(--error); margin-top: 8px; }

/* 画面 */
.screen-center { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { background: var(--bg-elevated); border: 1px solid var(--border-default); border-radius: 12px; padding: 32px; max-width: 420px; width: 100%; text-align: center; box-shadow: 0 2px 12px rgba(0,0,0,0.04); }
.brand { font-weight: 700; font-size: 18px; color: var(--text-primary); letter-spacing: -0.01em; }
a.brand:hover { text-decoration: none; }

/* ボタン・入力 */
.btn { font: inherit; font-size: 12px; font-weight: 500; padding: 6px 12px; border-radius: var(--radius); border: 1px solid var(--border-default); background: var(--bg-elevated); color: var(--text-secondary); cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--bg-subtle); }
.btn-primary { background: var(--kaitori-1); border-color: var(--kaitori-1); color: #fff; font-weight: 600; padding: 9px 18px; margin-top: 12px; }
.btn-primary:hover { background: #0369a1; }
.btn-link { color: var(--kaitori-1); }
.btn-link:hover { text-decoration: none; }
.ctl { font: inherit; font-size: 12px; border: 1px solid var(--border-emphasis); border-radius: var(--radius); padding: 5px 8px; background: var(--bg-elevated); color: var(--text-primary); }
.filter-label { font-size: 11px; color: var(--text-secondary); font-weight: 500; }
.segmented { display: inline-flex; border: 1px solid var(--border-default); border-radius: var(--radius); overflow: hidden; }
.segmented button { font: inherit; font-size: 12px; padding: 5px 12px; border: none; background: var(--bg-elevated); color: var(--text-secondary); cursor: pointer; }
.segmented button + button { border-left: 1px solid var(--border-default); }
.segmented button.on { background: var(--kaitori-1); color: #fff; font-weight: 600; }

/* ヘッダー */
.app-header { position: sticky; top: 0; z-index: 10; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding: 10px 20px; background: var(--bg-elevated); border-bottom: 1px solid var(--border-default); }
.header-left { display: flex; align-items: baseline; gap: 10px; }
.header-sub { font-size: 11px; color: var(--text-secondary); }
.header-center { flex: 1 1 360px; }
.store-switch { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.store-switch input { width: 180px; }
.store-switch select { min-width: 220px; max-width: 100%; }
.header-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hq-links { display: flex; gap: 6px; }
.pill { font-size: 11px; padding: 3px 8px; border-radius: 999px; background: var(--bg-subtle); color: var(--text-secondary); cursor: help; white-space: nowrap; }
.pill-warn { background: var(--warn-bg); color: var(--warn); font-weight: 600; }
.user-name { font-size: 12px; color: var(--text-secondary); }

/* 本文 */
.app-main { max-width: 1280px; margin: 0 auto; padding: 16px 20px 24px; display: flex; flex-direction: column; gap: 16px; }
.app-footer { max-width: 1280px; margin: 0 auto; padding: 0 20px 24px; font-size: 11px; }
.panel { background: var(--bg-elevated); border: 1.5px solid var(--border-emphasis); border-radius: 12px; padding: 14px 16px 16px; }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.panel-title { margin: 0; font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.panel-title::before { content: ''; display: inline-block; width: 8px; height: 22px; border-radius: 4px; background: var(--kaitori-gradient); }
h3.panel-title { font-size: 13px; }
.notice { padding: 12px 14px; border-radius: var(--radius); background: var(--bg-subtle); color: var(--text-secondary); }
.notice-error { background: rgba(220, 38, 38, 0.06); color: var(--error); }
.notes { margin: 10px 0 0; padding-left: 18px; color: var(--text-secondary); font-size: 11px; }

/* 表 */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { padding: 7px 10px; border-bottom: 1px solid var(--border-default); text-align: left; white-space: nowrap; }
.tbl th { font-size: 11px; font-weight: 600; color: var(--text-secondary); background: var(--bg-subtle); position: sticky; top: 0; }
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl .num { text-align: right; }
.tbl tr.total td { background: #f1f5f9; font-weight: 600; }
.tbl tr.sub td { color: var(--text-secondary); background: #fafafa; }
.tbl tbody tr:hover td { background: #f8fafc; }

/* ファネル（直営Board の .dl-funnel-* を写した） */
.fn-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-bottom: 8px; }
.fn-card { background: #f9fafb; border-radius: 6px; padding: 10px 12px 12px; border-top: 3px solid var(--kaitori-1); display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.fn-base { border-top-color: #334155; background: #f1f5f9; }
.fn-name { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.fn-count { font-size: 22px; font-weight: 700; line-height: 1.1; }
.fn-count.fn-na { font-size: 14px; color: var(--text-tertiary); font-weight: 600; }
.fn-sub { font-size: 11px; color: #4b5563; }
.fn-note { font-size: 10px; color: var(--text-tertiary); margin-top: 2px; }

.chart-box { position: relative; height: 260px; }

@media (max-width: 640px) {
  .app-header, .app-main, .app-footer { padding-left: 16px; padding-right: 16px; }
  .store-switch input, .store-switch select { width: 100%; min-width: 0; }
}
