/* 広告データ分析ツールの画面。見た目は mock/index.html の見本に合わせた（そこから写し、使わない部分を除いて足した）。インラインの style は使わない（CSP）。 */
:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --card-2: #f9fafb;
  --text: #1d2430;
  --muted: #5f6977;
  --line: #e2e5ea;
  --line-strong: #cfd4db;
  --accent: #2f5d8a;
  --accent-soft: #e7eef6;
  --c-spend: #6573c3;
  --c-gmv: #22857a;
  --c-ref: #8a93a1;
  --good: #1d7a4a;
  --bad: #b42318;
  --danger: #b42318;
  --danger-bg: #fdeceb;
  --warn: #7a5300;
  --warn-bg: #fbf1d6;
  --ok: #1d7a4a;
  --ok-bg: #e5f3eb;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --card: #1c2027;
    --card-2: #20252d;
    --text: #e5e8ed;
    --muted: #9ba4b1;
    --line: #2c323b;
    --line-strong: #3a414b;
    --accent: #8db5df;
    --accent-soft: #24303d;
    --c-spend: #8e9bef;
    --c-gmv: #4fbfac;
    --c-ref: #7d8794;
    --good: #6fcf97;
    --bad: #f08a80;
    --danger: #f08a80;
    --danger-bg: #3a201e;
    --warn: #e7c46e;
    --warn-bg: #362d17;
    --ok: #6fcf97;
    --ok-bg: #19322a;
    --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", Meiryo, sans-serif;
  font-size: 14px;
  line-height: 1.55;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; color: inherit; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ヘッダー */
.top {
  position: sticky; top: 0; z-index: 10;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.top-inner {
  max-width: 1200px; margin: 0 auto; padding: 10px 16px 0;
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px;
}
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1 1 auto; }
.brand h1 { font-size: 16px; margin: 0; font-weight: 700; white-space: nowrap; }
.mock-badge {
  font-size: 11px; line-height: 1; padding: 4px 7px; border-radius: 999px;
  border: 1px dashed var(--line-strong); color: var(--muted); white-space: nowrap;
}
.nav { display: flex; gap: 2px; width: 100%; }
.nav a {
  padding: 8px 12px 9px; color: var(--muted); border-bottom: 2px solid transparent;
  font-weight: 600; font-size: 13px;
}
.nav a:hover { text-decoration: none; color: var(--text); }
.nav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }
@media (min-width: 760px) {
  .top-inner { flex-wrap: nowrap; padding-top: 0; }
  .nav { width: auto; }
  .nav a { padding: 16px 12px 14px; }
}

main { max-width: 1200px; margin: 0 auto; padding: 16px 16px 40px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px 16px; margin-bottom: 12px; }
.page-head h2 { font-size: 18px; margin: 0; }
.page-head .sub { margin-top: 2px; }
h3 { font-size: 15px; margin: 0; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px; box-shadow: var(--shadow);
}
.section { margin-top: 16px; }
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin-bottom: 10px; }

/* 期間切り替え */
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; background: var(--card); }
.seg button {
  border: 0; background: transparent; padding: 6px 14px; cursor: pointer; font-size: 13px;
  border-left: 1px solid var(--line-strong); min-width: 56px;
}
.seg button:first-child { border-left: 0; }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 700; }

