/* ==========================================================================
   粗利率・利益率・原価率計算ツール
   PC: 左に入力カード / 右に計算結果（sticky）
   SP: 入力 → 結果の1カラム
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  background: #f3f5f8;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Kaku Gothic Pro', 'Yu Gothic', 'Meiryo', sans-serif;
  color: #1f2937;
  line-height: 1.6;
}

button, input, select, textarea { font-family: inherit; }

:focus-visible {
  outline: 2px solid #2f6fb0;
  outline-offset: 2px;
}

/* ── パンくず・導入 ───────────────────────────────────────────── */
.gpc__breadcrumb,
.gpc__seo-header,
.gpc__main-container,
.gpc__doc-section {
  max-width: 1180px;
  margin-left: auto;
  margin-right: auto;
}

.gpc__breadcrumb { margin-top: 14px; padding: 0 16px; }

.gpc__seo-header {
  margin-top: 10px;
  margin-bottom: 22px;
  padding: 0 16px;
}

.gpc__seo-header h1 {
  margin: 0 0 8px;
  font-size: 1.58rem;
  font-weight: 700;
  line-height: 1.4;
}

.gpc__seo-lead {
  margin: 0;
  max-width: 760px;
  color: #444;
  line-height: 1.75;
}

/* ── メインレイアウト ─────────────────────────────────────────── */
.gpc__main-container {
  margin-bottom: 48px;
  padding: 0 16px;
  display: grid;
  grid-template-columns: minmax(320px, 55fr) minmax(300px, 45fr);
  gap: 20px;
  align-items: start;
}

.gpc__form-column {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.gpc__card {
  background: #fff;
  border: 1px solid #e4e9f0;
  border-radius: 10px;
  padding: 22px 22px 18px;
}

.gpc__divider {
  border: none;
  border-top: 1px solid #eef1f5;
  margin: 8px 0 18px;
}

/* ── 計算モード ───────────────────────────────────────────── */
.gpc__tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}

.gpc-tab {
  padding: 10px 8px;
  border: 1px solid #e4e9f0;
  border-radius: 8px;
  background: #f8fafc;
  font-size: .84rem;
  font-weight: 600;
  color: #6b7280;
  cursor: pointer;
  text-align: center;
  line-height: 1.4;
}

.gpc-tab:hover { color: #2f6fb0; border-color: #2f6fb0; }

.gpc-tab.is-active {
  color: #1d4ed8;
  background: #eff6ff;
  border-color: #1d4ed8;
}

/* ── フォーム項目 ───────────────────────────────────────────── */
.gpc__form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.gpc__form-field label {
  font-size: .85rem;
  font-weight: 600;
  color: #4b5563;
}

.gpc__amount-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.gpc__amount-row input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 46px;
  padding: 10px 12px;
  font-size: 1.15rem;
  font-weight: 700;
  text-align: right;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: #1f2937;
}

.gpc__amount-row input:focus { border-color: #2f6fb0; }

.gpc__unit {
  flex: 0 0 auto;
  font-size: .92rem;
  font-weight: 600;
  color: #6b7280;
}

.gpc__field-note {
  margin: -1px 0 0;
  font-size: .78rem;
  color: #6b7280;
}

.gpc__input-error {
  margin: 2px 0 0;
  font-size: .78rem;
  color: #b42318;
}

.gpc__amount-row input.is-invalid {
  border-color: #b42318;
  background: #fffafa;
}

/* ── ボタン ───────────────────────────────────────────── */
.gpc__actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.gpc__btn-outline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  background: #fff;
  border: 1px solid #2f6fb0;
  color: #2f6fb0;
}

