/* ふぁまふぁい 共通の部品。色・書体・重なりの順は tokens.css の変数を使う */

/* ==========================================
   ラベルとヘルプ
   ========================================== */
/* ラベルの文字と「？」を 1 行に並べる */
.label-text { display: flex; align-items: center; gap: 0.5em; }

/* 「？」に触れる・フォーカスする・タップすると data-help の文を浮かせて出す */
.help-tip {
  display: inline-grid; place-items: center;
  width: 16px; height: 16px;
  border: 1px solid var(--text-dim); border-radius: 50%;
  color: var(--text-muted); font-size: 0.75rem; line-height: 1;
  cursor: help;
}
/* 注意（「！」）: 説明ではなく、見落とすと誤解する事柄に使う */
.help-tip.warn { border-color: var(--color-warn); color: var(--color-warn); }
/* 表のマスの浮き出し（単価ごとの内訳など）。印は付けない（下線は数が多いとうるさい） */
body.app td.tip-host { cursor: help; }
/* 浮かせて出す文（common.js の initHelpTips が、画面からはみ出さない位置に置く） */
.help-float {
  position: fixed; z-index: calc(var(--z-popup) + 1);
  width: max-content; max-width: min(20em, calc(100vw - 16px));
  padding: 0.5em 0.75em;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); font-family: var(--font-ui); font-size: 0.75rem; font-weight: 400; line-height: 1.6; white-space: pre-line; text-align: left;
  pointer-events: none;
}

/* ==========================================
   パスワード欄（common.js の initPasswordFields が input を包む）
   ========================================== */
.password-field { position: relative; display: grid; }
/* 右側に「最後に打った文字」と表示ボタンが重なるので、その分だけ文字を入れない */
.password-field input { min-width: 0; padding-right: calc(44px + 2em); }

/* 押している間だけ中身を表示するボタン */
.password-reveal {
  position: absolute; right: 0; top: 0; bottom: 0;
  display: grid; place-items: center;
  width: 44px; min-height: 0; padding: 0;
  background: none; border: 0; border-radius: 6px;
  color: var(--text-muted); cursor: pointer;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.password-reveal svg { width: 20px; height: 20px; pointer-events: none; }
.password-reveal.is-held { color: var(--c-p-dark); }

/* 最後に打った 1 文字を少しの間だけ見せる */
.password-last {
  position: absolute; right: 44px; top: 50%; transform: translateY(-50%);
  padding: 0.25em 0.5em;
  background: var(--bg-sub); border: 1px solid var(--border); border-radius: 4px;
  color: var(--text); font-family: var(--font-mono); font-size: 1rem; line-height: 1;
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur-float) var(--ease-float);
}
.password-last.is-shown { opacity: 1; }

/* ==========================================
   利用者の画面の土台（layout.html の body.app の中だけに効かせる）
   ========================================== */
:root { --c-s-dark: oklch(0.42 0.09 var(--hue-s)); }
body.app, body.app * { box-sizing: border-box; }
body.app { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font-ui); font-size: 1rem; line-height: 1.5; }
body.app a { color: var(--c-p-dark); text-decoration: none; }
body.app a:hover { color: var(--c-p); }
body.app button { font-family: var(--font-ui); cursor: pointer; }
body.app [hidden] { display: none !important; }

/* ── ヘッダーと上部ナビ ── */
body.app > header { position: sticky; top: 0; z-index: var(--z-header); background: var(--bg-card); border-bottom: 1px solid var(--border); }
.hd { max-width: 1820px; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; gap: 20px; min-height: 3.75rem; }
.logo { font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; color: var(--c-p-dark); display: flex; align-items: center; gap: 0.5rem; white-space: nowrap; }
.logo svg { width: 1.5rem; height: 1.5rem; }
/* 狭い画面では、右側の操作（メールのみ・売上／利益の切替・通知・アカウント）を 1 行に収めるためロゴをマークだけにする。
   右側の部品は 375px 幅で、さらに間隔とボタンの余白を詰め、見出しのヘルプは出さない（ページが横にあふれて縮小表示されていた） */
