/* ToT 共通の土台スタイル。サイト共通の /css/common.css の後に読み込む。
   白基調・主操作は青・成功は緑・エラーは赤＋文字。common.css に合わせてダークモードにも対応。 */
:root {
  --tot-surface: #f6f8fb;
  --tot-field-bg: #ffffff;
  --tot-border: #d6dce5;
  --tot-input-border: #9aa5b5;
  --tot-text: #1a2230;
  --tot-muted: #5a6575;
  --tot-primary: #1d5fd1;
  --tot-primary-hover: #164ba8;
  --tot-primary-soft: #e8f0fd;
  --tot-on-primary: #ffffff;
  --tot-success: #157347;
  --tot-success-text: #0f5132;
  --tot-success-soft: #e7f5ee;
  --tot-danger: #b42318;
  --tot-danger-soft: #fdecea;
  --tot-focus: #f2a900;
  --tot-radius: 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --tot-surface: #20242b;
    --tot-field-bg: #15181d;
    --tot-border: #3a414c;
    --tot-input-border: #5c6675;
    --tot-text: #e8ecf2;
    --tot-muted: #a7b0bd;
    --tot-primary: #6ea2ff;
    --tot-primary-hover: #8fb7ff;
    --tot-primary-soft: #1d2a40;
    --tot-on-primary: #0b1220;
    --tot-success: #4cc38a;
    --tot-success-text: #9be0bd;
    --tot-success-soft: #15291f;
    --tot-danger: #ff8a7a;
    --tot-danger-soft: #3a1d1a;
  }
}

.tot-main *, .tot-main *::before, .tot-main *::after { box-sizing: border-box; }

.tot-main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px 16px 64px;
  color: var(--tot-text);
  font-size: 16px;
  line-height: 1.7;
}
.tot-main a { color: var(--tot-primary); }
/* ツールの表示部分。中の2列・1列の切り替えは画面幅ではなくこの幅で決める（@container tot-tool。作業画面の並べて表示の片側でも合う） */
.tot-tool { container: tot-tool / inline-size; }
.tot-main :focus-visible { outline: 3px solid var(--tot-focus); outline-offset: 2px; }

.tot-visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.tot-main [hidden] { display: none !important; }

/* ── パンくず ── */
.tot-crumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: 0 6px;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
  font-size: 12px;
  color: var(--tot-muted);
}
.tot-crumbs li + li::before { content: "›"; margin-right: 6px; }
.tot-crumbs a { color: var(--tot-muted); text-decoration: none; }
.tot-crumbs a:hover { text-decoration: underline; }

/* ── タイトル ── */
.tot-version {
  display: inline-block;
  margin-bottom: 4px;
  padding: 0 8px;
  border: 1px solid var(--tot-border);
  border-radius: 999px;
  font-size: 12px;
  color: var(--tot-muted);
}
.tot-main .tot-open-tab {
  display: inline-flex; align-items: center; min-height: 36px; margin-left: 8px; padding: 2px 12px;
  border: 1px solid var(--tot-primary); border-radius: var(--tot-radius);
  font-size: 14px; font-weight: 600; text-decoration: none; vertical-align: middle;
}
.tot-main .tot-open-tab:hover { background: var(--tot-primary-soft); }
.tot-main .tot-title h1 { margin: 0 0 4px; font-size: 26px; line-height: 1.35; letter-spacing: 0; }
.tot-main .tot-lead { margin: 0 0 12px; color: var(--tot-muted); }

.tot-main .tot-privacy {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: 0 0 20px;
  padding: 10px 14px;
  border-radius: var(--tot-radius);
  background: var(--tot-success-soft);
  color: var(--tot-success-text);
  font-size: 14px;
}

.tot-doc { margin-top: 36px; }
.tot-main .tot-doc h2 {
  font-size: 20px;
  margin: 0 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--tot-border);
}