.gpc__btn-outline:hover { background: #eff6ff; }

.gpc__btn-text {
  background: none;
  border: none;
  padding: 6px 4px;
  font-size: .85rem;
  color: #9ca3af;
  text-decoration: underline;
  cursor: pointer;
}

.gpc__btn-text:hover { color: #6b7280; }

.gpc__auto-calc-note {
  margin: 10px 0 0;
  font-size: .78rem;
  color: #9ca3af;
}

/* ── 結果カード ───────────────────────────────────────────── */
.gpc__result-column {
  position: sticky;
  top: 20px;
}

.gpc__result-title {
  margin: 0 0 16px;
  font-size: 1.05rem;
  font-weight: 700;
  color: #1f2937;
}

.gpc__result-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 6px;
}

.gpc__result-card {
  padding: 16px 14px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #eef1f5;
}

.gpc__result-card-label {
  font-size: .82rem;
  font-weight: 600;
  color: #6b7280;
  margin-bottom: 6px;
}

.gpc__result-card-value {
  font-size: 1.2rem;
  font-weight: 700;
  color: #1f2937;
}

/* 金額カード（横並び1行・2列分いっぱいに広げる） */
.gpc__result-card--amount {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
}

.gpc__result-card--amount .gpc__result-card-label { margin-bottom: 0; }
.gpc__result-card--amount .gpc__result-card-value { font-size: 1.22rem; }

/* 率カード（大きな数字で強調） */
.gpc__result-card--rate {
  text-align: center;
  background: #eff6ff;
  border-color: #dbeafe;
}

.gpc__result-card--rate .gpc__result-card-label { color: #1d4ed8; }

.gpc__result-card--rate .gpc__result-card-value {
  font-size: 2.05rem;
  font-weight: 800;
  color: #1e3a8a;
  line-height: 1.2;
}

.gpc__result-card--empty .gpc__result-card-value { color: #9ca3af; }

/* 赤字（マイナス）を強調表示 */
.gpc__result-card--negative .gpc__result-card-value { color: #dc2626; }
.gpc__result-card--rate.gpc__result-card--negative { background: #fef2f2; border-color: #fecaca; }
.gpc__result-card--rate.gpc__result-card--negative .gpc__result-card-label { color: #b91c1c; }

/* 計算式 */
.gpc__formula {
  margin: 14px 0 0;
}

.gpc__formula-summary {
  padding: 4px 0;
  font-size: .9rem;
  font-weight: 600;
  color: #2f6fb0;
  cursor: pointer;
  list-style: none;
}

.gpc__formula-summary::-webkit-details-marker { display: none; }

.gpc__formula-body {
  margin-top: 10px;
  padding: 12px 14px;
  background: #f8fafc;
  border-radius: 8px;
}

.gpc__formula-list {
  margin: 0 0 10px;
  padding-left: 18px;
  font-size: .85rem;
  color: #374151;
  line-height: 1.9;
}

.gpc__formula-note {
  margin: 0;
  font-size: .8rem;
  color: #6b7280;
  line-height: 1.7;
}

/* ── 解説・FAQセクション ───────────────────────────────────── */
.gpc__doc-section {
  margin-top: 40px;
  margin-bottom: 60px;
  padding: 0 16px;
  color: #374151;
  line-height: 1.85;
}

.gpc__doc-section h2 {
  margin: 38px 0 14px;
  padding-left: 10px;
  border-left: 4px solid #1d4ed8;
  color: #111827;
  font-size: 1.22rem;
  font-weight: 700;
}

.gpc__doc-section h2:first-of-type { margin-top: 0; }

.gpc__doc-section h3 {
  margin: 0 0 6px;
  color: #1d4ed8;
  font-size: 1rem;
  font-weight: 700;
}

.gpc__doc-section p,
.gpc__doc-section li {
  color: #374151;
  font-size: .92rem;
  line-height: 1.85;
}

.gpc__doc-section p { margin: 0 0 12px; }
.gpc__doc-section a { color: #1d4ed8; font-weight: 600; }

.gpc__example-table {
  border-collapse: collapse;
  margin: 0 0 16px;
  font-size: .86rem;
  width: auto;
}

.gpc__example-table th,
.gpc__example-table td {
  border: 1px solid #e5e7eb;
  padding: 8px 20px;
  text-align: center;
}

.gpc__example-table th {
  background: #f8fafc;
  color: #4b5563;
  font-weight: 600;
}

.gpc__faq-item {
  margin-bottom: 10px;
  padding: 13px 16px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
}

.gpc__faq-item p { margin: 0; }

.related-links {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.related-links li a {
  display: block;
  margin: 0;
  padding: 11px 13px;
  border: 1px solid #e5e7eb;
  border-radius: 9px;
  background: #fff;
  color: #1d4ed8;
  font-weight: 600;
  font-size: .88rem;
  text-decoration: none;
}

.related-links li a:hover { background: #eff6ff; }

/* ── レスポンシブ ───────────────────────────────────────────── */
@media (max-width: 900px) {
  .gpc__main-container {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .gpc__form-column { order: 1; }
  .gpc__result-column {
    order: 2;
    position: static;
  }
}

@media (max-width: 560px) {
  .gpc__tabs { grid-template-columns: 1fr; }
  .gpc__result-grid { grid-template-columns: 1fr; }
  .gpc__result-card--rate .gpc__result-card-value { font-size: 1.9rem; }

  .gpc__actions { flex-direction: column-reverse; align-items: stretch; text-align: center; }
}

/* ── 印刷 ───────────────────────────────────────────── */
@media print {
  #header, #footer, .gpc__breadcrumb, .gpc__form-column,
  .gpc__doc-section { display: none !important; }
  .gpc__main-container { display: block; }
  .gpc__result-column { position: static; }
}
