/* 売上を見る。iPad の横向き 1 画面に収める配置（素案）。縦向き・PC・スマホでも崩れないように折り返す
   見た目：やわらかいパステル（ピンク・ピーチ・ラベンダー）、丸ゴシック、角の丸いカード。
   上がった・下がったの色は、ピンクの地でも見分けられるよう、緑とえんじにする */
:root {
  color-scheme: light;
  --bg: #fff6f8;
  --bg-dot: #ffe3ea;
  --surface: #ffffff;
  --surface-soft: #fff0f4;
  --surface-lav: #f4efff;
  --ink: #4a3540;
  --ink-soft: #8a6f7c;
  --line: #f6dbe3;
  --accent: #e8588c;
  --accent-ink: #ffffff;
  --lead-from: #e0558a;
  --lead-to: #f47f73;
  --this-year: #ec5f92;
  --this-year-fill: rgba(236, 95, 146, .16);
  --last-year: #a48ad8;
  --sat: #6f7fd6;
  --sun: #e0557a;
  --good: #1f8a62;
  --bad: #c2334f;
  --warn-bg: #fff3dc;
  --warn-ink: #7a5300;
  --shadow: 0 2px 4px rgba(232, 88, 140, .06), 0 8px 20px rgba(232, 88, 140, .09);
  --radius: 22px;
  --radius-sm: 16px;
  --font: "Hiragino Maru Gothic ProN", "Hiragino Maru Gothic Pro", "BIZ UDPGothic", "Hiragino Sans", "Noto Sans JP", "Meiryo", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.55;
  background-color: var(--bg);
  background-image: radial-gradient(var(--bg-dot) 1.6px, transparent 1.7px);
  background-size: 22px 22px;
  padding: env(safe-area-inset-top, 0px) max(16px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(16px, env(safe-area-inset-left, 0px));
  font-variant-numeric: tabular-nums;
}
h1, h2 { margin: 0; text-wrap: balance; }
button, select { font: inherit; color: inherit; }
button:focus-visible, select:focus-visible, tr:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---- 上の帯 ---- */
.bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding-block: 14px 10px; }
.bar-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; min-width: 0; }
.bar h1 { font-size: 1.65rem; font-weight: 800; letter-spacing: .04em; color: var(--accent); display: flex; align-items: center; gap: 8px; }
.bar h1 .mark { display: inline-grid; place-items: center; width: 1.6em; height: 1.6em; border-radius: 50%; font-size: .8em;
  background: linear-gradient(135deg, var(--lead-from), var(--lead-to)); color: #fff; box-shadow: var(--shadow); }
.place { font-weight: 700; color: var(--ink); background: var(--surface); border-radius: 999px; padding: 2px 12px; box-shadow: var(--shadow); }
.as-of { color: var(--ink-soft); font-size: .9rem; }
.bar-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.pick { display: flex; align-items: center; gap: 6px; }
.pick label { font-size: .85rem; color: var(--ink-soft); }
.pick select { background: var(--surface); border: 2px solid var(--line); border-radius: 999px; padding: 5px 12px; max-width: 16rem; }
.month-pick { display: flex; align-items: center; gap: 4px; background: var(--surface); border-radius: 999px; padding: 3px; box-shadow: var(--shadow); }
.month-label { min-width: 6.5em; text-align: center; font-weight: 800; }
.tool { background: var(--surface); border: 2px solid var(--line); border-radius: 999px; padding: 4px 14px; cursor: pointer; min-height: 36px; }
.month-pick .tool { border: 0; background: var(--surface-soft); min-width: 36px; padding: 0; font-weight: 800; color: var(--accent); }
.tool:disabled { opacity: .35; cursor: default; }
.primary { background: linear-gradient(135deg, var(--lead-from), var(--lead-to)); color: #fff; border: 0; border-radius: 999px; padding: 11px 26px; font-weight: 800; cursor: pointer; box-shadow: var(--shadow); }
.user { color: var(--ink-soft); font-size: .9rem; }
.sample-note { margin: 0 0 8px; font-size: .85rem; color: var(--warn-ink); background: var(--warn-bg); border-radius: 999px; padding: 3px 14px; display: inline-block; }
.stale { margin: 0 0 8px; color: var(--warn-ink); background: var(--warn-bg); border-radius: var(--radius-sm); padding: 8px 14px; }
.stale::before { content: "🔔 "; }

.gate .primary + .primary { margin-left: 8px; }
.gate { max-width: 28rem; margin: 15vh auto; text-align: center; background: var(--surface); border-radius: var(--radius); padding: 36px 24px; box-shadow: var(--shadow); }
.gate::before { content: "🌷"; display: block; font-size: 2.4rem; margin-bottom: 8px; }

.main { display: grid; gap: 14px; padding-bottom: 18px; }
.back { justify-self: start; }

/* ---- 大きな数字 ---- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.kpi { container-type: inline-size; position: relative; overflow: hidden; background: var(--surface); border-radius: var(--radius); padding: 14px 18px; box-shadow: var(--shadow); display: grid; gap: 2px; min-width: 0; }
.kpi.lead { background: linear-gradient(135deg, var(--lead-from), var(--lead-to)); color: #fff; }
.kpi.lead::after { content: ""; position: absolute; right: -28px; top: -28px; width: 110px; height: 110px; border-radius: 50%; background: rgba(255, 255, 255, .16); }
.kpi.lead::before { content: ""; position: absolute; right: 36px; bottom: -40px; width: 80px; height: 80px; border-radius: 50%; background: rgba(255, 255, 255, .1); }
.kpi-label { font-weight: 800; font-size: 1rem; position: relative; z-index: 1; }
.kpi-value { font-size: clamp(1.4rem, 3vw, 2.4rem); font-weight: 800; line-height: 1.2; white-space: nowrap; position: relative; z-index: 1; }
/* カードの幅に合わせて、1 行に収まる大きさにする（1,000 万円台の 11 文字まで） */
@supports (font-size: 1cqi) { .kpi-value { font-size: clamp(1.2rem, 12.5cqi, 2.5rem); } }
.kpi-note { font-size: .78rem; opacity: .85; position: relative; z-index: 1; }
.kpi .up { color: var(--good); }
.kpi .down { color: var(--bad); }
.kpi .up::before { content: "↗ "; font-size: .7em; }
.kpi .down::before { content: "↘ "; font-size: .7em; }

/* ---- その日のようす ---- */
.section-title { font-size: 1.05rem; margin-top: 2px; display: flex; align-items: center; gap: 6px; }
.section-title::before { content: "🌸"; font-size: .95em; }
.metrics { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.metric { background: var(--surface); border-radius: var(--radius-sm); padding: 10px 14px; box-shadow: var(--shadow); min-width: 0; }
.metric.soft { background: var(--surface-lav); }
.metric-label { display: flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--ink-soft); font-weight: 700; }
.metric-icon { display: inline-grid; place-items: center; width: 1.9em; height: 1.9em; border-radius: 50%; background: var(--surface-soft); font-size: .95rem; flex: none; }
.metric.soft .metric-icon { background: var(--surface); }
.metric-value { display: block; font-size: clamp(1.2rem, 2.2vw, 1.7rem); font-weight: 800; margin-top: 2px; }

/* ---- 下の段 ---- */
.lower { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.lower-left { display: grid; gap: 14px; min-width: 0; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 18px; min-width: 0; }
.card h2 { font-size: 1.05rem; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.legend { display: flex; align-items: center; gap: 6px; font-size: .85rem; font-weight: 700; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-left: 10px; }
.swatch.this { background: var(--this-year); }
.swatch.last { background: var(--last-year); }
.chart svg { display: block; width: 100%; height: auto; }
.chart text { fill: var(--ink-soft); font-size: 11px; font-family: var(--font); }
.chart .grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 4; }
.chart .axis { stroke: var(--line); stroke-width: 1.5; }
.chart .area-this { fill: var(--this-year-fill); stroke: none; }
.chart .line-this { stroke: var(--this-year); stroke-width: 3; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.chart .line-last { stroke: var(--last-year); stroke-width: 2.2; fill: none; stroke-dasharray: 2 5; stroke-linecap: round; }
.chart .dot-this { fill: var(--surface); stroke: var(--this-year); stroke-width: 2; }
.chart .dot-latest { fill: var(--this-year); stroke: var(--surface); stroke-width: 3; }

.notices { background: var(--surface-soft); }
.notices h2::before { content: "💌 "; }
.notice { margin: 8px 0 0; background: var(--surface); border-radius: var(--radius-sm); padding: 8px 12px; }
.notice strong { display: block; }
.notice-empty { margin: 6px 0 0; color: var(--ink-soft); }

.unit { font-size: .8rem; color: var(--ink-soft); }
.days { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.days ol { list-style: none; margin: 0; padding: 0; }
.days li { display: flex; justify-content: space-between; padding: 2px 10px; border-bottom: 1px dashed var(--line); font-size: .9rem; border-radius: 10px; }
.days li.latest { font-weight: 800; background: var(--surface-soft); border-bottom-color: transparent; color: var(--accent); }
.days li.future { color: var(--ink-soft); }
.days li.missing span:last-child { color: var(--warn-ink); background: var(--warn-bg); border-radius: 999px; padding: 0 8px; font-size: .82rem; }
.days li.partial span:last-child { color: var(--warn-ink); }
.days .wd-sat { color: var(--sat); }
.days .wd-sun { color: var(--sun); }
.hint { margin: 6px 0 0; font-size: .75rem; color: var(--ink-soft); }

/* ---- 店ごとの一覧 ---- */
.table-wrap { overflow-x: auto; }
.stores { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .92rem; }
.stores th, .stores td { padding: 7px 10px; border-bottom: 1px dashed var(--line); text-align: left; white-space: nowrap; }
.stores th { font-size: .8rem; color: var(--ink-soft); border-bottom: 2px solid var(--line); }
.stores .num { text-align: right; }
.stores tbody tr { cursor: pointer; }
.stores tbody tr:hover td { background: var(--surface-soft); }
.stores tbody tr:hover td:first-child { border-radius: 12px 0 0 12px; }
.stores tbody tr:hover td:last-child { border-radius: 0 12px 12px 0; }
.stores .up { color: var(--good); }
.stores .down { color: var(--bad); }
.status { color: var(--ink-soft); margin: 0; }

@media (max-width: 1000px) {
  .metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .lower { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bar h1 { font-size: 1.35rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