@media (max-width: 579px) { .logo-text { display: none; } }
@media (max-width: 479px) {
  body.mnav .hd { padding: 0 16px; }
  .hd-r { gap: 4px; }
  .hd-r .seg button { padding: 0 0.5rem; }
  .hd-r > .help-tip { display: none; }
}
.help-tip { flex: none; }
nav.top { display: flex; gap: 0.25rem; flex: 1; min-width: 0; overflow: hidden; }
nav.top a, nav.top .soon { display: flex; align-items: center; padding: 0 0.75rem; min-height: 2.75rem; border-radius: 8px; font-size: 0.875rem; color: var(--text-muted); white-space: nowrap; }
nav.top a:hover { background: var(--bg-sub); }
nav.top a.on { color: var(--c-p-dark); font-weight: 700; background: var(--c-p-light); }
.soon { cursor: default; }
nav.top .soon { color: var(--text-dim); }
.hd-r { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; position: relative; }
.bell { position: relative; width: 2.75rem; height: 2.75rem; border: 0; background: none; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--text-muted); flex: none; }
/* 通知のポップアップ（タグ／本文／時刻／操作 の列を揃える） */
.nplist { display: grid; grid-template-columns: 4rem minmax(0, 1fr) 7.5rem max-content; gap: 8px 12px; align-items: center; max-height: 60dvh; overflow: auto; overscroll-behavior: contain; }
.nplist .ni { display: contents; }
.nplist .tag { justify-self: start; }
.nplist .nt { font-size: 0.875rem; min-width: 0; }
.nplist .nt.read { color: var(--text-muted); }
.nplist .ntime { font-size: 0.75rem; color: var(--text-dim); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nplist .nack { min-width: 3.5rem; font-size: 0.75rem; color: var(--text-dim); text-align: center; }
/* 操作の列（読み上げ・既読）。ボタンは右寄せでそろえる */
.nplist .nacts { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.nplist .empty { grid-column: 1 / -1; }
/* 狭い幅では 1 件を 2 段（タグ・時刻・操作／本文）にする。display: contents のままだと全件が同じ行に重なるので、件ごとの格子にする */
@media (max-width: 620px) {
  .nplist { display: flex; flex-direction: column; gap: 12px; align-items: stretch; }
  .nplist .ni { display: grid; grid-template-columns: max-content minmax(0, 1fr) max-content; gap: 4px 8px; align-items: center; }
  .nplist .ni .tag { grid-row: 1; grid-column: 1; }
  .nplist .ni .ntime { grid-row: 1; grid-column: 2; text-align: left; }
  .nplist .ni .nacts { grid-row: 1; grid-column: 3; justify-self: end; }
  .nplist .ni .nt { grid-row: 2; grid-column: 1 / -1; }
}
.bell:hover { background: var(--bg-sub); }
.bell svg { width: 1.25rem; height: 1.25rem; }
.bell .n { position: absolute; top: 0.375rem; right: 0.375rem; min-width: 1rem; height: 1rem; padding: 0 0.25rem; border-radius: 0.5rem; background: var(--c-a); color: var(--btn-text); font-size: 0.75rem; line-height: 1.35; text-align: center; font-weight: 700; }
.acct { display: flex; align-items: center; gap: 0.5rem; min-height: 2.75rem; padding: 0 0.5rem; border: 0; background: none; border-radius: 8px; color: var(--text); }
.acct:hover { background: var(--bg-sub); }
.ava { width: 2rem; height: 2rem; border-radius: 50%; background: var(--c-p-light); color: var(--c-p-dark); font-family: var(--font-display); font-weight: 700; font-size: 0.875rem; display: flex; align-items: center; justify-content: center; flex: none; }
/* 丸い頭文字の右に、名前と契約名を 2 段で縦にそろえる（契約名は複数の契約に入っている人にだけ出る） */
.acct .who { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 0.125rem; min-width: 0; line-height: 1.2; }
.acct .nm { font-size: 0.875rem; color: var(--text); white-space: nowrap; }
.acct .tn { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; max-width: 12em; overflow: hidden; text-overflow: ellipsis; }

/* アカウントのメニュー（契約の切替・ログアウト） */
.menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: var(--z-menu); min-width: 14em; padding: 8px; display: flex; flex-direction: column; gap: 4px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; }
.menu-name { padding: 0.25em 0.75em; font-size: 0.875rem; font-weight: 700; }
.menu-group { padding: 0.5em 0.75em 0; font-size: 0.75rem; color: var(--text-dim); }
.menu-item { display: flex; align-items: center; min-height: 2.75rem; padding: 0 0.75em; border: 0; background: none; border-radius: 8px; font-size: 0.875rem; color: var(--text); text-align: left; white-space: nowrap; }
.menu-item:hover { background: var(--bg-sub); }
.menu-item.on { background: var(--c-p-light); color: var(--c-p-dark); font-weight: 700; }

/* ── ページのグリッド（4 分割・最小ユニット 280px）──
   列数は 4 → 2 → 1 で、3 列は使わない（span2 のカードが多く、3 列では片側が空く）。
   切替は画面幅 1220（4 列のカードが 280 になる幅）と 620（2 列のカードが 280 になる幅）。
   auto-fit では 3 列を飛ばせないので、画面幅で列数を決める */
body.app > main { max-width: 1820px; margin: 0 auto; padding: 20px; display: grid; gap: 20px; grid-template-columns: repeat(4, minmax(0, 1fr)); container-type: inline-size; align-items: stretch; }
@media (max-width: 1219px) { body.app > main { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 619px) { body.app > main { grid-template-columns: minmax(0, 1fr); } }
.span2 { grid-column: span 2; }
.span4 { grid-column: 1 / -1; }
@container (width < 580px) { .span2 { grid-column: auto; } }
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; padding: 20px; display: flex; flex-direction: column; gap: 16px; min-width: 0; min-height: 0; }
.card h2 { margin: 0; font-size: 1rem; font-weight: 700; display: flex; align-items: center; gap: 0.5rem; }
.card h2 svg { width: 1.125rem; height: 1.125rem; color: var(--c-p); }
.chead { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.chead .sp { margin-left: auto; }
.note { font-size: 0.75rem; color: var(--text-dim); }
/* 折りたたみ: たたんだ状態は本文 3 行分（行の高さ 1.8 × 0.875rem）だけ見せ、下端を地の色にぼかす */
.fold { position: relative; }
.fold[data-folded]:not([data-open]) > :first-child { max-height: calc(0.875rem * 1.8 * 3); overflow: hidden; -webkit-mask-image: linear-gradient(to bottom, #000 40%, transparent); mask-image: linear-gradient(to bottom, #000 40%, transparent); }
.fold-more { display: inline-flex; align-items: center; gap: 0.25rem; min-height: 2.75rem; padding: 0; border: 0; background: none; font-size: 0.875rem; color: var(--c-p-dark); cursor: pointer; }
.fold-more svg { width: 1.25rem; height: 1.25rem; transition: transform 0.2s; }
.fold[data-open] > .fold-more svg { transform: rotate(180deg); }
.mfoot { margin-top: auto; font-size: 0.75rem; color: var(--text-dim); }
/* 原本のポップアップ（売上明細・売上報告で共用） */
.dh { font-size: 0.75rem; color: var(--text-dim); }
.mailpre { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; background: var(--bg-input); border: 1px solid var(--border); border-radius: 8px; padding: 16px; margin: 0; font-family: var(--font-mono); font-size: 0.875rem; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.popup .cmpl, body.app #tbl tr.cmpr .cmpl { color: var(--text-muted); font-size: 0.875em; }
.empty { padding: 1.5em 0; font-size: 0.875rem; color: var(--text-dim); text-align: center; }
.load-error { font-size: 0.875rem; color: var(--color-danger); }

/* ── ページ見出しと基準日の操作 ── */
.datebar { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.datebar h1 { margin: 0; font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; color: var(--c-p-dark); }
.dctl { margin-left: auto; display: flex; align-items: center; gap: 0.25rem; }
.db { min-width: 2.75rem; min-height: 2.75rem; border: 1px solid var(--border); background: var(--bg-card); border-radius: 8px; color: var(--text-muted); font-size: 1rem; display: inline-flex; align-items: center; justify-content: center; }
.db:hover { background: var(--bg-sub); }
.db:disabled { color: var(--text-dim); background: var(--bg-sub); cursor: default; }
.cur { position: relative; display: inline-flex; align-items: center; gap: 0.5rem; min-height: 2.75rem; padding: 0 0.75rem; border: 1px solid var(--border); background: var(--bg-card); border-radius: 8px; font-size: 0.875rem; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.cur svg { width: 1rem; height: 1rem; color: var(--text-dim); }
/* 日付の欄は見た目を隠してボタン全体に重ね、押すと端末の日付選びが開くようにする */
.cur input[type="date"], .cur input[type="month"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
/* 日付の横の天気（アイコンと最高／最低気温だけ。詳しくはマウスオーバーで） */
/* 日付の操作の左隣に寄せる。狭い幅で日付の操作が次の行に落ちたときは、見出しの行の右端に残る */
.wxbadge { display: inline-flex; align-items: center; gap: 0.25rem; min-height: 2.75rem; padding: 0 0.5rem; margin-left: auto; font-size: 0.875rem; color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; cursor: default; }
.wxbadge svg { width: 1.25rem; height: 1.25rem; }
.datebar .wxbadge:not([hidden]) ~ .dctl { margin-left: 0; }
.today-tag { font-size: 0.75rem; font-weight: 700; color: var(--c-p-dark); background: var(--c-p-light); border-radius: 0.5rem; padding: 0.125rem 0.5rem; }
.btn-s { min-height: 2.75rem; padding: 0 0.75rem; border: 1px solid var(--border); background: var(--bg-card); border-radius: 8px; font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }
.btn-s:hover { background: var(--bg-sub); }
/* 切替ボタンの並び。幅は中身の分だけ（グリッドやフレックスの縦並びの中で親いっぱいに伸ばさない。伸ばすところは個別に width: 100% を指定する） */
.seg { display: inline-flex; width: fit-content; max-width: 100%; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--bg-card); flex: none; }
.seg button { min-height: 2.75rem; padding: 0 0.75rem; border: 0; background: none; font-size: 0.875rem; color: var(--text-muted); white-space: nowrap; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.on { background: var(--c-p-light); color: var(--c-p-dark); font-weight: 700; }
/* 1 行に収まらない切替は、均等な格子に組み直す（列数は JS の initSegs が幅から決める。線は格子の隙間に地の色を見せて引く） */
.seg.wrap { display: grid; grid-template-columns: repeat(var(--cols, 2), 1fr); width: 100%; gap: 1px; background: var(--border); }
.seg.wrap button { border-left: 0; background: var(--bg-card); padding: 0 0.5rem; }
.seg.wrap button.on { background: var(--c-p-light); }

/* ── サマリーカード（ラベル／金額／点数／脚注 の段を揃える） ── */
.kpi { gap: 8px; display: grid; grid-template-rows: auto 2.5rem auto minmax(1.5rem, auto); align-content: start; }
.kpi .lb { font-size: 0.875rem; color: var(--text-muted); font-weight: 500; display: flex; align-items: center; gap: 0.5rem; }
.kpi .big { font-family: var(--font-display); font-weight: 700; font-size: 2rem; line-height: 1.2; font-variant-numeric: tabular-nums; white-space: nowrap; align-self: end; }
.kpi .big.rng { font-size: 1.5rem; }
.kpi .qty { font-size: 1rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
/* 増減の印はカードの右端（比較元はマウスオーバー）。金額と数量は同じ大きさ */
.kpi .big, .kpi .qty { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.kpi .qty { font-family: var(--font-display); font-weight: 700; font-size: 1.5rem; line-height: 1.2; color: var(--text); }
.kpi .big { font-size: 1.5rem; }
.kpi .cmp { align-self: end; display: flex; align-items: center; gap: 0.5rem; font-size: 0.75rem; color: var(--text-dim); flex-wrap: wrap; }
/* 増減の印は幅をそろえる（-100.0% と +25.0% で幅が違うとガタつく）。文字は中央 */
.delta { display: inline-block; box-sizing: border-box; min-width: 5.5rem; text-align: center; font-size: 0.75rem; font-weight: 700; border-radius: 0.5rem; padding: 0.125rem 0.5rem; white-space: nowrap; line-height: 1.5; }
.delta.tip-host { cursor: help; }
.delta.up { color: var(--color-success); background: var(--c-p-light); }
.delta.dn { color: var(--color-danger); background: var(--c-a-light); }

/* ── タグと識別色の丸 ── */
.tag { display: inline-flex; align-items: center; font-size: 0.75rem; font-weight: 700; border-radius: 0.5rem; padding: 0.125rem 0.5rem; white-space: nowrap; }
.tag.info { background: var(--c-p-tag); color: var(--c-p-dark); }   /* 薄い緑の地（ブロックの見出し等）の上でも見えるよう、タグ用の濃さにする */
.tag.warn { background: var(--c-s-light); color: var(--c-s-dark); }
.tag.error { background: var(--c-a-light); color: var(--color-danger); }
.tag.soldout { background: var(--c-a); color: var(--btn-text); }
.tag.ai { background: var(--c-p); color: var(--btn-text); }
.tag.ref { background: var(--bg-sub); color: var(--text-muted); }
/* AI の分析の出どころ: 検索語（薄いチップ）と参照したページ（リンクのチップ・ドメイン名） */
.ai-sources { display: flex; flex-direction: column; gap: 6px; margin-top: 1.8em; font-size: 0.75rem; }   /* 本文の段落の間隔（1 行分）と同じだけ空ける */
.ai-sources .row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.ai-sources .k { color: var(--text-dim); margin-right: 0.25em; min-width: 2em; }
.ai-sources .q, .ai-sources .src { display: inline-flex; align-items: center; height: 1.5rem; padding: 0 0.6em; border-radius: 0.75rem; white-space: nowrap; max-width: 24em; overflow: hidden; text-overflow: ellipsis; }
.ai-sources .q { background: var(--bg-sub); color: var(--text-muted); }
.ai-sources .src { background: var(--c-p-light); color: var(--c-p-dark); text-decoration: none; }
.ai-sources .src:hover { text-decoration: underline; }
.dot { width: 0.5em; height: 0.5em; border-radius: 50%; flex: none; display: inline-block; }

/* ── グラフ（charts.js が中身を作る） ── */
.scroll { overflow-x: auto; overscroll-behavior-x: contain; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 0.75rem; color: var(--text-muted); }
.legend span { display: inline-flex; align-items: center; gap: 0.375rem; }
.sw { width: 0.875rem; height: 0.875rem; border-radius: 2px; flex: none; }
.sw.q { background: var(--c-p); }
.sw.a { background: var(--c-s); }
.sw.avgq { background: repeating-linear-gradient(135deg, var(--c-p-dark) 0 2px, transparent 2px 6px); border: 1.5px solid var(--c-p-dark); }
.sw.avga { background: repeating-linear-gradient(135deg, var(--c-s-dark) 0 2px, transparent 2px 6px); border: 1.5px solid var(--c-s-dark); }
.sw.fq { background: var(--c-p-light); border: 1.5px dashed var(--c-p); }
.sw.fa { background: var(--c-s-light); border: 1.5px dashed var(--c-s); }
.chart { min-width: 580px; padding: 1.5rem 3.5rem 0; position: relative; }
/* 縦軸を左右に貼り付ける形（charts.js の renderAxes）。グラフ本体は目盛りの分の余白を持たない */
.scroll.axes { display: flex; align-items: flex-start; }
/* 両端の列の値や日付が、貼り付いた目盛りの下に隠れないよう余白を取る */
.scroll.axes .chart { padding-left: 2.5rem; padding-right: 2.5rem; flex: 1 0 auto; }
/* 棒の上に値を出すグラフは、上限いっぱいの棒の値と、重なりを避けて上へ逃がした値が見切れないように上の余白を広げる */
.chart.values { padding-top: 5rem; }
/* 比較の棒（.avg の z-index 2）より手前に置く */
/* 幅は charts.js が目盛りの実幅から決める（3.5rem は決まるまでの仮の値） */
.yaxis { position: sticky; flex: none; width: 3.5rem; padding-top: 1.5rem; background: var(--bg-card); z-index: 3; box-sizing: border-box; }
.yaxis.l { left: 0; }
.yaxis.r { right: 0; }
.yaxis .yplot { position: relative; }
.yaxis.l .yl { right: 0.5rem; padding-right: 0; }
.yaxis.r .yl { left: 0.5rem; padding-left: 0; }
.axname { position: absolute; top: 0; font-size: 0.75rem; font-weight: 700; }
.axname.l { left: 0; color: var(--c-p-dark); }
.axname.r { right: 0; color: var(--c-s-dark); }
/* 貼り付けた軸では、名前を軸の幅の中央に置き、高さは横線の間隔（20%）をもう 1 段のばした位置（目盛りと同じ translateY(50%) で中心を合わせる） */
.yaxis .axname { top: auto; bottom: 120%; left: 0; right: 0; text-align: center; transform: translateY(50%); line-height: 1; }
.plot { position: relative; height: 240px; border-bottom: 2px solid var(--border); }
.gl { position: absolute; left: 0; right: 0; border-top: 1px solid var(--border); }
.yl { position: absolute; font-size: 0.75rem; color: var(--text-dim); font-variant-numeric: tabular-nums; transform: translateY(50%); line-height: 1; white-space: nowrap; }
.yl.l { right: 100%; padding-right: 0.5rem; text-align: right; color: var(--c-p-dark); }
.yl.r { left: 100%; padding-left: 0.5rem; color: var(--c-s-dark); }
.lanes { position: absolute; inset: 0; display: flex; align-items: stretch; }
.iv { flex: 1 1 0; display: flex; align-items: flex-end; justify-content: center; gap: 3px; min-width: 0; position: relative; }
/* 現在の位置の点線。枠線にするとその列だけ幅が増えるので、列に重ねて描く */
.iv.now::before { content: ''; position: absolute; left: 0; top: calc(-20% + 0.5rem); bottom: 0; border-left: 2px dashed var(--text-dim); pointer-events: none; }
/* 現在・ここから予測 の文字は、点・円の名前と同じ高さ＝横線の間隔をもう 1 段のばした位置（中心を合わせる）。棒の上の数字と重ならない */
.nowlb { position: absolute; bottom: 120%; left: 0; transform: translate(-50%, 50%); line-height: 1; font-size: 0.75rem; color: var(--text-dim); white-space: nowrap; background: var(--bg-card); padding: 0 0.25rem; }
/* 棒は下から積む（色分けのときは属性ごとの段を積み上げる） */
.bcol { position: relative; width: 26%; max-width: 1.75rem; height: 100%; display: flex; flex-direction: column-reverse; align-items: stretch; }
.b { width: 100%; flex: none; }
.bcol > .b:last-of-type { border-radius: 2px 2px 0 0; }
.b.q { background: var(--c-p); }
.b.a { background: var(--c-s); }
.b.fq { background: var(--c-p-light); border: 1.5px dashed var(--c-p); border-bottom: 0; }
.b.fa { background: var(--c-s-light); border: 1.5px dashed var(--c-s); border-bottom: 0; }.avg { position: absolute; left: 0; bottom: 0; width: 100%; z-index: 2; border-radius: 2px 2px 0 0; }
.avg.q { background: repeating-linear-gradient(135deg, var(--c-p-dark) 0 2px, transparent 2px 6px); border: 1.5px solid var(--c-p-dark); }
.avg.a { background: repeating-linear-gradient(135deg, var(--c-s-dark) 0 2px, transparent 2px 6px); border: 1.5px solid var(--c-s-dark); }
/* 棒の上の値（数量と金額を 2 段で。列の幅が足りないときは chart.novals で隠す） */
.cv { position: absolute; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 1px; transform: translateY(-4px); font-size: 0.75rem; line-height: 1.1; font-variant-numeric: tabular-nums; pointer-events: none; white-space: nowrap; }
/* 値の文字には地の色を敷き、現在・ここから予測 の点線や目盛りの線が文字を横切らないようにする（列にマウスを乗せたときは列の色に合わせる） */
.cv { z-index: 2; }
.cv b { font-weight: 500; background: var(--bg-card); padding: 0 2px; border-radius: 2px; }
.iv:hover .cv b { background: var(--bg-sub); }
.cv .q { color: var(--c-p-dark); }
.cv .a { color: var(--c-s-dark); }
.cv.f { opacity: 0.6; }
.cv.zero .q { color: var(--text-dim); font-weight: 400; }
/* 値は棒のすぐ上に置き、ほかの値や棒と重なるときだけ上へ逃がす（charts.js の placeValueLabels が --rise を入れる） */
.cv { transform: translateY(calc(-4px - var(--rise, 0px))); }
.chart.novals .cv { display: none; }
.iv { cursor: default; }
.iv:hover { background: var(--bg-sub); }
.iv.drill { cursor: pointer; }
.xrow { display: flex; padding-top: 0.375rem; }
.xrow > span { flex: 1 1 0; text-align: center; font-size: 0.75rem; color: var(--text-muted); font-variant-numeric: tabular-nums; min-width: 0; white-space: nowrap; }
.xrow.weather > span { display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--text-dim); }
.xrow.weather svg { width: 1rem; height: 1rem; }
/* 列の下の印（便を確認したメールの数など） */
.xrow.notes > span { color: var(--text-dim); }
.mailcnt { display: inline-flex; align-items: center; gap: 0.25rem; cursor: default; }
.mailcnt svg { width: 0.875rem; height: 0.875rem; }
.mailcnt.ok { color: var(--text-muted); }

/* ── 表（列幅は文字数から em で逆算・左右 0.5 文字の余白・縮尺は --tbl-fs） ── */
/* 表の容器。ホイールは表の中をスクロールし、端まで行ったら（縦に伸びない表では最初から）ページに渡す。
   overscroll-behavior: contain を付けると、縦にあふれていない表の上でもホイール操作を奪ってページが動かなくなる */
.tscroll { overflow: auto; overscroll-behavior: auto; min-height: 0; }
body.app table { border-collapse: separate; border-spacing: 0; table-layout: fixed; width: 100%; font-size: var(--tbl-fs, 0.875rem); }
body.app th { font-size: 0.875em; color: var(--text-dim); font-weight: 500; text-align: left; padding: 0 0.5em 0.5em; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--bg-card); }
body.app td { font-size: 1em; padding: 0.5em; border-bottom: 1px solid var(--bg-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.app th.num, body.app td.num { text-align: right; font-variant-numeric: tabular-nums; }
body.app td.num { overflow: visible; text-overflow: clip; }
body.app td.dim { color: var(--text-dim); }
body.app th.sub { padding-top: 0; font-size: 0.75em; }
body.app thead th { position: sticky; top: 0; z-index: 2; }
body.app thead tr:first-child th { height: 2em; }
body.app thead tr + tr th { top: 2em; }
body.app tfoot td { border-bottom: 0; border-top: 1px solid var(--border); font-weight: 700; background: var(--bg-card); }
/* 2 段の見出し（日付 → 点・円）: 日付と点・円の間に横線は引かず、日付のまとまりごとに縦線で区切る */
body.app th.grp { border-bottom: 0; }
body.app th.gsep, body.app td.gsep { border-left: 1px solid var(--border); }
/* 合計の 2 列（点・円）は右端に貼り付ける（横にスクロールしても見える） */
.stickr1, .stickr2 { position: sticky; background: var(--bg-card); }
/* 点の列の位置は、円の列の実際の幅（表が広いときは比率で伸びる）を common.js の tableZoom が測って --stickr に入れる */
.stickr1 { right: var(--stickr, 6.5em); }
.stickr2 { right: 0; }
body.app thead th.stickr1, body.app thead th.stickr2 { z-index: 3; }
body.app tbody td.stickr1, body.app tbody td.stickr2, body.app tfoot td.stickr1, body.app tfoot td.stickr2 { z-index: 1; }
/* 表の列の組の境（時間の順に並べた列の区切り） */
body.app th.sep, body.app td.sep { border-left: 1px solid var(--border); }
.stick1, .stick2 { position: sticky; background: var(--bg-card); }
.stick1 { left: 0; }
.stick2 { border-right: 1px solid var(--border); }
body.app thead th.stick1, body.app thead th.stick2 { z-index: 3; }
body.app tbody td.stick1, body.app tbody td.stick2, body.app tfoot td.stick1, body.app tfoot td.stick2 { z-index: 1; }
.cell-name { display: flex; align-items: flex-start; gap: 0.4em; min-width: 0; }
.cell-name .dot { margin-top: 0.45em; }
.cell-name .nm1 { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.cell-name .tnote { display: block; font-size: 0.875em; color: var(--text-dim); white-space: normal; line-height: 1.35; font-weight: 500; }
.cell-name .tnote.warn { color: var(--c-s-dark); }
/* マウスを載せた行と列を着色する（どこを見ていたか見失わないように。貼り付けたセルも同じ色にするため、stick の後に置く） */
body.app tbody tr.hl-row td, body.app tfoot tr.hl-row td, body.app tbody td.hl-col, body.app tfoot td.hl-col, body.app thead th.hl-col { background: var(--bg-sub); }
body.app tr.grow td { border-bottom: 1px solid var(--border); padding-top: 0.75em; font-weight: 700; overflow: visible; }
body.app tr.grow td .cell-name { align-items: center; }
body.app tr.grow td .dot { margin-top: 0; }
body.app table .tag { font-size: 0.875em; padding: 0.125em 0.5em; }
/* 表の縮尺の操作（表があふれているときだけ出す） */
.zoom { display: none; align-items: center; gap: 0.5rem; }
.zoom.show { display: flex; }

/* ── モバイル用ナビ（下部のバー＋「その他」のシート） ── */
nav.bottom { display: none; }
body.mnav nav.top { visibility: hidden; }
body.mnav .acct .nm, body.mnav .acct .tn { display: none; }
body.mnav .hd { gap: 8px; }
body.mnav > main { padding-bottom: calc(4.5rem + env(safe-area-inset-bottom) + 20px); }
/* 項目（アイコン＋名前）を均等割り */
body.mnav nav.bottom { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-header); background: var(--bg-card); border-top: 1px solid var(--border); padding: 0.25rem 0.25rem calc(0.25rem + env(safe-area-inset-bottom)); }
nav.bottom a, nav.bottom .soon { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.125rem; min-height: 2.75rem; padding: 0.25rem; border-radius: 8px; font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
nav.bottom .soon { color: var(--text-dim); }
nav.bottom svg { width: 1.25rem; height: 1.25rem; }
nav.bottom a.on { color: var(--c-p-dark); font-weight: 700; background: var(--c-p-light); }
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.2); z-index: var(--z-sheet); display: none; }
/* 閉じている間は見えない・押せない（開くときは即、閉じるときは動きが終わってから隠す） */
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-sheet); background: var(--bg-card); border-top: 1px solid var(--border); border-radius: 8px 8px 0 0; padding: 20px 20px calc(20px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; transform: translateY(105%); transition: transform var(--dur-float) var(--ease-float), visibility 0s linear var(--dur-float); pointer-events: none; visibility: hidden; }
body.sheet-open #navSheet, body.tags-open #tagSheet, body.add-open #addSheet { visibility: visible; transition-delay: 0s; }
.sheet h3 { margin: 0; font-size: 0.75rem; font-weight: 500; color: var(--text-dim); }
.sheet a, .sheet .soon { display: flex; align-items: center; gap: 0.75rem; min-height: 2.75rem; padding: 0 0.75rem; border-radius: 8px; font-size: 1rem; color: var(--text); }
.sheet .soon { color: var(--text-dim); }
.sheet a:hover { background: var(--bg-sub); }
.sheet a.on { background: var(--c-p-light); color: var(--c-p-dark); font-weight: 700; }
.sheet svg { width: 1.25rem; height: 1.25rem; color: var(--text-muted); }
body.sheet-open .scrim { display: block; }
body.sheet-open #navSheet { transform: none; pointer-events: auto; }
#navSheet { z-index: calc(var(--z-sheet) + 1); }

/* ── ポップアップ（枠の外を押すと閉じる。幅は 4 分割のスパン 880 / 1330 / 1780） ── */
.popup-scrim { position: fixed; inset: 0; z-index: var(--z-popup); background: rgba(0, 0, 0, 0.2); display: grid; place-items: center; padding: 20px; }
.popup { width: min(100%, var(--popup-width, 880px)); max-height: calc(100dvh - 40px); overflow: auto; background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.popup h2 { margin: 0; font-size: 1rem; font-weight: 700; }
.popup .ptext { margin: 0; font-size: 0.875rem; }
.phead { display: flex; align-items: flex-start; gap: 0.75rem; }
.phead h2 { margin: 0; font-size: 1.125rem; font-weight: 700; font-family: var(--font-display); color: var(--c-p-dark); flex: 1; min-width: 0; }
.pclose { width: 2.75rem; height: 2.75rem; margin: -0.5rem -0.5rem 0 0; border: 0; background: none; border-radius: 8px; color: var(--text-muted); font-size: 1.25rem; display: flex; align-items: center; justify-content: center; flex: none; }
.pclose:hover { background: var(--bg-sub); }
.btn-s.danger { color: var(--color-danger); border-color: var(--color-danger); }
.popup .popup-foot { display: flex; justify-content: flex-end; gap: 8px; }

/* ── 編集のポップアップ（ラベル／入力の 2 列。狭い幅では 1 列） ── */
.pform { display: grid; grid-template-columns: 8rem minmax(0, 1fr); gap: 12px 16px; align-items: center; }
.pform .pl { font-size: 0.875rem; color: var(--text-muted); }
.pform .pl .help-tip { margin-left: 0.5em; }
.pform .pl.top { align-self: start; padding-top: 0.75rem; }
.pform .pv { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.pform .pnote { grid-column: 1 / -1; margin: 0; font-size: 0.875rem; color: var(--text-muted); line-height: 1.6; }
/* 売上報告メールの店舗が無い契約（手動記帳だけ）では、便ごとの表示・出荷・取込元の切替を出さない */
body.no-mail .mail-only { display: none !important; }
.pform .pv .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pform .sel { width: 100%; }
@media (max-width: 620px) { .pform { grid-template-columns: 1fr; } .pform .pl.top { padding-top: 0; } }
/* 略称の案内と、表での見え方の見本 */
.hint { font-size: 0.75rem; color: var(--c-s-dark); }
.sample { display: inline-flex; align-items: center; gap: 0.4em; font-size: 0.875rem; background: var(--bg-sub); border-radius: 8px; padding: 0.25rem 0.75rem; max-width: 8.5em; }
.sample .nm1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.popup .pfoot { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.popup .pfoot .left { margin-right: auto; }
.check { display: inline-flex; align-items: center; gap: 0.5rem; min-height: 2.75rem; font-size: 0.875rem; }
.check input { width: 1.25rem; height: 1.25rem; accent-color: var(--c-p); }

/* ── 数量のステッパー（出荷入力・手動記帳で共通）: − ／ 入力欄 ／ ＋ ── */
.step { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--bg-card); }
.sb { width: 2.75rem; height: 2.75rem; border: 0; background: none; font-size: 1.25rem; color: var(--c-p-dark); }
.sb:hover { background: var(--bg-sub); }
.sin { width: 3.5rem; min-height: 2.75rem; border: 0; border-left: 1px solid var(--border); border-right: 1px solid var(--border); background: var(--bg-input); text-align: center; font-family: var(--font-ui); font-size: 1rem; font-variant-numeric: tabular-nums; color: var(--text); padding: 0; appearance: textfield; -moz-appearance: textfield; }
.sin::-webkit-outer-spin-button, .sin::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ── よく使う組合せの行（出荷入力・手動記帳で共通）: 場所と商品の印つきの名前／単価／並びの基準の値 ── */
.combos { display: flex; flex-direction: column; gap: 8px; }
.combo { display: grid; grid-template-columns: minmax(0, 1fr) 4.5rem 4rem; gap: 8px; align-items: center; min-height: 2.75rem; padding: 0 0.75rem; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-card); font-size: 0.875rem; text-align: left; color: var(--text); }
.combo:hover { background: var(--bg-sub); }
/* 区分の列つき（手動記帳: 単価・税込 など。金額が何の金額かを示す） */
.combo.withkind { grid-template-columns: minmax(0, 1fr) 6.5rem 4.5rem 4rem; }
.combo .ckind { font-size: 0.75rem; color: var(--text-dim); white-space: nowrap; text-align: right; }
.combo .cell-name { min-width: 0; align-items: center; }
.combo .cell-name .dot { margin-top: 0; }
.combo .nm1 { white-space: nowrap; }      /* 折り返さず三点リーダーで切る（場所・商品の 2 語が縦に割れない） */
.combo .cdot { margin-left: 0.6em; }      /* 場所の名前と商品の印のあいだを 1 文字ぶん空ける */
.combo .cprice { text-align: right; font-variant-numeric: tabular-nums; }
.combo .ctimes { text-align: right; font-size: 0.75rem; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.combo.added .ctimes { color: var(--c-p-dark); font-weight: 700; }
/* スマホ幅の規則（下の @media）が後に来るように、基本の規則はここまで */
/* スマホ幅では 2 段（1 段目＝場所と商品・2 段目＝単価と並びの基準）。1 段に詰めると名前が 1〜2 文字で切れる */
@media (max-width: 479px) {
  .combo { grid-template-columns: minmax(0, 1fr) max-content; padding: 8px 0.75rem; row-gap: 2px; }
  .combo .cell-name { grid-column: 1 / -1; }
  .combo .cprice { grid-column: 1; text-align: left; }
  .combo .ctimes { grid-column: 2; }
  .combo.withkind { grid-template-columns: max-content minmax(0, 1fr) max-content; }
  .combo.withkind .ckind { grid-column: 1; text-align: left; }
  .combo.withkind .cprice { grid-column: 2; text-align: right; }
  .combo.withkind .ctimes { grid-column: 3; }
}
