/*
 * 在庫健康診断 — 見た目
 * 色は Quickloda（quickloda-gcp/frontend/src/index.css）のデザイントークンに合わせる。
 * 文字は端末のフォント（外部フォントを読み込まない＝通信を増やさない）。
 */
:root {
  --sd-surface: #f8f9ff;
  --sd-card: #ffffff;
  --sd-container-low: #eff4ff;
  --sd-container: #e5eeff;
  --sd-container-high: #dce9ff;
  --sd-on-surface: #0b1c30;
  --sd-on-variant: #424754;
  --sd-outline: #727785;
  --sd-outline-variant: #c2c6d6;
  --sd-primary: #0058be;
  --sd-primary-container: #2170e4;
  --sd-primary-fixed: #d8e2ff;
  --sd-navy: #082b63; /* LP の本文色 */
  --sd-good: #006c49;
  --sd-good-bg: #d6f5e8;
  --sd-warn: #825100;
  --sd-warn-bg: #ffddb8;
  --sd-error: #ba1a1a;
  --sd-error-bg: #ffdad6;
  --sd-radius: 16px;
  --sd-font: 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', 'Noto Sans JP', Meiryo, 'Yu Gothic', sans-serif;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--sd-surface);
  color: var(--sd-on-surface);
  font-family: var(--sd-font);
  font-size: 16px;
  line-height: 1.75;
  overflow-wrap: anywhere;
}

img {
  max-width: 100%;
  height: auto;
}

a {
  color: var(--sd-primary);
}

[hidden] {
  display: none !important;
}

.sd-wrap {
  width: 100%;
  max-width: 1040px;
  margin-inline: auto;
  padding-inline: 16px;
}

.sd-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.sd-small {
  font-size: 13px;
  color: var(--sd-on-variant);
  line-height: 1.7;
}

.sd-pc {
  display: inline;
}

/* ---------- ヘッダ ---------- */
.sd-header {
  background: var(--sd-card);
  box-shadow: 0 0 14px rgb(0 0 0 / 10%);
}

.sd-header__inner {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 60px;
}

.sd-header__logo img {
  display: block;
  width: 120px;
  height: auto;
}

.sd-header__name {
  font-weight: 700;
  color: var(--sd-navy);
  font-size: 15px;
}

.sd-header__link {
  margin-left: auto;
  font-size: 13px;
  white-space: nowrap;
}

/* ---------- ヒーロー ---------- */
.sd-hero {
  background: linear-gradient(135deg, #eff4ff 0%, #fdf9ff 100%);
  padding: 40px 0 32px;
}

.sd-hero__eyebrow {
  display: inline-block;
  margin: 0 0 12px;
  padding: 2px 12px;
  border-radius: 999px;
  background: var(--sd-primary);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.sd-hero__title {
  margin: 0 0 16px;
  color: var(--sd-navy);
  font-size: clamp(22px, 4.2vw, 34px);
  line-height: 1.45;
}

.sd-hero__lead {
  margin: 0 0 20px;
  max-width: 46em;
}

.sd-privacy {
  max-width: 46em;
  padding: 14px 18px;
  border-left: 4px solid var(--sd-good);
  border-radius: 8px;
  background: var(--sd-card);
  font-size: 14px;
}

.sd-hero__sample {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin: 20px 0 0;
}

.sd-hero__sample .sd-small {
  margin: 0;
}

.sd-privacy p {
  margin: 0;
}

.sd-privacy__title {
  font-weight: 700;
  color: var(--sd-good);
  margin-bottom: 4px !important;
}

/* ---------- セクション共通 ---------- */
.sd-section {
  padding: 32px 0;
}

.sd-h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 16px;
  color: var(--sd-navy);
  font-size: 22px;
  line-height: 1.4;
}

.sd-step {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--sd-primary);
  color: #fff;
  font-size: 15px;
}

.sd-panel {
  margin-top: 16px;
  padding: 20px;
  border-radius: var(--sd-radius);
  background: var(--sd-card);
  box-shadow: 0 4px 20px rgba(11, 28, 48, 0.05);
  min-width: 0;
}

