/* ================================================================
   POR 業績レポート — スタイル
   ・色はすべて :root のトークン経由。デザイン差し替え時はここだけ触る
   ・データの色（--dp-*）は dataviz 検証済みパレットの先頭3色（ライト/ダーク両方で検証PASS）
   ・文字は色で意味を持たせない（▲▼ などの記号を必ず添える）
   ================================================================ */

:root {
  color-scheme: light;

  /* 面・文字 */
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f2f1ec;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);

  /* ブランド（UIの強調色。デザイン確定時に差し替え） */
  --accent: #2a78d6;
  --accent-ink: #ffffff;

  /* データ：時間帯（順序固定。ランチ→ディナー→深夜） */
  --dp-lunch: #2a78d6;
  --dp-dinner: #eb6834;
  --dp-mid: #1baf7a;
  /* データ：前年など「比べる相手」 */
  --dp-context: #b5b3ab;

  /* 状態（系列の色に流用しない） */
  --good-ink: #006300;
  --bad-ink: #a82626;
  --warn-bg: #fff4dc;
  --warn-ink: #6b4a00;
  --warn-line: #fab219;

  --radius: 12px;
  --shadow: 0 1px 2px rgba(11, 11, 11, .05), 0 2px 10px rgba(11, 11, 11, .04);
  --font: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232322;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --dp-lunch: #3987e5;
    --dp-dinner: #d95926;
    --dp-mid: #199e70;
    --dp-context: #5c5b57;
    --good-ink: #4fc24f;
    --bad-ink: #ef7676;
    --warn-bg: #2e2510;
    --warn-ink: #f5d27a;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232322;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --accent: #3987e5;
  --dp-lunch: #3987e5;
  --dp-dinner: #d95926;
  --dp-mid: #199e70;
  --dp-context: #5c5b57;
  --good-ink: #4fc24f;
  --bad-ink: #ef7676;
  --warn-bg: #2e2510;
  --warn-ink: #f5d27a;
  --shadow: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--ink);
  font: 14px/1.6 var(--font);
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}
button, input, select { font: inherit; color: inherit; }
.muted { color: var(--muted); font-weight: 400; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- ボタン ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 8px 14px;
  min-height: 40px;
  cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn:focus-visible, select:focus-visible, input:focus-visible, .chip:focus-visible, .seg button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-primary:disabled { opacity: .6; cursor: wait; }
.btn-ghost { background: transparent; }
/* リンクをボタンの見た目にする（ヘッダーの「☰ メニュー」） */
a.btn { display: inline-flex; align-items: center; color: inherit; text-decoration: none; font: inherit; }

select, input[type="date"], input[type="password"] {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 7px 10px;
  min-height: 40px;
}

/* ---------- 起動 ---------- */
.boot {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: var(--page);
  padding: 16px;
}
.boot-box { width: min(360px, 100%); text-align: center; }
.boot-title { font-weight: 600; margin-bottom: 12px; }
.boot-note { color: var(--ink-2); font-size: 13px; margin: 10px 0; }
.bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--accent); transition: width .3s ease; }

