/* あにふぉれ デザインシステム：部品。tokens.css のあとに読む。
   正本はこのファイル。各アプリの public/ds/ には sync.mjs で写す（直接直さない）。
   部品の名前・形・値は今の管理画面（admin）で実際に効いていた値と同じ（上書きが重なっていた所はまとめた）。
   ここにない、そのアプリだけの部品は各アプリの app.css に書く。 */

/* ---------- 土台 ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: var(--fs-m)/1.6 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }
.hint { font-size: var(--fs-s); color: var(--sub); }
.muted { color: var(--mute); }
.err-text { color: var(--bad); font-weight: 600; }

/* ---------- 枠：左メニュー＋本文。861〜1180px はメニューを細く、860px 以下はメニューが上に回る ---------- */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--side); border-right: 1px solid var(--line); padding: var(--sp-4) var(--sp-3); display: flex; flex-direction: column; gap: var(--sp-1); position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side::before { content: ''; display: block; height: 6px; margin: -16px -12px 14px; background: var(--checker); }
.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 6px 8px 18px; }
.brand b { display: block; font-size: 15px; }
.brand small { color: var(--sub); font-size: var(--fs-xs); padding-left: 4px; }
.brand .wordmark { display: block; width: 100%; max-width: 200px; height: auto; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button { display: flex; align-items: center; gap: 11px; border: 0; background: none; padding: 9px 12px; border-radius: 10px; cursor: pointer; color: var(--sub); text-align: left; white-space: nowrap; font-size: 15px; }
.nav button svg { width: 18px; height: 18px; flex: none; }
.nav button:hover { background: var(--soft); color: var(--ink); }
.nav button.on { background: var(--soft); color: var(--soft-ink); font-weight: 600; }
.side .foot { margin-top: auto; padding: var(--sp-3); font-size: var(--fs-s); color: var(--sub); background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-m); line-height: 1.5; }
.me { display: flex; align-items: center; justify-content: space-between; gap: 6px; flex-wrap: wrap; font-size: var(--fs-s); color: var(--sub); padding: 0 8px 12px; }
.me:empty { display: none; }
.me > span { min-width: 0; }
.side .me { margin-top: 8px; padding: 10px 8px 0; border-top: 1px solid var(--line); }
.shell > main { padding: 40px clamp(16px, 3.2vw, 56px) 72px; width: 100%; min-width: 0; }
@media (min-width: 861px) and (max-width: 1180px) {
  .shell { grid-template-columns: 200px minmax(0, 1fr); }
  .nav button { font-size: 14px; padding: 8px 10px; }
}
@media (max-width: 860px) {
  /* 上の帯は中身の高さだけ。本文が短いときに、余った高さが帯に配られて帯が縦に伸びていた（2026-11-11 iPhone で見つかった） */
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .side { position: sticky; height: auto; flex-direction: row; align-items: center; padding: 8px max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left)); z-index: 10; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; overflow-y: visible; }
  .side::before, .side .foot, .brand div, .brand small { display: none; }
  .brand { flex-direction: row; padding: 0 6px 0 0; }
  .brand .wordmark { width: auto; height: 32px; }
  .nav { flex-direction: row; }
  .nav button { font-size: 13px; padding: 7px 10px; }
  .shell > main { padding: 20px max(16px, env(safe-area-inset-right)) calc(64px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
  .me { padding: 0 6px; white-space: nowrap; }
  .me > span { display: none; }
  .side .me { margin-top: 0; padding: 0 6px; border-top: 0; }
}

/* ---------- 上の帯（左メニューを使わない画面：お客さん・店用） ---------- */
.appbar { position: sticky; top: 0; z-index: 10; background: var(--side); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top); }
.appbar::before { content: ''; display: block; height: 6px; background: var(--checker); }
.appbar .inner { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) max(var(--sp-4), env(safe-area-inset-right)) var(--sp-2) max(var(--sp-4), env(safe-area-inset-left)); max-width: 1280px; margin: 0 auto; }
.appbar .title { white-space: nowrap; }
.appbar .wordmark { height: 34px; width: auto; display: block; }
.appbar .title { font-family: var(--display); font-weight: 700; font-size: var(--fs-l); }
.appbar .grow { flex: 1; }

/* ---------- ページ見出し：小さな日付＋丸ゴシックの大見出し ---------- */
.head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 28px; }
.head .titles { flex: 1; min-width: 220px; }
.eyebrow { font-size: var(--fs-s); letter-spacing: .14em; color: var(--sub); margin-bottom: 6px; }
.head h1 { font-family: var(--display); font-weight: 700; font-size: var(--fs-h1); line-height: 1.15; margin: 0; letter-spacing: .01em; color: var(--ink); }
.head .tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
@media (max-width: 860px) {
  .head { margin-bottom: 20px; }
  .head h1 { font-size: var(--fs-h1-sp); }
}