/* ── ボタン ── */
.tot-btn {
  appearance: none;
  min-height: 44px;
  padding: 8px 18px;
  border: 1px solid var(--tot-primary);
  border-radius: var(--tot-radius);
  background: transparent;
  color: var(--tot-primary);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.tot-btn:hover { background: var(--tot-primary-soft); }
.tot-btn-primary { background: var(--tot-primary); color: var(--tot-on-primary); }
.tot-btn-primary:hover { background: var(--tot-primary-hover); }
.tot-btn-quiet { border-color: var(--tot-border); color: var(--tot-muted); }
.tot-btn-quiet:hover { background: var(--tot-surface); }

@media (min-width: 900px) {
  .tot-main { padding: 24px 24px 80px; }
  .tot-main .tot-title h1 { font-size: 30px; }
}

/* 利用状況の計測の設定（src/shared/usage/usage-page.js。画面の下に出し、ツールの操作を妨げない。閉じられる） */
.tot-usage-note { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 50; max-width: 720px; max-height: 70vh; overflow: auto; margin: 0 auto; padding: 12px 14px; border: 1px solid var(--tot-border); border-radius: var(--tot-radius); background: var(--tot-field-bg); color: var(--tot-text); font-size: 13px; line-height: 1.6; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15); }
.tot-usage-note p { margin: 0 0 6px; }
.tot-usage-title { font-weight: 700; font-size: 14px; }
.tot-usage-state { color: var(--tot-muted); }
.tot-usage-note a { color: var(--tot-primary); }
.tot-usage-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 8px; }
/* 「許可する」「許可しない」は同じ見た目（どちらかを目立たせない） */
.tot-usage-btn { min-height: 36px; padding: 4px 16px; border: 1px solid var(--tot-input-border); border-radius: 6px; background: var(--tot-surface); color: var(--tot-text); font: inherit; font-weight: 600; cursor: pointer; }
.tot-usage-btn:focus-visible, .tot-usage-note-close:focus-visible { outline: 3px solid var(--tot-focus); outline-offset: 2px; }
.tot-usage-note-close { margin-left: auto; padding: 2px 10px; border: 1px solid var(--tot-input-border); border-radius: 6px; background: transparent; color: var(--tot-text); font: inherit; cursor: pointer; }

/* TOT-027 国内4販路・利益比較 */
.tot-mp { display: grid; gap: 20px; }
.tot-mp-h2 { margin: 0 0 8px; font-size: 18px; }
.tot-form-note { margin: 0 0 12px; font-size: 14px; color: var(--tot-muted); }

.tot-mp-common {
  padding: 16px;
  border: 1px solid var(--tot-border);
  border-radius: var(--tot-radius);
}
.tot-mp-common-grid { display: grid; gap: 4px 16px; }

.tot-field { margin-bottom: 14px; }
.tot-field label { display: block; font-weight: 600; margin-bottom: 4px; }
.tot-input-wrap { display: flex; align-items: center; gap: 8px; }
.tot-input-wrap input, .tot-field select {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--tot-input-border);
  border-radius: var(--tot-radius);
  font: inherit;
  color: var(--tot-text);
  background: var(--tot-field-bg);
}
.tot-input-wrap input { font-size: 18px; font-variant-numeric: tabular-nums; text-align: right; }
.tot-field select { width: 100%; font-size: 15px; }
.tot-input-wrap input[aria-invalid="true"] { border: 2px solid var(--tot-danger); background: var(--tot-danger-soft); }
.tot-unit { width: 1.5em; font-weight: 600; color: var(--tot-muted); }
.tot-hint { margin: 2px 0 0; font-size: 13px; color: var(--tot-muted); }
.tot-hint:empty { display: none; }
.tot-field-error { margin: 4px 0 0; font-size: 14px; color: var(--tot-danger); font-weight: 600; }
.tot-field-error::before { content: "⚠ "; }
.tot-link-btn {
  appearance: none;
  margin: 2px 0 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--tot-primary);
  font: inherit;
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
}

.tot-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.tot-btn:disabled { opacity: 0.55; cursor: not-allowed; background: transparent; }
.tot-copy-msg { font-size: 14px; color: var(--tot-success); font-weight: 600; }

/* ── 比較表 ── */
.tot-result {
  padding: 16px;
  border: 1px solid var(--tot-border);
  border-radius: var(--tot-radius);
  background: var(--tot-surface);
}
.tot-result-title { margin: 0 0 8px; font-size: 18px; }
.tot-result-empty { margin: 0; color: var(--tot-muted); }
.tot-pending p { margin: 0 0 6px; }
.tot-pending-missing { color: var(--tot-muted); }
.tot-pending-error { margin: 0; color: var(--tot-danger); font-weight: 600; }