.sd-panel h3 {
  margin: 0 0 4px;
  font-size: 17px;
  color: var(--sd-navy);
}

.sd-panel .sd-sub {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--sd-on-variant);
}

.sd-grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.sd-grid2 > .sd-panel {
  margin-top: 16px;
}

/* ---------- アップロード ---------- */
.sd-drops {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.sd-drop {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 20px;
  border: 2px dashed var(--sd-outline-variant);
  border-radius: var(--sd-radius);
  background: var(--sd-card);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.sd-drop:hover,
.sd-drop:focus-within,
.sd-drop.is-over {
  border-color: var(--sd-primary);
  background: var(--sd-container-low);
}

.sd-drop.is-loaded {
  border-style: solid;
  border-color: var(--sd-good);
}

.sd-drop__title {
  font-weight: 700;
  font-size: 17px;
  color: var(--sd-navy);
}

.sd-drop__hint {
  font-size: 13px;
  color: var(--sd-on-variant);
}

.sd-drop__action {
  margin-top: 6px;
  color: var(--sd-primary);
  font-weight: 700;
  font-size: 14px;
}

.sd-drop__status {
  font-size: 13px;
  color: var(--sd-good);
  font-weight: 700;
}

.sd-drop__status.is-error {
  color: var(--sd-error);
}

.sd-badge {
  display: inline-block;
  margin-left: 4px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--sd-container);
  color: var(--sd-on-variant);
  font-size: 12px;
  font-weight: 700;
  vertical-align: 2px;
}

.sd-badge--req {
  background: var(--sd-primary);
  color: #fff;
}

.sd-linkbtn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--sd-primary);
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}

/* ---------- 列の確認 ---------- */
.sd-map {
  margin-bottom: 16px;
  padding: 16px 20px;
  border-radius: var(--sd-radius);
  background: var(--sd-card);
}

.sd-map h3 {
  margin: 0 0 8px;
  font-size: 16px;
  color: var(--sd-navy);
}

.sd-map__row {
  display: grid;
  grid-template-columns: 150px minmax(0, 260px) minmax(0, 1fr);
  gap: 8px 12px;
  align-items: center;
  padding: 6px 0;
  border-top: 1px solid var(--sd-container);
}

.sd-map__label {
  font-weight: 700;
  font-size: 14px;
}

.sd-map__sample {
  font-size: 12px;
  color: var(--sd-on-variant);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sd-map select {
  width: 100%;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid var(--sd-outline-variant);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  font-size: 14px;
}

.sd-map select.is-missing {
  border-color: var(--sd-error);
  background: var(--sd-error-bg);
}

/* ---------- ボタン ---------- */
.sd-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 20px;
  border: 1px solid var(--sd-primary);
  border-radius: 999px;
  background: #fff;
  color: var(--sd-primary);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.sd-btn--primary {
  background: var(--sd-primary);
  color: #fff;
  padding-inline: 32px;
  font-size: 17px;
}

.sd-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.sd-error {
  margin: 12px 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--sd-error-bg);
  color: var(--sd-error);
  font-size: 14px;
}

/* ---------- 結果 ---------- */
.sd-result__head,
.sd-detail__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
}

.sd-notes {
  margin: 0;
  padding-left: 1.2em;
  font-size: 13px;
  color: var(--sd-warn);
}

.sd-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 12px;
}

.sd-card {
  padding: 20px;
  border-radius: var(--sd-radius);
  background: var(--sd-card);
  box-shadow: 0 10px 30px rgba(11, 28, 48, 0.06);
  border-top: 4px solid var(--sd-primary);
  min-width: 0;
}

.sd-card__label {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--sd-on-variant);
}

.sd-card__value {
  margin: 4px 0 0;
  font-size: clamp(26px, 5vw, 34px);
  font-weight: 800;
  line-height: 1.25;
  color: var(--sd-navy);
  font-variant-numeric: tabular-nums;
}