/* ---------- ボタン ---------- */
.btn { border: 0; border-radius: var(--r-pill); padding: 9px 18px; background: var(--accent); color: var(--accent-ink); cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn.accent { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: var(--panel); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line2); }
.btn.danger { background: none; color: var(--bad); box-shadow: inset 0 0 0 1px var(--line2); }
.btn.sm { padding: 5px 12px; font-size: 13px; }
.btn.lg { padding: 14px 24px; font-size: var(--fs-l); }
.btn.block { display: block; width: 100%; text-align: center; }
a.btn { display: inline-block; text-decoration: none; }
a.btn.block { display: block; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--soft-ink); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }

/* ---------- 状態の表示（押せない）：枠と地の色なし。色つきの点＋文字（押せるボタンと見分ける） ---------- */
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-s); font-weight: 600; padding: 0; border: 0; border-radius: 0; background: none; color: var(--sub); white-space: nowrap; cursor: default; }
.chip::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.chip.good { color: var(--good); }
.chip.warn { color: var(--warn); }
.chip.bad { color: var(--bad); }
.chip.acc { color: var(--split-ink); }   /* ピンク */
.chip.mint { color: var(--soft-ink); }
.chips { display: flex; gap: 4px; flex-wrap: wrap; }

/* ---------- 数字カード（ラベル右上、数字は大きく等幅）。4色を順に。広い画面は1列、狭い画面は2列 ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); gap: 12px; margin-bottom: 20px; }
@media (min-width: 1280px) { .kpis { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); } }
@media (max-width: 1279px) { .kpis { grid-template-columns: 1fr 1fr; } .kpis > .kpi:last-child:nth-child(odd) { grid-column: span 2; } }
.kpi { container-type: inline-size; display: flex; flex-direction: column; border-radius: var(--r-l); padding: 14px 16px; min-width: 0; min-height: 0; background: var(--k1); color: var(--k1-ink); border: 1px solid rgba(0, 0, 0, .04); }
.kpis .kpi:nth-child(4n+2) { background: var(--k2); color: var(--k2-ink); }
.kpis .kpi:nth-child(4n+3) { background: var(--k3); color: var(--k3-ink); }
.kpis .kpi:nth-child(4n+4) { background: var(--k4); color: var(--k4-ink); }
.kpi .l { order: -1; align-self: flex-end; font-size: var(--fs-s); font-weight: 600; letter-spacing: .1em; display: flex; gap: 6px; align-items: center; margin-bottom: 10px; text-align: right; }
.kpi .v { font-size: clamp(18px, 10cqi, 26px); font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.01em; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .s { font-size: var(--fs-s); margin-top: 6px; opacity: .85; min-height: 0; }
.kpi .chip { color: inherit; }
.kpi.link { cursor: pointer; }
.kpi.link:hover { filter: brightness(.97); }
.meter { height: 6px; border-radius: 99px; background: rgba(255, 255, 255, .5); margin-top: 10px; overflow: hidden; }
.meter i { display: block; height: 100%; background: currentColor; border-radius: 99px; opacity: .7; }
@media (max-width: 600px) {
  .kpi .v { margin-top: 12px; }
  .kpi .l { font-size: var(--fs-xs); letter-spacing: .06em; }
}

/* ---------- カード：白い面。見出し＋本文、または表（flush） ---------- */
.card { container-type: inline-size; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-xl); margin-bottom: 20px; min-width: 0; padding: 6px; }
.card > header { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 14px 10px; }
.card > header h2 { font-size: var(--fs-l); margin: 0; font-weight: 650; white-space: nowrap; }
.card > header .grow { flex: 1; }
.card > .body { padding: 6px 14px 14px; }
.card > .flush { overflow-x: auto; background: var(--panel); border-radius: var(--r-l); border: 1px solid var(--line); }
.count { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 99px; background: var(--panel); border: 1px solid var(--line2); font-size: var(--fs-s); color: var(--sub); font-weight: 500; }
.cols { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 20px; align-items: start; margin-bottom: 20px; }
.cols > div > .card:last-child { margin-bottom: 0; }
.empty { padding: 32px 18px; text-align: center; color: var(--sub); background: var(--panel); border-radius: var(--r-l); }
@media (max-width: 1180px) { .cols { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .card { border-radius: 16px; }
  .card > header { padding: 10px 12px 8px; }
}
@media (max-width: 600px) { .cols { gap: 14px; } }

/* ---------- 入力 ---------- */
.field { display: flex; flex-direction: column; gap: 5px; font-size: var(--fs-s); color: var(--sub); min-width: 0; }
.field > span { display: flex; gap: 6px; align-items: center; }
.input, select.input { background: var(--panel); border: 1px solid var(--line2); border-radius: var(--r-m); padding: 9px 12px; min-width: 0; width: 100%; color: var(--ink); }
.input:focus, select.input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.input.r { text-align: right; }
.seg { display: inline-flex; background: var(--raise); border-radius: var(--r-m); padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 6px 14px; border-radius: var(--r-s); cursor: pointer; color: var(--sub); white-space: nowrap; }
.seg button.on { background: var(--panel); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.toggle { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line2); border-radius: var(--r-pill); padding: 6px 14px; cursor: pointer; background: var(--panel); color: var(--sub); user-select: none; }
.toggle.on { background: var(--soft); border-color: var(--accent); color: var(--soft-ink); font-weight: 600; }
.toggle.dashed { border-style: dashed; }
.toggle.clip { display: inline-block; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hstack { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.hstack > .input { flex: 1 1 10em; width: auto; }

/* ---------- 大きな選択肢（スマホで押す答え）。説明つき ---------- */
.options { display: grid; gap: 10px; }
.options.grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.option { appearance: none; text-align: left; background: var(--panel); border: 1.5px solid var(--line2); border-radius: var(--r-l); padding: 16px 18px; cursor: pointer; display: grid; gap: 2px; color: var(--ink); }
.option b { font-size: var(--fs-l); font-weight: 650; overflow-wrap: anywhere; }
.option small { color: var(--sub); font-size: 13px; }
.option:hover, .option.on { border-color: var(--accent); background: var(--soft); }
.option .chip { justify-self: start; margin-top: 4px; }
.options.grid .option { text-align: center; justify-items: center; padding: 16px 10px; }
.options.grid .option .chip { justify-self: center; }

/* ---------- 表：白い面の中の行。数字は右揃え、1列目は左（文字の表は table.text） ---------- */
table { border-collapse: collapse; width: 100%; }
th, td { padding: 13px 16px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: 0; }
th { font-size: var(--fs-s); color: var(--sub); font-weight: 500; letter-spacing: .04em; }
th:first-child, td:first-child { text-align: left; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: var(--raise); }
tr.total td { font-weight: 700; background: var(--raise); border-bottom: 0; }
td .sub { display: block; font-size: var(--fs-s); color: var(--sub); font-weight: 400; }
td.l, th.l { text-align: left; }
table.text th, table.text td { text-align: left; }
table.text .end { text-align: right; }
tr.off td { color: var(--mute); }
td.acts .btn + .btn { margin-left: 6px; }
@media (max-width: 860px) { th, td { padding: 11px 12px; } }

/* ---------- ログインなどの真ん中のカード ---------- */
.center-screen { min-height: calc(100vh - 140px); display: grid; place-items: center; padding: 16px; }
.login-card { overflow-wrap: anywhere; width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-xl); padding: 28px 24px; display: flex; flex-direction: column; gap: 12px; }
.login-logo { width: 180px; align-self: center; }
.login-card h1 { font-family: var(--display); font-size: var(--fs-xl); margin: 4px 0 0; text-align: center; }
.login-sub { font-size: 13px; color: var(--sub); margin: 0; text-align: center; }
.login-card .btn.accent { padding: 11px 18px; }

/* ---------- お知らせ（画面の下に一瞬出る） ---------- */
#toast { max-width: calc(100vw - 32px); overflow-wrap: anywhere; text-align: center; position: fixed; bottom: calc(22px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%) translateY(10px); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: var(--r-pill); opacity: 0; transition: .2s; pointer-events: none; z-index: 60; font-weight: 600; }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.err { background: var(--bad); color: #fff; }

/* ---------- さわる端末（スマホ・タブレット）：押す場所を 40px 以上に、入力欄の文字を 16px に（iPhone の自動拡大を防ぐ）。
   マウスの端末（管理画面の店のパソコン）の見た目は変えない。2026-11-11 デザイン崩れの監査 ---------- */
@media (pointer: coarse) {
  .btn.sm { padding: 10px 14px; }
  .nav button { min-height: 40px; }
  .toggle { min-height: 40px; }
  .seg button { min-height: 40px; }
  .linkbtn { display: inline-block; padding: 10px 0; }
  .input, select.input { font-size: 16px; }
}
