/* Canterano 週次コックピット — DESIGN_SYSTEM.md 準拠のトンマナ */

:root {
  --paper: #faf8f4;
  --white: #ffffff;
  --ink: #17203c;
  --ink-2: #2c3556;
  --muted: #666d7d;
  --faint: #9aa0ac;
  --sand: #efeae0;
  --sand-2: #f4f0e8;
  --line: #e6e1d6;
  --line-2: #eeeae1;
  --accent: #2f5aa6;
  --accent-soft: #edf1f8;
  --radius: 14px;

  --sans: "Noto Sans JP", system-ui, -apple-system, sans-serif;
  --disp: "Zen Kaku Gothic New", "Noto Sans JP", sans-serif;
  --en: "Montserrat", var(--sans);
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.9;
  letter-spacing: 0.02em;
  -webkit-font-smoothing: antialiased;
}

.container {
  width: min(1200px, 100% - clamp(22px, 5vw, 64px) * 2);
  margin-inline: auto;
}

/* ---- ヘッダー ---- */
.app-header {
  border-bottom: 1px solid var(--line);
  background: var(--white);
  padding: 20px 0;
}
.app-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
}
.app-title__en {
  display: block;
  font-family: var(--en);
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
}
.app-title__ja {
  display: block;
  font-family: var(--disp);
  font-weight: 700;
  font-size: clamp(1.2rem, 2.4vw, 1.6rem);
  margin-top: 2px;
}

/* ---- 週選択 ---- */
.week-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.week-nav__btn {
  border: 1px solid var(--ink);
  border-radius: 2px;
  background: var(--white);
  color: var(--ink);
  font-family: var(--en);
  font-weight: 700;
  font-size: 0.85rem;
  padding: 0.6em 1em;
  cursor: pointer;
  transition: 0.4s var(--ease);
  text-decoration: none;
  display: inline-block;
  /* CJKテキストは既定でどの文字間でも改行できるため、flex縮小時にボタン内で
     縦一文字ずつ折り返るのを防ぐ(ボタン単位でwrapさせ、文字単位では折り返さない)。 */
  white-space: nowrap;
  flex-shrink: 0;
}
.week-nav__btn:hover:not(:disabled) {
  background: var(--ink);
  color: var(--paper);
}
.week-nav__btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.week-nav__label {
  font-family: var(--en);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  min-width: 11ch;
  text-align: center;
}
.week-nav__range {
  font-size: 0.78rem;
  color: var(--faint);
  display: block;
  text-align: center;
  margin-top: 2px;
  font-weight: 400;
  letter-spacing: 0;
}

/* ---- セクション共通 ---- */
.section {
  padding: clamp(48px, 7vw, 88px) 0;
}
.section + .section {
  border-top: 1px solid var(--line-2);
}
.sec-head {
  margin-bottom: clamp(24px, 3vw, 40px);
}
.sec-head__en {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--en);
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
}
.sec-head__en::before {
  content: "";
  display: inline-block;
  width: 34px;
  height: 1px;
  background: var(--accent);
}
.sec-head__ja {
  font-family: var(--disp);
  font-weight: 700;
  font-size: clamp(1.1rem, 2.4vw, 1.5rem);
  margin: 8px 0 0;
}
.sec-head__note {
  color: var(--faint);
  font-size: 0.82rem;
  margin: 6px 0 0;
}
.sec-head--row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}
.waterfall-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.trend-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.trend-controls__label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
}
.gap-link-card {
  text-align: center;
}
.gap-link-card a {
  color: var(--accent);
  font-weight: 600;
}

/* ---- 数値タイル ---- */
.num-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.num {
  text-align: center;
  padding: 34px 16px;
  background: var(--white);
}
.num__val {
  font-family: var(--en);
  font-weight: 700;
  font-size: clamp(1.8rem, 3.6vw, 2.6rem);
  color: var(--ink);
  line-height: 1;
  letter-spacing: -0.01em;
}
.num__unit {
  font-weight: 600;
  color: var(--accent);
  margin-left: 4px;
  font-size: 0.9rem;
}
.num__sub {
  font-family: var(--en);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--muted);
  margin-left: 8px;
}
.num__label {
  color: var(--muted);
  margin-top: 14px;
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.6;
}
.num__label small {
  display: block;
  color: var(--faint);
  font-size: 0.68rem;
  margin-top: 2px;
}
@media (max-width: 940px) {
  .num-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 560px) {
  .num-grid {
    grid-template-columns: 1fr;
  }
}
.num-grid--3 {
  grid-template-columns: repeat(3, 1fr);
}
@media (max-width: 700px) {
  .num-grid--3 {
    grid-template-columns: 1fr;
  }
}