.tot-mp-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tot-mp-caption { caption-side: bottom; padding-top: 8px; font-size: 12px; color: var(--tot-muted); text-align: left; }
.tot-mp-table th, .tot-mp-table td { padding: 8px 6px; border-bottom: 1px solid var(--tot-border); text-align: right; white-space: nowrap; }
.tot-mp-table th:first-child { text-align: left; }
.tot-mp-table thead th { font-size: 13px; color: var(--tot-muted); font-weight: 600; }
.tot-mp-table tbody th { font-weight: 700; }
.tot-mp-table td:nth-child(2) { font-weight: 800; }
.tot-mp-table tr.is-loss td:nth-child(2) { color: var(--tot-danger); }
.tot-mp-table tr.is-best td:nth-child(2) { color: var(--tot-success); }
.tot-mp-na { color: var(--tot-danger); font-weight: 600; text-align: left !important; white-space: normal !important; }
.tot-mp-best, .tot-mp-manual {
  display: inline-block;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  vertical-align: middle;
}
.tot-mp-best { background: var(--tot-success-soft); color: var(--tot-success-text); border: 1px solid var(--tot-success); }
.tot-mp-manual { background: var(--tot-primary-soft); color: var(--tot-primary); border: 1px solid var(--tot-primary); }

/* ── 販路カード ── */
.tot-mp-cards { display: grid; gap: 16px; }
.tot-mp-card {
  padding: 14px 16px;
  border: 1px solid var(--tot-border);
  border-top: 4px solid var(--tot-border);
  border-radius: var(--tot-radius);
}
.tot-mp-card.is-best { border-top-color: var(--tot-success); }
.tot-mp-card.is-loss { border-top-color: var(--tot-danger); }
.tot-mp-card-title { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 18px; }
.tot-badge { padding: 1px 10px; border-radius: 999px; font-size: 13px; }
.tot-badge-loss { background: var(--tot-danger); color: var(--tot-field-bg); }

.tot-profit {
  padding: 10px 14px;
  border-radius: var(--tot-radius);
  border-left: 6px solid var(--tot-success);
  background: var(--tot-success-soft);
}
.tot-profit.is-loss { border-left-color: var(--tot-danger); background: var(--tot-danger-soft); }
.tot-profit-label { margin: 0; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.tot-profit-value { margin: 0; font-size: 30px; font-weight: 800; line-height: 1.25; font-variant-numeric: tabular-nums; color: var(--tot-success); }
.tot-profit.is-loss .tot-profit-value { color: var(--tot-danger); }

.tot-breakdown { margin: 8px 0 0; }
.tot-breakdown > div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--tot-border); }
.tot-breakdown dt { font-weight: 600; }
.tot-breakdown dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.tot-note { display: block; font-size: 12px; font-weight: 400; color: var(--tot-muted); }

.tot-mp-ship { margin-bottom: 4px; }
.tot-mp-ship .tot-field { margin-bottom: 10px; }
.tot-mp-details { margin-top: 10px; }
.tot-mp-details > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 600; color: var(--tot-primary); }
.tot-mp-settings { padding-top: 6px; }
.tot-mp-notes { margin: 4px 0 0; padding-left: 1.2em; font-size: 12px; color: var(--tot-muted); }
.tot-mp-notes li { margin-bottom: 2px; }
.tot-mp-source { margin: 10px 0 0; font-size: 12px; color: var(--tot-muted); }
.tot-mp-source a { color: var(--tot-muted); }
.tot-mp-source summary { cursor: pointer; }
.tot-mp-source p { margin: 4px 0; }
.tot-mp-source ul { margin: 4px 0 0; padding-left: 1.2em; }

/* ── 説明 ── */
.tot-rules { padding-left: 1.2em; margin: 0; }
.tot-rules li { margin-bottom: 4px; }
.tot-fee-table { border-collapse: collapse; width: 100%; font-size: 14px; }
.tot-fee-table th, .tot-fee-table td { padding: 6px 8px; border: 1px solid var(--tot-border); text-align: left; vertical-align: top; }
.tot-fee-table th { background: var(--tot-surface); }
.tot-table-scroll { overflow-x: auto; }
.tot-noscript { color: var(--tot-danger); font-weight: 700; }

/* 2列にするかはツールの表示幅で決める（作業画面の並べて表示の片側でも狭ければ縦に並べる。.tot-tool は base.css の tot-tool コンテナ） */
@container tot-tool (min-width: 608px) {
  .tot-mp-common-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@container tot-tool (min-width: 840px) {
  .tot-mp-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@container tot-tool (max-width: 448px) {
  .tot-mp-table th, .tot-mp-table td { padding: 8px 4px; font-size: 14px; }
  .tot-mp-table thead th:nth-child(4), .tot-mp-table td:nth-child(4),
  .tot-mp-table thead th:nth-child(5), .tot-mp-table td:nth-child(5) { display: none; }
}
.tot-formula { margin: 0 0 12px; display: grid; gap: 6px; }
.tot-formula > div { display: grid; grid-template-columns: 5em 1fr; gap: 8px; }
.tot-formula dt { font-weight: 700; }
.tot-formula dd { margin: 0; }