.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.field { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.field select, .field input, .input {
  border: 1px solid var(--line-strong); background: var(--card); border-radius: 8px;
  padding: 6px 8px; font-size: 13px; min-height: 34px;
}
.input { width: 100%; max-width: 320px; }

/* お知らせ */
.notice { border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; font-size: 13px; border: 1px solid transparent; }
.notice strong { margin-right: 4px; }
.notice.danger { background: var(--danger-bg); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.notice.warn { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.notice a { color: inherit; text-decoration: underline; }

.tag {
  display: inline-block; font-size: 11px; line-height: 1.2; padding: 3px 7px; border-radius: 999px;
  font-weight: 600; white-space: nowrap; vertical-align: 1px;
}
.tag.danger { background: var(--danger-bg); color: var(--danger); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.off { background: var(--card-2); color: var(--muted); border: 1px solid var(--line); }

/* 表（PC は表、スマホはカード） */
.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow-x: auto; box-shadow: var(--shadow); }
table.rt { width: 100%; border-collapse: collapse; font-size: 13px; }
table.rt th, table.rt td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.rt thead th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--card-2); white-space: nowrap; }
table.rt th.num, table.rt td.num { text-align: right; }
table.rt tbody tr:last-child td { border-bottom: 0; }
table.rt tr.clickable { cursor: pointer; }
table.rt tr.clickable:hover td { background: var(--card-2); }
table.rt tr.low td { background: color-mix(in srgb, var(--danger-bg) 55%, transparent); }
table.rt tr.grp th { background: var(--bg); color: var(--muted); font-size: 12px; font-weight: 700; padding: 7px 12px; }
table.rt .name { font-weight: 600; }
table.rt .id { font-variant-numeric: tabular-nums; color: var(--muted); }
.sort-btn { border: 0; background: none; padding: 0; cursor: pointer; font-weight: 600; color: inherit; font-size: inherit; white-space: nowrap; }
.sort-btn .arrow { display: inline-block; width: 1em; color: var(--accent); }
.mobile-only { display: none; }
.empty { padding: 20px; text-align: center; color: var(--muted); }

@media (max-width: 720px) {
  .table-wrap { background: transparent; border: 0; box-shadow: none; overflow: visible; }
  table.rt, table.rt tbody, table.rt tr, table.rt td, table.rt th { display: block; width: 100%; }
  table.rt thead { display: none; }
  table.rt tr { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; box-shadow: var(--shadow); }
  table.rt tr.low { border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
  table.rt tr.low td { background: transparent; }
  table.rt tr.clickable:hover td { background: transparent; }
  table.rt td { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 3px 0; border: 0; text-align: right; }
  table.rt td::before { content: attr(data-label); color: var(--muted); font-size: 12px; text-align: left; flex-shrink: 0; }
  table.rt td.primary { display: block; text-align: left; padding: 0 0 6px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
  table.rt td.primary::before { content: none; }
  table.rt tr.grp { background: transparent; border: 0; box-shadow: none; padding: 6px 2px 2px; margin: 0; }
  table.rt tr.grp th { background: transparent; padding: 0; }
  .mobile-only { display: flex; }
  /* 数字の多い表は、カード内を3列に並べて縦の長さを抑える */
  table.rt.compact tr:not(.grp) { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 10px; }
  table.rt.compact td { display: block; text-align: left; padding: 0; min-width: 0; overflow-wrap: anywhere; }
  table.rt.compact td::before { display: block; font-size: 11px; line-height: 1.3; text-align: inherit; }
  table.rt.compact td.num { text-align: right; }
  table.rt.compact td.primary { grid-column: 1 / -1; margin-bottom: 0; }
  table.rt.compact td.wide { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: baseline; border-top: 1px solid var(--line); padding-top: 5px; }
  table.rt.compact td.wide::before { display: inline; }
  table.rt.compact td.empty { grid-column: 1 / -1; text-align: center; }
}

/* 主要な数字 */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 900px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; box-shadow: var(--shadow); min-width: 0; }
.kpi .label { font-size: 12px; color: var(--muted); }
.kpi .value { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; overflow-wrap: anywhere; line-height: 1.3; }
.kpi .delta { font-size: 12px; margin-top: 3px; font-variant-numeric: tabular-nums; }
.delta.good { color: var(--good); }
.delta.bad { color: var(--bad); }
.delta.neutral { color: var(--muted); }

/* 店舗詳細の上部 */
.store-bar { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.store-bar .left { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.store-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin-bottom: 12px; }
.store-title h2 { font-size: 20px; margin: 0; }
.balance-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; margin-bottom: 12px; }
.balance-strip.low { border-color: color-mix(in srgb, var(--danger) 45%, transparent); background: var(--danger-bg); }
.balance-strip .bal { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.balance-strip .item { display: flex; flex-direction: column; }
.balance-strip .note { flex-basis: 100%; color: var(--danger); font-size: 12px; }

/* グラフ */
.charts { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
@media (min-width: 1000px) { .charts { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted); margin: 4px 0 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.legend i.line { height: 3px; border-radius: 2px; vertical-align: 3px; width: 14px; }
.legend i.dash { height: 0; border-top: 2px dashed var(--c-ref); width: 14px; vertical-align: 3px; border-radius: 0; }
.chart { position: relative; width: 100%; }
.chart svg { display: block; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .ax { fill: var(--muted); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.chart .bar { fill: var(--c-spend); opacity: .85; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.gmv { stroke: var(--c-gmv); }
.chart .line.roas { stroke: var(--accent); }
.chart .ref { stroke: var(--c-ref); stroke-dasharray: 4 4; stroke-width: 1.5; }
.chart .ref-t { fill: var(--muted); font-size: 10.5px; }
.chart .hover-line { stroke: var(--line-strong); stroke-width: 1; }
.tip {
  position: absolute; top: 8px; pointer-events: none; z-index: 2;
  background: var(--card); border: 1px solid var(--line-strong); border-radius: 8px;
  padding: 7px 9px; font-size: 12px; box-shadow: 0 4px 14px rgba(0,0,0,.12); white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.tip .d { font-weight: 700; margin-bottom: 2px; }
.tip .row { display: flex; justify-content: space-between; gap: 14px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); background: var(--card);
  border-radius: 8px; padding: 7px 14px; cursor: pointer; font-weight: 600; font-size: 13px;
}
.btn.primary { background: var(--accent); color: var(--card); border-color: var(--accent); }
.back { font-size: 13px; white-space: nowrap; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 50;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 13px;
  max-width: calc(100% - 32px); box-shadow: 0 6px 20px rgba(0,0,0,.2);
}
footer { max-width: 1200px; margin: 0 auto; padding: 0 16px 28px; color: var(--muted); font-size: 12px; }
footer p { margin: 2px 0; }

/* 並べ替え */
.sortbox { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.seg-dir button { min-width: 72px; }
.sort-now { font-size: 12px; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
table.rt thead th.sorted { background: var(--accent-soft); color: var(--accent); }
table.rt td.sorted { background: color-mix(in srgb, var(--accent-soft) 55%, transparent); font-weight: 700; }
.formula { margin: 6px 0 0; }
@media (max-width: 720px) {
  table.rt td.sorted { background: transparent; color: var(--accent); }
  table.rt.compact td.sorted::before { color: var(--accent); }
}
.kpis.k10 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 900px) { .kpis.k10 { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
@media (min-width: 1000px) { .charts.three { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.chart .bar.impr { fill: var(--c-ref); }
.chart .line.clicks { stroke: var(--accent); }
.sub-chart-title { font-size: 12px; color: var(--muted); margin: 6px 0 0; }

/* 商品の個別ページ */
.item-title h2 { font-size: 19px; margin: 0; overflow-wrap: anywhere; }
.item-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 4px 0 12px; font-size: 12px; color: var(--muted); }
.item-nav { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 16px 0 0; }
.item-nav a, .item-nav span.disabled {
  display: inline-flex; align-items: center; min-height: 44px; padding: 6px 12px; border: 1px solid var(--line-strong);
  border-radius: 8px; background: var(--card); max-width: 42%; font-size: 13px; overflow: hidden;
}
.item-nav a span.nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-nav span.disabled { color: var(--muted); opacity: .6; }
.item-nav .pos { font-size: 12px; color: var(--muted); text-align: center; }
.dt-wrap { background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow-x: auto; box-shadow: var(--shadow); }
table.dt { border-collapse: collapse; width: 100%; min-width: 520px; font-size: 12.5px; }
table.dt th, table.dt td { padding: 7px 9px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.dt thead th { background: var(--card-2); color: var(--muted); font-weight: 600; font-size: 12px; }
table.dt th:first-child, table.dt td:first-child { position: sticky; left: 0; background: var(--card); text-align: left; z-index: 1; }
table.dt thead th:first-child { background: var(--card-2); }
table.dt tfoot td { font-weight: 700; border-top: 2px solid var(--line-strong); border-bottom: 0; }
table.dt td.weekend { color: var(--muted); }

/* 広告の情報（読み取りのみ。第1段階では変更のボタンは置かない） */
.budget-card .bc-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-top: 8px; }
.budget-card .bc-vals { display: flex; flex-wrap: wrap; gap: 6px 22px; }
.budget-card .bc-vals .v { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.budget-card .bc-vals > div { display: flex; flex-direction: column; }
.btn.lg { min-height: 44px; padding: 8px 16px; font-size: 14px; justify-content: center; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.reason { font-size: 12px; color: var(--muted); background: var(--card-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
h4 { font-size: 13px; margin: 14px 0 0; }
tr.flash td, .flash { animation: flash 2.4s ease-out; }
@keyframes flash { 0%, 30% { background: var(--accent-soft); } 100% { background: transparent; } }
.icon-btn { border: 0; background: transparent; font-size: 22px; line-height: 1; width: 44px; height: 44px; cursor: pointer; color: var(--muted); border-radius: 8px; }
.msg { margin-top: 10px; font-size: 13px; min-height: 20px; }
.msg.err { color: var(--danger); }
/* 表示通貨の切り替え・円換算 */
.nav { align-items: center; }
.cur-toggle { margin-left: auto; }
.cur-toggle button { min-width: 0; padding: 5px 10px; font-size: 12px; min-height: 32px; }
@media (min-width: 760px) { .cur-toggle { margin-left: 12px; } }
.rate-line { flex-basis: 100%; font-size: 12px; color: var(--accent); }
.item-meta .rate-line { margin-top: 2px; }
details.rates { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin-bottom: 12px; font-size: 13px; }
details.rates summary { cursor: pointer; color: var(--accent); font-weight: 600; min-height: 28px; display: flex; align-items: center; }
details.rates ul { margin: 6px 0 4px; padding-left: 18px; font-variant-numeric: tabular-nums; }
details.rates p { margin: 4px 0 0; }
table.rt tr.total td { font-weight: 700; }
.yen-hint { margin-top: 6px; font-size: 12px; color: var(--accent); }
/* 期間 */
.seg-period button { min-width: 0; padding: 6px 12px; }
.period-box { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 16px; margin: -4px 0 12px; }
.period-input { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.period-input input[type="date"] { min-width: 0; width: 150px; }
.period-input .btn { min-height: 34px; }
.period-box .msg { flex-basis: 100%; margin: 0; min-height: 0; }
.period-box .msg:empty { display: none; }
.period-now { display: flex; flex-direction: column; gap: 0; font-size: 12px; text-align: right; }
.period-now .pn-main { font-weight: 700; font-size: 13px; }
@media (max-width: 720px) {
  .period-now { text-align: left; }
  .period-input input[type="date"] { width: 140px; }
}
.chart .dot { stroke: none; }
.chart .dot.gmv { fill: var(--c-gmv); }
.chart .dot.roas, .chart .dot.clicks { fill: var(--accent); }
/* ページ内の目次 */
.toc { display: flex; gap: 6px; overflow-x: auto; margin: -4px 0 12px; padding-bottom: 2px; scrollbar-width: none; }
.toc button { flex: 0 0 auto; border: 1px solid var(--line-strong); background: var(--card); border-radius: 999px; padding: 5px 12px; font-size: 12px; cursor: pointer; min-height: 32px; }
/* 残り日数 */
.dl { font-size: 11.5px; white-space: nowrap; }
.danger-txt { color: var(--danger); font-weight: 700; }
.warn-txt { color: var(--warn); }
/* 要注意 */
.tag.watch { background: var(--warn-bg); color: var(--warn); text-decoration: none; }
.watch-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
@media (min-width: 900px) { .watch-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.watch-col { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 0; }
.wc-head { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 600; }
.wc-head b { color: var(--warn); }
.watch-col ul { list-style: none; margin: 6px 0 0; padding: 0; font-size: 12.5px; }
.watch-col li { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; border-top: 1px solid var(--line); }
.watch-col li a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.watch-col li .muted { white-space: nowrap; font-variant-numeric: tabular-nums; }
.watch-col .link-btn { padding-top: 6px; min-height: 32px; }
.watch-none { margin: 4px 0; color: var(--ok); font-weight: 600; }
.flag-chip { display: inline-flex; align-items: center; gap: 2px; background: var(--warn-bg); color: var(--warn); border-radius: 999px; padding: 0 0 0 10px; font-size: 12px; }
.icon-btn.sm { width: 32px; height: 32px; font-size: 16px; color: inherit; }
/* 切り替え（チェックボックス） */
.switch { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; cursor: pointer; min-height: 32px; white-space: nowrap; }
.switch input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.head-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.csv-btn { font-size: 12px; padding: 6px 10px; min-height: 34px; }
.sort-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.sort-row .formula { flex-basis: 100%; }
.link-btn { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 10px 0 0; font-size: 13px; }

/* ---- その2で足したもの ---- */
.env-badge { font-size: 11px; line-height: 1; padding: 4px 7px; border-radius: 999px; border: 1px dashed var(--line-strong); color: var(--muted); white-space: nowrap; }
.sm-btn { padding: 5px 10px; font-size: 12px; min-height: 32px; }
.nav .sm-btn { margin-left: 6px; }
@media (max-width: 759px) { .nav { flex-wrap: wrap; row-gap: 6px; } }
.nodata { color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; }
.kpi .value .nodata { font-size: 14px; }
.mb8 { margin-bottom: 8px; }
.mb10 { margin-bottom: 10px; }
.mb12 { margin-bottom: 12px; }
.mt6 { margin: 6px 0 0; }
.mt10 { margin-top: 10px; }
.note-tight { margin: -4px 0 8px; }
.w100 { width: 100%; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.sw.spend { background: var(--c-spend); }
.sw.line { height: 3px; width: 14px; vertical-align: 3px; }
.sw.gmv { background: var(--c-gmv); }
.sw.roas { background: var(--accent); }
.sw.dash { height: 0; border-top: 2px dashed var(--c-ref); width: 14px; vertical-align: 3px; border-radius: 0; background: none; }
.chart .bar.missing { fill: none; }
.err-box { background: var(--danger-bg); color: var(--danger); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; font-size: 13px; }
.login-card { max-width: 420px; margin: 40px auto; }
.login-card h2 { font-size: 18px; margin: 0 0 4px; }
.input.wide { max-width: none; margin-top: 4px; }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
table.rt td.day-none { color: var(--muted); }
.progress { display: inline-block; width: 80px; height: 6px; background: var(--line); border-radius: 3px; vertical-align: middle; margin-right: 6px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--accent); }
.p0 i { width: 0; } .p10 i { width: 10%; } .p20 i { width: 20%; } .p30 i { width: 30%; } .p40 i { width: 40%; } .p50 i { width: 50%; }
.p60 i { width: 60%; } .p70 i { width: 70%; } .p80 i { width: 80%; } .p90 i { width: 90%; } .p100 i { width: 100%; }
.err-msg { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }

/* 日ごとのグラフの左右の目盛り（左＝広告費、右＝売上） */
.chart .ax-l { fill: var(--c-spend); }
.chart .ax-r { fill: var(--c-gmv); }

/* スマホ幅（720px 以下）：ダッシュボード／店舗／商品の3画面（app.js の renderSp*）。PC の画面には出さない */
.sp-only { display: none; }
@media (max-width: 720px) {
  .sp-only { display: inline; }
  .pc-only { display: none; }
  .top-inner { padding: 8px 12px 0; }
  .nav { gap: 0; }
  .nav a { padding: 8px 7px 9px; font-size: 12.5px; }
  .nav .sm-btn { margin-left: 4px; padding: 5px 8px; }
  .cur-toggle button { padding: 5px 7px; }
  main { padding: 12px 12px 32px; }
}
.sp-back { display: inline-flex; align-items: center; min-height: 40px; font-size: 14px; }
.sp-period { margin-bottom: 4px; }
.sp-period .seg-period { margin-bottom: 8px; }
.sp-period .period-box { margin: 0 0 12px; }
.sp-period .period-input input[type="date"] { width: 132px; }
.sp-title { display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px; }
.sp-title h2 { font-size: 19px; margin: 0; overflow-wrap: anywhere; }
.sp-sum { margin-bottom: 12px; }
.sp-sum-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.sp-empty { margin: 4px 0; font-weight: 700; font-size: 15px; }
.sp-note { margin: 8px 0 0; color: var(--warn); }
.kpis.sp-k5 { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.kpis.sp-k5 .kpi { grid-column: span 2; padding: 9px 10px; }
.kpis.sp-k5 .kpi:nth-child(1), .kpis.sp-k5 .kpi:nth-child(2) { grid-column: span 3; }
.kpis.sp-k5 .kpi .value { font-size: 17px; }
.kpis.sp-k5 .kpi:nth-child(n+3) .value { font-size: 16px; }
.kpis.sp-k5 .kpi .delta { font-size: 11px; }
.sp-sum .kpi { box-shadow: none; background: var(--card-2); }
.sp-list-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px 10px; margin: 16px 0 6px; }
.sp-list-head h3 { display: inline; margin-right: 8px; }
.sp-selbtns { display: flex; gap: 6px; }
.sp-selbtns .btn { min-height: 40px; padding: 6px 12px; }
.sp-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.sp-list .empty { background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
.sp-grp { color: var(--muted); font-size: 12px; font-weight: 700; padding: 6px 2px 0; }
.sp-shop { display: flex; align-items: stretch; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); min-width: 0; }
.sp-shop.low { border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.sp-check { flex: 0 0 48px; display: flex; align-items: center; justify-content: center; border-right: 1px solid var(--line); cursor: pointer; }
.sp-check input { width: 22px; height: 22px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.sp-main, .sp-row { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 4px; padding: 9px 12px; color: inherit; }
.sp-row { background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.sp-main:hover, .sp-row:hover { text-decoration: none; }
.sp-name { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; min-width: 0; }
.sp-name b { color: var(--accent); overflow-wrap: anywhere; }
.sp-nums { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px 8px; }
.sp-nums.four { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px 6px; }
.sp-cell { display: flex; flex-direction: column; min-width: 0; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 13px; line-height: 1.35; overflow-wrap: anywhere; }
.sp-cell small { color: var(--muted); font-size: 11px; font-weight: 400; }
.sp-cell.sorted, .sp-cell.sorted small { color: var(--accent); }
.sp-nums.four .sp-cell { font-size: 12.5px; }
.sp-nodata { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.sp-bal { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; font-size: 13px; font-variant-numeric: tabular-nums; }
.sp-bal .dl { white-space: normal; }
.sp-balance { display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px; padding: 10px 12px; }
.sp-balance.low { border-color: color-mix(in srgb, var(--danger) 45%, transparent); background: var(--danger-bg); }
.sp-bal-v { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
.sp-bal-v .bal { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.sp-bal-v .dl { white-space: normal; font-size: 12.5px; }
.sp-watch ul { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.sp-watch li { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.sp-watch p { margin: 6px 0 0; color: var(--ok); }
.sp-watch.on { border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
body.sp .sortbox .sort-now { display: none; }
body.sp #prod-filter { max-width: none; }
body.sp .controls { flex-wrap: wrap; }

/* 残高の通知（Chatwork）の設定欄（連携の状態・スマホの店舗の画面） */
.alert-form { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.af-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.field .af-input { width: 140px; max-width: 100%; text-align: right; }
.af-cur { color: var(--muted); font-size: 12px; }
.af-check { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; cursor: pointer; }
.af-check input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.af-saved { color: var(--muted); }
.af-saved.err { color: var(--danger); }
.af-state { line-height: 1.6; }
.sp-alert { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
@media (max-width: 720px) {
  table.rt td.af-cell { display: block; text-align: left; padding-top: 6px; }
  table.rt td.af-cell::before { display: block; margin-bottom: 4px; }
  .field .af-input { width: 130px; min-height: 40px; }
  .af-save { min-height: 40px; padding: 6px 16px; }
}

/* 商品名（長い名前は省略。商品ID を小さく併記。スマホで横にはみ出さない） */
.item-cell { display: inline-flex; flex-direction: column; min-width: 0; max-width: 100%; vertical-align: top; }
.item-nm { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.item-id { display: block; font-size: 11px; font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
table.rt td.prod-cell { max-width: 340px; }
table.rt td.prod-cell .item-cell { max-width: 100%; }
.watch-col li .item-cell { flex: 1 1 auto; }
.sp-item { flex-wrap: nowrap; flex-direction: column; align-items: flex-start; }
.sp-item .item-cell { width: 100%; }
.sp-item .item-nm { white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow-wrap: anywhere; }
@media (max-width: 720px) {
  table.rt td.prod-cell { max-width: none; }
  table.rt td.prod-cell .item-nm { white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow-wrap: anywhere; }
}

/* ===== 第2段階：セルスマの数字（利益） ===== */
th.ss-col, td.ss-col { background: var(--card-2); }
@media (min-width: 1100px) { .watch-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpis.sp-k2 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.kpis.sp-k2 .kpi .value { font-size: 17px; }
.sp-nums.sp-pl { margin-top: 4px; padding-top: 4px; border-top: 1px dashed var(--line); }
.sp-nums.sp-pl .sp-cell { font-size: 12.5px; }
.ss-counts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; padding: 12px; }
@media (min-width: 900px) { .ss-counts { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.ss-counts > div { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.ss-counts b { font-size: 18px; font-variant-numeric: tabular-nums; }
.field .af-input.ssm-idx { width: 80px; }/* 商品別にセルスマの列を足した時（PC）：列が多いので詰めて、見出しは折り返す */
@media (min-width: 721px) {
  table.rt.with-ss { font-size: 12px; }
  table.rt.with-ss th, table.rt.with-ss td { padding: 7px 6px; }
  table.rt.with-ss thead th { white-space: normal; line-height: 1.3; vertical-align: bottom; }
  table.rt.with-ss thead th .sort-btn { white-space: normal; text-align: inherit; }
  table.rt.with-ss td.prod-cell { max-width: 190px; }
  table.rt.with-ss td.num { white-space: nowrap; }
}