/* =========================================
   ダッシュボード共通レイアウト
   ========================================= */

.app {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: 20px 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar__brand {
  padding: 4px 22px 22px;
  border-bottom: 1px solid var(--sidebar-border);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

.sidebar__brand-icon {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar__brand-icon svg { width: 18px; height: 18px; color: #fff; }

.sidebar__brand-text { font-size: 15px; font-weight: 700; letter-spacing: .5px; }
.sidebar__brand-sub { font-size: 12px; color: var(--muted); letter-spacing: 1px; margin-top: 1px; }

.sidebar__category {
  padding: 6px 22px 4px;
  font-size: 12px;
  letter-spacing: 1.5px;
  color: var(--muted);
  font-weight: 600;
  margin-top: 6px;
}

.sidebar__nav { list-style: none; padding: 0 10px; }

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--sidebar-text);
  margin-bottom: 2px;
  transition: background .15s, color .15s;
}

.sidebar__link:hover { background: rgba(60, 56, 51, .05); color: var(--text); }

.sidebar__link.is-active {
  background: var(--sidebar-bg-active);
  color: var(--sidebar-text-active);
  font-weight: 600;
}

.sidebar__link.is-active::before {
  content: '';
  position: absolute;
  left: 0;
  width: 3px;
  height: 22px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
  margin-left: -10px;
}

.sidebar__link { position: relative; }

.sidebar__icon { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar__footer {
  margin-top: auto;
  padding: 18px 22px 6px;
  border-top: 1px solid var(--sidebar-border);
  font-size: 12px;
  color: var(--muted);
}

/* ダッシュボード一覧へ戻る = ボタンらしい見た目に（2026-07-27） */
.sidebar__back {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-light);
  background: var(--card-alt);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 9px 12px;
  margin-bottom: 8px;
  transition: background .15s, border-color .15s, color .15s;
}

.sidebar__back:hover { color: var(--text); background: var(--border); border-color: var(--border-strong); }

/* ---------- Main area ---------- */
.main {
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-width: 0;   /* グリッド項目の溢れ防止（横スクロールは各 .table-wrap 等が個別に担う） */
  /* 注: ここに overflow-x を付けると .topbar の position:sticky が無効化されるため付けない */
}

.topbar {
  background: var(--topbar-bg);
  color: var(--text);
  border-bottom: 1px solid var(--topbar-border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar__title {
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar__title-icon { width: 22px; height: 22px; }

.topbar__separator { color: var(--border-strong); font-weight: 400; font-size: 15px; }

.topbar__subtitle { font-weight: 500; color: var(--text-light); font-size: 15px; }

.topbar__filters { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }

.topbar__filter {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.topbar__filter-label {
  font-size: 12px;
  letter-spacing: 1px;
  color: var(--muted);
  font-weight: 600;
}

.topbar__filter-select {
  padding: 5px 28px 5px 10px;
  border-radius: 6px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%236f695f' stroke-width='2'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  cursor: pointer;
  min-width: 130px;
}
.topbar__filter-select:hover { border-color: var(--border-strong); }

.topbar__updated {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.content {
  padding: 18px 28px 28px;
  max-width: 100%;
}

/* ---------- KPI cards ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(152px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi {
  background: var(--card);
  border-radius: 14px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  animation: fadeUp .4s ease-out both;
}

.kpi__icon {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}

.kpi__icon svg { width: 22px; height: 22px; }

/* KPIアイコン色 — 4色に集約。旧 --blue/--orange/--purple/--teal は新しいパレットに自動マップ */
.kpi__icon--navy   { background: var(--kpi-navy); }
.kpi__icon--green  { background: var(--kpi-green); }
.kpi__icon--yellow { background: var(--kpi-yellow); }
.kpi__icon--red    { background: var(--kpi-red); }
.kpi__icon--blue   { background: var(--kpi-navy); }  /* alias → navy */
.kpi__icon--orange { background: var(--kpi-yellow); } /* alias → yellow */
.kpi__icon--purple { background: var(--kpi-navy); }  /* alias → navy */
.kpi__icon--teal   { background: var(--kpi-green); } /* alias → green */

.kpi__body { flex: 1; min-width: 0; }

.kpi__label {
  font-size: 12px;
  color: var(--text-light);
  font-weight: 500;
  margin-bottom: 4px;
}

.kpi__value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  display: flex;
  align-items: baseline;
  gap: 3px;
}

.kpi__unit {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-light);
}

.kpi__sub {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.kpi__delta {
  font-size: 12px;
  font-weight: 600;
}
.kpi__delta--up { color: var(--success); }
.kpi__delta--down { color: var(--danger); }
.kpi__delta--flat { color: var(--muted); }

.kpi__progress {
  margin-top: 8px;
  height: 4px;
  background: var(--card-alt);
  border-radius: 999px;
  overflow: hidden;
}
.kpi__progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width .6s ease-out;
}

/* ---------- Section / Card ---------- */
.section {
  background: var(--card);
  border-radius: 14px;
  padding: 16px 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

.section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 10px;
}

.section__title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.section__title-bar {
  display: inline-block;
  width: 3px;
  height: 16px;
  background: var(--accent);
  border-radius: 2px;
}

.section__legend {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text-light);
}

.section__legend-item { display: inline-flex; align-items: center; gap: 5px; }

.section__legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

/* ---------- Data table（2026-07-21 全表アップグレード: 枠付きラウンド容器＋ゼブラ＋軽い罫線） ---------- */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
}

.table {
  width: 100%;
  font-size: 13px;
  border-collapse: collapse;
  white-space: nowrap;
}

.table th, .table td {
  padding: 10px 12px;
  text-align: right;
  border-bottom: 1px solid rgba(60, 56, 51, .07);
}

.table th {
  background: var(--card-alt);
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: .05em;
  position: sticky;
  top: 0;
}

.table tbody tr:nth-child(even) td { background: rgba(60, 56, 51, .018); }
.table tbody tr:last-child td { border-bottom: none; }

.table th:first-child, .table td:first-child {
  text-align: left;
  font-weight: 600;
  color: var(--text);
  background: var(--card);
  position: sticky;
  left: 0;
  z-index: 1;
}

/* Corner header (sticky top + left): must sit above the sticky first-column body cells (z-index:1) so it isn't covered on vertical scroll */
.table th:first-child { background: var(--card-alt); z-index: 2; }

.table tbody tr:hover td { background: rgba(61, 139, 110, .03); }

.table tfoot td {
  font-weight: 700;
  background: var(--card-alt);
  border-top: 2px solid var(--border-strong);
}

.table--funnel th { text-align: center; padding: 8px 10px; }
.table--funnel td { text-align: center; }
.table--funnel td:first-child, .table--funnel th:first-child { text-align: left; }

/* Cell highlight */
.cell-num { font-variant-numeric: tabular-nums; }
.cell-good { color: var(--success); font-weight: 700; }
.cell-bad { color: var(--danger); font-weight: 700; }
.cell-rate { color: var(--text); font-weight: 600; }
.cell-rate.is-low { color: var(--danger); }
.cell-rate.is-mid { color: var(--warn); }
.cell-rate.is-high { color: var(--success); }
.cell-zero { color: var(--muted); }

.heatmap--high { background: rgba(61, 139, 110, .15); color: var(--accent-dark); font-weight: 700; }
.heatmap--mid { background: rgba(212, 160, 60, .14); color: #8a6618; font-weight: 600; }
.heatmap--low { background: rgba(212, 100, 92, .12); color: #a8443d; font-weight: 600; }

/* Stage column colors (funnel) — 3段階に集約
   進行中: navy → 内定〜受諾: accent → 入社: accent-dark / 退社: muted */
.stage-contact    { color: var(--kpi-navy); }
.stage-apply      { color: var(--kpi-navy); }
.stage-interview1 { color: var(--kpi-navy); }
.stage-interview2 { color: var(--accent); }
.stage-offer      { color: var(--accent); }
.stage-accept     { color: var(--accent-dark); font-weight: 700; }
.stage-hire       { color: var(--accent-dark); font-weight: 700; }
.stage-resign     { color: var(--muted); }

/* ---------- Two-column / Grid sections ---------- */
.grid-2 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}

/* グリッド項目の溢れ防止: nowrap テーブル等の最小幅で列が押し広げられ
   カード外へはみ出すのを防ぐ（横スクロールは各 .table-wrap が担う） */
.grid-2 > *, .grid-3 > * { min-width: 0; }

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-bottom: 18px;
}

/* ---------- Pipeline (Sprint3) ---------- */
.pipe-stages {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 22px;
}

.pipe-stage {
  background: var(--card);
  border-radius: 12px;
  padding: 14px 14px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  align-items: stretch;
  gap: 10px;
}
/* 量が一目で分かるよう、カード下に「最多の段階＝100%」の帯を敷く（2026-07-27） */
.pipe-stage__body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.pipe-stage__track {
  height: 6px; margin-top: 10px; border-radius: 2px;
  background: var(--card-alt); overflow: hidden;
}
.pipe-stage__bar { height: 100%; border-radius: 2px; transition: width .3s ease-out; }

.pipe-stage__icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}
.pipe-stage__icon svg { width: 18px; height: 18px; }

.pipe-stage__label { font-size: 12px; color: var(--text-light); margin-bottom: 2px; font-weight: 500; }
.pipe-stage__value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: baseline;
  gap: 2px;
}
.pipe-stage__unit { font-size: 12px; font-weight: 500; color: var(--text-light); }
.pipe-stage__delta { font-size: 12px; color: var(--text-light); margin-top: 2px; }

.pipe-stage__arrow {
  position: relative;
}

.candidate-tag {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  background: var(--card-alt);
  color: var(--text);
  margin: 2px 3px 2px 0;
  white-space: nowrap;
}

/* 候補者タグ — 3段階に集約（早期グレー → 中期薄緑 → 後期濃緑） */
.candidate-tag--apply      { background: var(--card-alt); color: var(--text-light); }
.candidate-tag--interview1 { background: var(--card-alt); color: var(--text-light); }
.candidate-tag--interview2 { background: var(--accent-light); color: var(--accent-dark); }
.candidate-tag--offer      { background: var(--accent-light); color: var(--accent-dark); }
.candidate-tag--accept     { background: var(--accent); color: #fff; }
.candidate-tag--hire       { background: var(--accent-dark); color: #fff; font-weight: 700; }

/* ---------- Side panel (right column) ---------- */
.side-stack { display: flex; flex-direction: column; gap: 14px; }

.side-block {
  background: var(--card);
  border-radius: 12px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.side-block__title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
  padding-left: 8px;
  border-left: 3px solid var(--accent);
}

.side-block--warn .side-block__title { border-left-color: var(--danger); }
.side-block--memo { background: #fffbe6; }
.side-block--memo .side-block__title { border-left-color: var(--warn); }

.interview-item {
  font-size: 13px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
}
.interview-item:last-child { border-bottom: none; }
.interview-item__meta { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.interview-item__name { font-weight: 600; }
.interview-item__time { font-size: 12px; color: var(--text-light); margin-top: 2px; }

.consult-item {
  font-size: 13px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
}
.consult-item:last-child { border-bottom: none; }
.consult-item__title { font-weight: 600; font-size: 13px; margin-bottom: 3px; }
.consult-item__desc { font-size: 12px; color: var(--text-light); line-height: 1.5; }

/* ---------- Chart container ---------- */
.chart-wrap { position: relative; width: 100%; }

.chart-wrap--md { height: 280px; }
.chart-wrap--lg { height: 340px; }
.chart-wrap--sm { height: 200px; }

/* ---------- Footer note ---------- */
.note {
  font-size: 12px;
  color: var(--muted);
  margin-top: 10px;
}

/* ---------- Empty / Placeholder ---------- */
.placeholder {
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px;
}

.placeholder__icon {
  width: 80px;
  height: 80px;
  border-radius: 22px;
  background: var(--card-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
  color: var(--muted);
}
.placeholder__icon svg { width: 38px; height: 38px; }

.placeholder__title { font-size: 19px; font-weight: 700; margin-bottom: 6px; }
.placeholder__desc { font-size: 14px; color: var(--text-light); max-width: 440px; }
.placeholder__badge {
  display: inline-block;
  margin-top: 14px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

/* ---------- Mobile menu toggle ---------- */
.menu-toggle {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--card-alt);
  border: 1px solid var(--border);
  color: var(--text);
  align-items: center;
  justify-content: center;
}

.menu-toggle svg { width: 20px; height: 20px; }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 240px;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform .25s ease-out;
  }
  .sidebar.is-open { transform: translateX(0); box-shadow: 0 0 60px rgba(0, 0, 0, .35); }
  .menu-toggle { display: inline-flex; }
  .topbar { padding: 12px 16px; flex-wrap: wrap; }
  .topbar__title { font-size: 15px; }
  .topbar__filters { width: 100%; gap: 8px; }
  .topbar__filter-select { font-size: 12px; min-width: 100px; }
  .content { padding: 16px 14px 40px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi { padding: 12px 12px; gap: 9px; }
  .kpi__icon { width: 32px; height: 32px; border-radius: 9px; }
  .kpi__icon svg { width: 18px; height: 18px; }
  .kpi__value { font-size: 19px; }
  .kpi__label { font-size: 12px; }
  .section { padding: 14px 14px; border-radius: 12px; }
  .section__title { font-size: 14px; }
  .grid-3 { grid-template-columns: 1fr; }
  .pipe-stages { grid-template-columns: repeat(2, 1fr); }
  .pipe-stage__value { font-size: 18px; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .topbar__title { font-size: 14px; }
  .topbar__subtitle { display: none; }
  .topbar__updated { display: none; }
}

/* =========================================
   デザイン磨き込み（2026-07-21・全ページ共通）
   ========================================= */

/* ブランド（左上）= サマリーへ戻るリンク */
a.sidebar__brand { cursor: pointer; }
a.sidebar__brand .sidebar__brand-logo { transition: transform .2s ease; }
a.sidebar__brand:hover .sidebar__brand-logo { transform: scale(1.06) rotate(-3deg); }
a.sidebar__brand:hover .sidebar__brand-text { color: var(--accent-dark); }
a.sidebar__brand:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 8px; }

/* サイドバー: hoverで軽く前へ・アイコンにブランド色 */
.sidebar__link { transition: background .15s, color .15s, transform .15s ease; }
.sidebar__link:hover { transform: translateX(2px); }
.sidebar__link:hover .sidebar__icon,
.sidebar__link.is-active .sidebar__icon { color: var(--accent); }

/* トップバー: 半透明＋ブラーでスクロール時にコンテンツが透ける */
@supports (backdrop-filter: blur(8px)) {
  .topbar {
    background: color-mix(in srgb, var(--topbar-bg) 86%, transparent);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }
}

/* 数値の桁揃え（表・KPIは等幅数字で読み比べやすく） */
.table td, .kpi__value, .pipe-stage__value { font-variant-numeric: tabular-nums; }
.table th { letter-spacing: .3px; }

/* カード: hoverでわずかに浮く（影 .04 → .06 の控えめな変化） */
.kpi, .section, .side-block { transition: box-shadow .25s ease; }
.kpi:hover, .section:hover, .side-block:hover { box-shadow: var(--shadow-md); }

/* スクロールバーを細く目立たなく（表の横スクロール・サイドバー） */
.sidebar, .table-wrap { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.table-wrap::-webkit-scrollbar { height: 8px; width: 8px; }
.sidebar::-webkit-scrollbar { width: 6px; }
.table-wrap::-webkit-scrollbar-thumb, .sidebar::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
}
.table-wrap::-webkit-scrollbar-track, .sidebar::-webkit-scrollbar-track { background: transparent; }

/* 表の行hoverを少しだけ明確に */
.table tbody tr:hover td { background: rgba(61, 139, 110, .05); }

/* Mask for mobile sidebar */
.sidebar-mask {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .35);
  z-index: 99;
}
.sidebar-mask.is-open { display: block; }
