:root {
  --accent: #7c4dff; --accent-bg: #f1ecff;
  --stage-candidate: #757575; --stage-candidate-bg: #f0f0f0;
  --stage-visit: #0277bd; --stage-visit-bg: #e1f5fe;
  --stage-visited: #2e7d32; --stage-visited-bg: #e8f5e9;
  --eval-none: #757575; --eval-none-bg: #f0f0f0;
  --eval-strong: #2e7d32; --eval-strong-bg: #e8f5e9;
  --eval-excluded: #c62828; --eval-excluded-bg: #ffebee;
  --axis-temp: #e65100; --axis-temp-bg: #fff3e0;
  --axis-cont: #4527a0; --axis-cont-bg: #ede7f6;
  --border: #e6e6ee;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Hiragino Kaku Gothic ProN", "Meiryo", sans-serif;
  background: #faf9fd; color: #26232b;
}
header {
  background: #263238;
  color: #fff; padding: 20px 24px 0;
}
header h1 { margin: 0; font-size: 1.35rem; }
header p { margin: 6px 0 14px; font-size: 0.85rem; opacity: 0.85; }

.tabs { display: flex; gap: 4px; }
.tab-btn {
  background: rgba(255,255,255,0.12); color: #fff; border: none;
  border-radius: 8px 8px 0 0; padding: 10px 20px; font-size: 0.9rem; font-weight: bold;
  cursor: pointer; opacity: 0.75;
}
.tab-btn.active { background: #faf9fd; color: #263238; opacity: 1; }

.tab-panel { display: none; max-width: 1280px; margin: 0 auto; padding: 18px 18px 40px; }
.tab-panel.active { display: block; }

.err-banner {
  background: #ffebee; color: #b71c1c; padding: 10px 20px; font-size: 0.85rem;
  text-align: center; border-bottom: 1px solid #ef9a9a;
}

.controls {
  display: flex; flex-wrap: wrap; gap: 16px; align-items: center;
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 16px; margin-bottom: 14px; font-size: 0.85rem;
  box-shadow: 0 2px 8px rgba(60,40,120,0.05);
}
.controls input[type=text] {
  padding: 8px 14px; border: 1px solid var(--border); border-radius: 20px;
  font-size: 0.88rem; width: 220px;
}
.controls fieldset { border: none; margin: 0; padding: 0; display: flex; gap: 8px; align-items: center; }
.controls legend { font-size: 0.72rem; color: #888; padding: 0; float: left; margin-right: 4px; }
.controls label { display: inline-flex; align-items: center; gap: 3px; cursor: pointer; font-size: 0.8rem; }

.view-toggle { display: none; gap: 6px; margin-bottom: 12px; }
.vt-btn {
  flex: 1; padding: 8px; border-radius: 8px; border: 1px solid var(--border);
  background: #fff; font-size: 0.85rem; font-weight: bold; color: #666; cursor: pointer;
}
.vt-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

#split-container { display: flex; gap: 16px; }
#list-panel { flex: 1; min-width: 0; }
#map-panel { width: 380px; flex-shrink: 0; }
#map { height: 560px; width: 100%; border-radius: 10px; border: 1px solid var(--border); position: sticky; top: 12px; }
.map-legend {
  display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; padding: 8px 10px;
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  font-size: 0.72rem; color: #666; position: sticky; top: 584px;
}
.map-legend-item { display: inline-flex; align-items: center; gap: 4px; }
.map-legend-item i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

.count { font-size: 0.8rem; color: #888; margin: 0 0 10px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px,1fr)); gap: 16px; }
.card {
  background: #fff; border-radius: 14px; padding: 16px 18px;
  box-shadow: 0 2px 10px rgba(60,40,120,0.06); border: 1px solid var(--border);
  cursor: pointer; transition: transform .12s;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(60,40,120,0.12); }
.card.excluded { opacity: 0.6; }

.badges { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.badge { display: inline-block; font-size: 0.68rem; font-weight: bold; padding: 3px 9px; border-radius: 10px; white-space: nowrap; }
.badge.axis-temp { color: var(--axis-temp); background: var(--axis-temp-bg); }
.badge.axis-cont { color: var(--axis-cont); background: var(--axis-cont-bg); }
.badge.rank { color: #999; background: #f4f4f8; }
.badge.stage-candidate { color: var(--stage-candidate); background: var(--stage-candidate-bg); }
.badge.stage-visit { color: var(--stage-visit); background: var(--stage-visit-bg); }
.badge.stage-visited { color: var(--stage-visited); background: var(--stage-visited-bg); }
.badge.eval-none { color: var(--eval-none); background: var(--eval-none-bg); }
.badge.eval-strong { color: var(--eval-strong); background: var(--eval-strong-bg); }
.badge.eval-excluded { color: var(--eval-excluded); background: var(--eval-excluded-bg); }

.card h3 { margin: 2px 0 10px; font-size: 1.02rem; line-height: 1.35; }
.meta { font-size: 0.82rem; color: #555; margin: 2px 0; }
.meta b { color: #222; }

.req-mini { display: flex; gap: 4px; margin: 10px 0; flex-wrap: wrap; }
.req { display: inline-flex; align-items: center; gap: 2px; font-size: 0.64rem; padding: 2px 6px; border-radius: 8px; background: #f4f4f8; color: #666; }
.req.y { background: #e8f5e9; color: #2e7d32; }
.req.m { background: #fff8e1; color: #f57f17; }
.req.n { background: #ffebee; color: #c62828; }
.req.u { background: #f0f0f0; color: #aaa; }

.visit-note {
  background: #f6f4ff; border-left: 3px solid var(--accent);
  padding: 6px 10px; font-size: 0.76rem; border-radius: 0 6px 6px 0; margin-top: 8px;
}
.excl-note {
  background: #fff1f1; border-left: 3px solid #c62828;
  padding: 6px 10px; font-size: 0.76rem; border-radius: 0 6px 6px 0; margin-top: 8px; color: #8f2323;
}
.bottom-row { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; font-size: 0.72rem; color: #999; }
.bottom-row a { color: var(--accent); text-decoration: none; font-weight: bold; }
.bottom-row a:hover { text-decoration: underline; }

/* ---- 進捗ボード（カンバン） ---- */
.board { display: flex; gap: 14px; overflow-x: auto; align-items: flex-start; padding-bottom: 10px; }
.col { background: #ece8f7; border-radius: 12px; min-width: 300px; max-width: 320px; flex-shrink: 0; padding: 10px; }
.col-head { display: flex; justify-content: space-between; align-items: center; padding: 4px 6px 10px; }
.col-head h2 { margin: 0; font-size: 0.92rem; color: #3d2c8d; }
.col-head .n { font-size: 0.72rem; background: #fff; border-radius: 10px; padding: 1px 8px; color: #666; }

.kcard {
  background: #fff; border-radius: 10px; padding: 12px 13px; margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08); border-left: 4px solid #ccc; cursor: pointer;
}
.kcard.eval-strong { border-left-color: var(--eval-strong); }
.kcard.eval-excluded { border-left-color: var(--eval-excluded); opacity: 0.65; }
.kcard.eval-none { border-left-color: #b0bec5; }
.kcard-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 6px; margin-bottom: 6px; }
.kcard h4 { margin: 0 0 6px; font-size: 0.88rem; line-height: 1.3; }
.kcard .meta { font-size: 0.72rem; }
.kcard .price { font-size: 0.76rem; color: #37474f; font-weight: bold; margin: 4px 0; }
.kcard-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: 0.68rem; color: #999; }
.kcard-foot a { color: var(--accent); text-decoration: none; }

/* ---- モーダル ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(30,20,50,0.5);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px;
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: #fff; border-radius: 14px; max-width: 560px; width: 100%;
  max-height: 88vh; overflow-y: auto; padding: 24px; position: relative;
}
.modal-close {
  position: absolute; top: 12px; right: 14px; background: none; border: none;
  font-size: 1.4rem; cursor: pointer; color: #888; line-height: 1;
}
.modal h2 { margin: 0 0 4px; font-size: 1.15rem; }
.modal .field-row { display: flex; gap: 10px; margin: 12px 0; }
.modal label.field-label { font-size: 0.78rem; color: #666; display: block; margin-bottom: 4px; }
.modal select, .modal input[type=date], .modal textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 0.88rem;
  font-family: inherit;
}
.modal textarea { min-height: 60px; resize: vertical; }
.modal .req-detail-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 6px; margin: 10px 0; font-size: 0.8rem; }
.modal .req-detail-grid div { background: #f8f7fc; border-radius: 6px; padding: 6px 8px; }
.modal .visit-list { margin: 10px 0; }
.modal .visit-item { background: #f6f4ff; border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; font-size: 0.82rem; display: flex; justify-content: space-between; gap: 8px; }
.modal .visit-item button { border: none; background: none; color: #c62828; cursor: pointer; font-size: 0.78rem; }
.modal button.primary {
  background: var(--accent); color: #fff; border: none; border-radius: 8px;
  padding: 10px 16px; font-size: 0.88rem; font-weight: bold; cursor: pointer;
}
.modal button.secondary {
  background: #f0f0f5; color: #444; border: none; border-radius: 8px;
  padding: 10px 16px; font-size: 0.85rem; cursor: pointer;
}

/* ---- カスタム日付ピッカー（team-infoboardと同パターン） ---- */
.date-picker-wrap { position: relative; }
input.date-hidden {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; pointer-events: auto; z-index: 1; cursor: pointer;
  border: none; background: transparent; padding: 0; margin: 0;
}
.date-disp {
  display: flex; align-items: center; justify-content: space-between;
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; color: #26232b; font-size: 0.88rem; cursor: pointer;
  user-select: none; white-space: nowrap; position: relative; z-index: 2;
}
.date-picker-wrap:focus-within .date-disp { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(124,77,255,0.15); }
.date-disp-icon { color: #999; margin-left: 8px; flex-shrink: 0; }
.date-disp-placeholder { color: #999; }

footer { text-align: center; font-size: 0.75rem; color: #999; padding: 24px 0; }

/* ---- レスポンシブ ---- */
@media (max-width: 900px) {
  #map-panel { width: 320px; }
}
@media (max-width: 768px) {
  .view-toggle { display: flex; }
  #split-container { flex-direction: column; }
  #map-panel { width: 100%; display: none; }
  #map-panel.mobile-active { display: block; }
  #list-panel.mobile-hidden { display: none; }
  #map { height: 65vh; position: static; }
  .map-legend { position: static; }
  .controls input[type=text] { width: 100%; }
}