/* ---- カード ---- */
.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(20px, 3vw, 32px);
}
.card__visual {
  background: var(--sand-2);
  border-radius: 10px;
  padding: 16px 18px;
  margin-top: 8px;
}
.card + .card {
  margin-top: clamp(18px, 2.4vw, 28px);
}
.chart-wrap {
  position: relative;
  height: 320px;
}
.chart-wrap--short {
  height: 240px;
}

/* ---- 週次ファネル表 ---- */
.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
}
table.funnel {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  font-variant-numeric: tabular-nums;
}
table.funnel th,
table.funnel td {
  padding: 12px 14px;
  text-align: right;
  border-bottom: 1px solid var(--line-2);
  white-space: nowrap;
}
table.funnel th:first-child,
table.funnel td:first-child {
  text-align: left;
}
table.funnel thead th {
  font-family: var(--en);
  font-weight: 600;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--sand-2);
}
table.funnel tbody tr:last-child td {
  border-bottom: none;
}
table.funnel tr.is-total td {
  font-weight: 700;
  background: var(--accent-soft);
  border-top: 1px solid var(--accent);
}
@media (hover: hover) {
  table.funnel tbody tr:not(.is-total):not(.is-inactive-summary):hover td {
    background: var(--sand-2);
  }
}
/* ---- 週次ファネル表: 非稼働メンバーの折りたたみ行 ---- */
table.funnel tr.is-inactive-summary td {
  background: var(--white);
  text-align: left;
  padding: 8px 14px;
}
table.funnel tr.is-inactive-member td {
  color: var(--faint);
}
.link-toggle {
  border: none;
  background: none;
  color: var(--accent);
  font-family: var(--en);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  cursor: pointer;
  padding: 0;
}
.link-toggle:hover {
  text-decoration: underline;
}
table.funnel td.member-name {
  font-family: var(--disp);
  font-weight: 700;
}
.rate-cell {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
.rate-cell__main {
  font-family: var(--en);
  font-weight: 700;
}
.rate-cell__delta {
  font-size: 0.68rem;
  font-family: var(--en);
  font-weight: 600;
}
.rate-cell__delta.is-up {
  color: var(--accent);
}
.rate-cell__delta.is-down {
  color: var(--faint);
}
.rate-cell__delta.is-flat {
  color: var(--faint);
}

/* ---- データ健全性バッジ ---- */
.health-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--en);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.6em 1em;
  border-radius: 2px;
  border: 1px solid var(--line);
}
.badge--ok {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent);
}
.badge--attention {
  color: var(--ink);
  background: var(--sand);
  border-color: var(--ink);
}
.badge__icon {
  font-size: 0.9rem;
}

/* ---- ローディング/エラー ---- */
.state-msg {
  color: var(--faint);
  font-size: 0.85rem;
  padding: 24px 0;
}
.state-msg--error {
  color: var(--ink);
}

.footer-note {
  color: var(--faint);
  font-size: 0.76rem;
  padding: 24px 0 60px;
}

/* ---- 後確処理（保留中の受注） ---- */
table.funnel tr.is-attention td {
  background: var(--sand);
}
.row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.btn-sm {
  border: 1px solid var(--ink);
  border-radius: 2px;
  background: var(--white);
  color: var(--ink);
  font-family: var(--en);
  font-weight: 700;
  font-size: 0.72rem;
  padding: 0.5em 0.9em;
  cursor: pointer;
  transition: 0.4s var(--ease);
  white-space: nowrap;
  text-decoration: none;
  display: inline-block;
}
.btn-sm:hover {
  background: var(--ink);
  color: var(--paper);
}
.btn-sm--cancel {
  border-color: var(--faint);
  color: var(--muted);
}
.select-sm {
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--white);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 0.78rem;
  padding: 0.45em 0.6em;
}