/* ---------- ログイン ---------- */
.login { min-height: 100vh; min-height: 100svh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: min(360px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px;
  display: grid; gap: 16px;
}
.login-app { font-size: 20px; font-weight: 700; }
.login-co { color: var(--ink-2); }
.field { display: grid; gap: 6px; }
.field-label { font-size: 13px; color: var(--ink-2); }
.field input { font-size: 20px; letter-spacing: .2em; text-align: center; }
.login-msg { min-height: 1.6em; margin: 0; color: var(--bad-ink); font-size: 13px; }

/* ---------- ヘッダ ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 16px 8px;
  background: color-mix(in srgb, var(--page) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.brand-app { font-weight: 700; font-size: 16px; white-space: nowrap; }
.brand-co { color: var(--ink-2); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: 4px; }
.who { color: var(--ink-2); font-size: 13px; margin-right: 6px; white-space: nowrap; }

/* ---------- 画面の切替 ---------- */
.views {
  display: flex; gap: 4px; padding: 0 16px;
  max-width: 1200px; margin: 0 auto;
  border-bottom: 1px solid var(--border);
}
.views button {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  padding: 10px 14px; min-height: 44px; font-size: 14px; color: var(--ink-2);
  border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.views button[aria-selected="true"] { color: var(--ink); font-weight: 650; border-bottom-color: var(--accent); }
.views button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ---------- お知らせ（常設） ---------- */
.topnotice {
  margin: 0 0 14px; padding: 12px 14px; border-radius: 10px;
  background: var(--warn-bg); color: var(--warn-ink);
  border: 1px solid color-mix(in srgb, var(--warn-line) 60%, transparent);
}
.topnotice-title { font-weight: 650; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.topnotice-title::before { content: "⚠"; }
.topnotice-text { font-size: 13px; margin: 4px 0 0; }
.topnotice details { margin-top: 6px; font-size: 13px; }
.topnotice summary { cursor: pointer; }
.topnotice ul { margin: 6px 0 0; padding-left: 1.2em; columns: 2 240px; }
.topnotice li { break-inside: avoid; }

/* ---------- 施策の効果 ---------- */
.verdict { margin: 4px 0 10px; font-size: 14px; }
.verdict p { margin: 4px 0; }
.verdict .conclusion {
  margin-top: 8px; padding: 10px 12px; border-radius: 8px;
  background: var(--surface-2); font-weight: 650;
}
.verdict .caveat { font-size: 12px; color: var(--muted); }
table.t td.pt { font-weight: 650; }

/* ---------- ページ ---------- */
.page { max-width: 1200px; margin: 0 auto; padding: 16px 16px calc(32px + env(safe-area-inset-bottom, 0px)); }
.content { transition: opacity .2s; }
.content.is-loading { opacity: .45; pointer-events: none; }

/* フィルタ（1行・折り返し可） */
.filters { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; margin-bottom: 14px; }
.filter { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.filter-label { font-size: 12px; color: var(--muted); }
.custom-range { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.range-text { font-size: 12px; color: var(--ink-2); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  appearance: none; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface);
  border-radius: 999px; padding: 6px 12px; min-height: 36px;
  font-size: 13px;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.chip[aria-pressed="true"]::before { content: "✓ "; font-weight: 700; }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button { appearance: none; border: 0; background: transparent; padding: 7px 12px; min-height: 36px; cursor: pointer; font-size: 13px; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button[aria-checked="true"] { background: var(--ink); color: var(--surface); font-weight: 600; }
.seg--sm button { padding: 5px 10px; min-height: 32px; }

.error-banner {
  margin: 0 0 14px; padding: 10px 14px; border-radius: 8px;
  background: var(--warn-bg); color: var(--warn-ink); border-left: 4px solid var(--bad-ink);
}
.notice {
  display: block; margin: 0 0 14px; padding: 10px 14px; border-radius: 8px;
  background: var(--warn-bg); color: var(--warn-ink); border-left: 4px solid var(--warn-line);
  text-decoration: none; font-size: 13px;
}
.notice:hover { filter: brightness(.98); }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 16px; min-width: 0;
}
.kpi-label { font-size: 13px; color: var(--ink-2); }
.kpi-value { font-size: 26px; font-weight: 650; line-height: 1.25; margin-top: 4px; overflow-wrap: anywhere; }
.kpi-value small { font-size: 14px; font-weight: 500; margin-left: 2px; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi-delta { margin-top: 8px; font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.delta { font-weight: 650; }
.delta.up { color: var(--good-ink); }
.delta.down { color: var(--bad-ink); }
.delta.flat { color: var(--ink-2); }
.delta-note { color: var(--muted); font-size: 12px; }
.meter { margin-top: 8px; height: 6px; border-radius: 3px; background: color-mix(in srgb, var(--accent) 16%, transparent); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

/* ---------- カード ---------- */
.grid2 { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 14px; margin-bottom: 14px; align-items: start; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; min-width: 0; margin-bottom: 14px;
}
.grid2 > .card { margin-bottom: 0; }
.card-head { margin-bottom: 8px; }
.card-head--row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 10px; }
.card-title { font-size: 16px; margin: 0; }
.card-sub { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.card-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--ink-2); margin: 6px 0 4px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.key-rect { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.key-line { width: 16px; height: 0; border-top: 2px solid; display: inline-block; }
.key-line--marker { border-top: 0; border-left: 1px solid var(--ink-2); width: 0; height: 12px; }

/* グラフの箱は軸ラベルぶんまで含めて高さを取る（中で縦スクロールさせない） */
.chart-box { position: relative; width: 100%; height: 260px; }
.chart-box--dow { height: 260px; }
.chart-box--series { height: 300px; }

.series-summary { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; margin: 4px 0 6px; }
.series-summary b { font-weight: 650; }
.markers-list { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--ink-2); margin-top: 8px; }
.markers-list span::before { content: "│ "; color: var(--ink-2); }

/* ---------- 表 ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-top: 8px; }
table.t { border-collapse: collapse; width: 100%; font-size: 13px; }
table.t th, table.t td { padding: 7px 8px; border-bottom: 1px solid var(--grid); text-align: right; white-space: nowrap; }
table.t th:first-child, table.t td:first-child { text-align: left; }
table.t thead th { color: var(--muted); font-weight: 500; font-size: 12px; position: sticky; top: 0; background: var(--surface); }
table.t td.l { text-align: left; white-space: normal; min-width: 12em; }
table.t th.txt, table.t td.txt { text-align: left; }
table.t th.num, table.t td.num { text-align: right; }
table.t tbody tr:hover { background: var(--surface-2); }
table.t .store-row td { font-weight: 650; background: var(--surface-2); }
table.t td.vd { line-height: 1.3; }
table.t td.vd .v { display: block; }
table.t td.vd .delta { display: block; font-size: 11px; }
table.t tbody tr:not(.store-row) td:first-child { padding-left: 18px; color: var(--ink-2); }
table.t td.note { font-size: 12px; padding-left: 18px; }
.tbl-toggle { margin-top: 8px; }
.tbl-toggle summary { cursor: pointer; font-size: 13px; color: var(--ink-2); padding: 4px 0; }

.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--border); color: var(--ink-2); margin: 1px 2px; white-space: nowrap; }

/* 要確認 */
.alert-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 4px; }
.alert-tabs button {
  appearance: none; cursor: pointer; border: 1px solid var(--border); background: var(--surface);
  border-radius: 8px; padding: 6px 10px; font-size: 13px; min-height: 36px;
}
.alert-tabs button[aria-selected="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.alert-tabs .count { font-weight: 650; margin-left: 4px; }
.empty { color: var(--muted); padding: 12px 0; font-size: 13px; }
.alert-desc { font-size: 12px; color: var(--ink-2); margin: 8px 0 0; }

/* ツールチップ */
.tip {
  position: fixed; z-index: 40; pointer-events: none;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 4px 16px rgba(0, 0, 0, .12);
  padding: 8px 10px; font-size: 12px; min-width: 150px; max-width: 260px;
}
.tip-title { color: var(--ink-2); margin-bottom: 4px; }
.tip-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.tip-row .k { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); }
.tip-row .v { font-weight: 650; font-variant-numeric: tabular-nums; }

.foot { font-size: 12px; color: var(--ink-2); padding: 4px 2px; }
.foot p { margin: 4px 0; }

/* ---------- レスポンシブ ---------- */
@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
  .page { padding-left: 12px; padding-right: 12px; }
  .brand-co, .who { display: none; }
  .kpis { gap: 8px; }
  .kpi { padding: 12px; }
  .kpi-value { font-size: 20px; }
  .filters { gap: 10px; }
  .filter { width: 100%; }
  .card { padding: 14px 12px; }
  .chart-box--series { height: 260px; }
}

@media print {
  .topbar, .filters, .tbl-toggle summary, #refreshBtn, #logoutBtn { display: none !important; }
  .tbl-toggle[open] summary ~ *, .tbl-toggle summary ~ * { display: block !important; }
  body { background: #fff; }
  .card, .kpi { box-shadow: none; break-inside: avoid; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