.sd-card__value small {
  font-size: 15px;
  font-weight: 700;
  margin-left: 2px;
}

.sd-card__sub {
  margin: 6px 0 0;
  font-size: 14px;
  color: var(--sd-on-surface);
}

.sd-card__def {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--sd-on-variant);
  line-height: 1.6;
}

.sd-card--empty .sd-card__value {
  font-size: 18px;
  color: var(--sd-outline);
}

.sd-kpis {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
  margin: 0;
}

.sd-kpis div {
  padding: 8px 0;
  border-bottom: 1px solid var(--sd-container);
}

.sd-kpis dt {
  font-size: 13px;
  color: var(--sd-on-variant);
}

.sd-kpis dd {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  color: var(--sd-navy);
  font-variant-numeric: tabular-nums;
}

/* グラフ（自前SVG） */
.sd-chart {
  display: block;
  width: 100%;
  max-width: 560px; /* 横に広げすぎると文字が大きくなるため */
  height: auto;
  overflow: visible;
}

.sd-chart text {
  font-family: var(--sd-font);
  fill: var(--sd-on-surface);
}

.sd-chart .sd-axis {
  fill: var(--sd-on-variant);
  font-size: 12px;
}

.sd-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  font-size: 12px;
  color: var(--sd-on-variant);
}

.sd-legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 4px;
  border-radius: 2px;
  vertical-align: -1px;
}

/* 表 */
.sd-tablewrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.sd-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.sd-table th,
.sd-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--sd-container);
  text-align: left;
  white-space: nowrap;
}

.sd-table th {
  background: var(--sd-container-low);
  color: var(--sd-on-variant);
  font-weight: 700;
  font-size: 12px;
}

.sd-table td.num,
.sd-table th.num {
  text-align: right;
}

.sd-table td.wrap {
  white-space: normal;
  min-width: 8em;
}

.sd-pill {
  display: inline-block;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.sd-pill--out {
  background: var(--sd-error-bg);
  color: var(--sd-error);
}

.sd-pill--risk {
  background: var(--sd-warn-bg);
  color: var(--sd-warn);
}

.sd-pill--good {
  background: var(--sd-good-bg);
  color: var(--sd-good);
}

.sd-pill--warn {
  background: var(--sd-warn-bg);
  color: var(--sd-warn);
}

.sd-pill--bad {
  background: var(--sd-error-bg);
  color: var(--sd-error);
}

/* ---------- 申し込み ---------- */
.sd-unlock {
  background: var(--sd-container-low);
}

.sd-form {
  max-width: 560px;
  padding: 20px;
  border-radius: var(--sd-radius);
  background: var(--sd-card);
}

.sd-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 14px;
}

.sd-field label {
  font-weight: 700;
  font-size: 14px;
}

.sd-field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--sd-outline-variant);
  border-radius: 8px;
  font: inherit;
}

.sd-field input:focus {
  outline: 2px solid var(--sd-primary);
  outline-offset: 1px;
}

.sd-req {
  color: var(--sd-error);
}

.sd-hp {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.sd-sendpreview {
  margin: 4px 0 14px;
  font-size: 13px;
}

.sd-sendpreview summary {
  cursor: pointer;
  color: var(--sd-primary);
  font-weight: 700;
}

.sd-sendpreview pre {
  max-height: 240px;
  overflow: auto;
  padding: 10px;
  border-radius: 8px;
  background: var(--sd-surface);
  font-size: 12px;
  white-space: pre-wrap;
}

/* ---------- 詳細レポート ---------- */
.sd-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.sd-steps li {
  padding: 14px;
  border-radius: 12px;
  background: var(--sd-container-low);
  font-size: 14px;
}

.sd-steps .sd-steps__when {
  display: block;
  margin-bottom: 4px;
  color: var(--sd-primary);
  font-weight: 800;
  font-size: 13px;
}

.sd-steps .sd-steps__meta {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--sd-on-variant);
}

.sd-cta {
  margin-top: 16px;
  padding: 24px;
  border-radius: var(--sd-radius);
  background: var(--sd-navy);
  color: #fff;
}

.sd-cta h3 {
  margin: 0 0 8px;
  font-size: 19px;
}

.sd-cta p {
  margin: 0 0 8px;
}

.sd-cta a {
  color: #fff;
  font-weight: 700;
}

.sd-print-only {
  display: none;
}

/* ---------- フッタ ---------- */
.sd-footer {
  padding: 28px 0 40px;
  background: var(--sd-card);
  border-top: 1px solid var(--sd-container);
  font-size: 13px;
  color: var(--sd-on-variant);
}

.sd-footer p {
  margin: 0 0 8px;
}

/* ---------- スマホ ---------- */
@media (max-width: 767px) {
  .sd-pc {
    display: none;
  }

  .sd-hero {
    padding: 28px 0 24px;
  }

  .sd-drops,
  .sd-cards,
  .sd-grid2,
  .sd-steps {
    grid-template-columns: 1fr;
  }

  .sd-map__row {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .sd-panel,
  .sd-form {
    padding: 16px;
  }

  .sd-header__logo img {
    width: 96px;
  }

  .sd-btn--primary {
    width: 100%;
  }
}

/* ---------- 印刷（A4・1〜2ページ） ---------- */
@media print {
  @page {
    size: A4;
    margin: 12mm;
  }

  body {
    background: #fff;
    font-size: 10.5px;
    line-height: 1.5;
  }

  .sd-header__link,
  .sd-hero,
  #step-upload,
  #step-mapping,
  #step-unlock,
  #btn-print,
  .sd-footer,
  .sd-cta,
  #result-trends {
    display: none !important;
  }

  .sd-print-only {
    display: block;
  }

  .sd-wrap {
    max-width: none;
    padding: 0;
  }

  .sd-header {
    box-shadow: none;
    border-bottom: 1px solid #999;
  }

  .sd-header__inner {
    min-height: 0;
    padding-bottom: 4px;
  }

  .sd-section {
    padding: 6px 0;
  }

  .sd-h2 {
    font-size: 14px;
    margin-bottom: 6px;
  }

  .sd-step {
    width: 20px;
    height: 20px;
    font-size: 11px;
  }

  .sd-panel,
  .sd-card {
    margin-top: 6px;
    padding: 8px 10px;
    box-shadow: none;
    border: 1px solid #ccc;
    break-inside: avoid;
  }

  .sd-cards {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .sd-grid2 {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .sd-steps {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .sd-steps li {
    padding: 6px;
    font-size: 10px;
  }

  .sd-card__value {
    font-size: 20px;
  }

  .sd-card__def {
    display: none;
  }

  .sd-kpis {
    grid-template-columns: repeat(3, 1fr);
    gap: 0 8px;
  }

  .sd-kpis div {
    padding: 2px 0;
  }

  .sd-kpis dt {
    font-size: 9px;
  }

  .sd-kpis dd {
    font-size: 12px;
  }

  .sd-panel h3 {
    font-size: 12px;
  }

  .sd-table {
    font-size: 9px;
  }

  .sd-table th,
  .sd-table td {
    padding: 1px 4px;
    line-height: 1.2;
  }

  .sd-table td.wrap {
    white-space: nowrap;
  }

  .sd-table .sd-small {
    font-size: 8.5px;
  }

  .sd-panel .sd-sub {
    margin-bottom: 4px;
    font-size: 9.5px;
  }

  .sd-panel details {
    display: none;
  }

  .sd-legend {
    margin-top: 2px;
    font-size: 9px;
  }

  .sd-chart {
    max-height: 120px;
  }

  .sd-tablewrap {
    overflow: visible;
  }

  /* 1ページ目＝結果＋次の一手、2ページ目＝一覧表（滞留・欠品・店舗別スコア） */
  #detail-stagnant {
    break-before: page;
  }

  #print-meta {
    margin: 0;
    font-size: 9px;
  }

  * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
