/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue: #3b82f6;
  --blue-light: #dbeafe;
  --blue-dark: #1d4ed8;
  --green: #16a34a;
  --green-light: #dcfce7;
  --red: #dc2626;
  --red-light: #fee2e2;
  --amber: #d97706;
  --amber-light: #fef3c7;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-700: #334155;
  --gray-900: #0f172a;
  --radius: 12px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --shadow-hover: 0 4px 12px rgba(0,0,0,.12), 0 8px 32px rgba(0,0,0,.1);
  --sidebar-w: 260px;
  --transition: .2s ease;
}

body {
  font-family: -apple-system, 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  line-height: 1.6;
  font-size: 14px;
}

/* ===== Header ===== */
.site-header {
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  padding: 20px 16px 0;
}
.header-inner {
  max-width: 1280px;
  margin: 0 auto;
}
.site-header h1 {
  font-size: clamp(18px, 4vw, 26px);
  font-weight: 700;
  color: var(--blue-dark);
  letter-spacing: -.01em;
}
.header-sub {
  color: var(--gray-500);
  font-size: 13px;
  margin-top: 4px;
}

/* Accordion */
.scoring-guide {
  margin-top: 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.scoring-guide summary {
  cursor: pointer;
  padding: 10px 14px;
  background: var(--gray-50);
  font-weight: 600;
  font-size: 13px;
  color: var(--blue-dark);
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.scoring-guide summary::-webkit-details-marker { display: none; }
.scoring-guide summary::before {
  content: '▶';
  font-size: 10px;
  transition: transform var(--transition);
}
.scoring-guide[open] summary::before { transform: rotate(90deg); }

.guide-content {
  padding: 16px;
  border-top: 1px solid var(--gray-200);
  background: #fff;
}
.guide-content h3 {
  font-size: 13px;
  font-weight: 700;
  margin: 14px 0 6px;
  color: var(--gray-700);
}
.guide-content h3:first-child { margin-top: 0; }

.guide-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.guide-table th, .guide-table td {
  padding: 6px 10px;
  text-align: left;
  border-bottom: 1px solid var(--gray-100);
}
.guide-table th {
  background: var(--gray-100);
  font-weight: 600;
  color: var(--gray-700);
}
.guide-content ul {
  padding-left: 18px;
  font-size: 13px;
  color: var(--gray-700);
}
.guide-content li { margin: 3px 0; }
.guide-note {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 6px;
  font-style: italic;
}

/* ===== 地価トレンド表・警告ボックス ===== */
.land-trend-table td { vertical-align: top; font-size: 12px; }
.land-trend-table td:first-child { white-space: nowrap; text-align: center; }
.trend-high { color: var(--green); }
.trend-mid  { color: var(--amber); }
.trend-low  { color: var(--gray-500); }

.warn-box {
  margin-top: 12px;
  padding: 10px 14px;
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--gray-700);
}
.warn-box p { margin-bottom: 6px; font-size: 13px; }
.warn-box ul { padding-left: 16px; }
.warn-box li { margin: 4px 0; }
.scenario-down { color: var(--red); }
.scenario-up   { color: var(--green); }

/* ===== Layout ===== */
.layout {
  display: flex;
  max-width: 1280px;
  margin: 0 auto;
  min-height: calc(100vh - 200px);
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid var(--gray-200);
  padding: 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  scrollbar-width: thin;
}
.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 12px;
  color: var(--gray-700);
}
.sidebar-close {
  display: none;
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--gray-500);
  padding: 2px 6px;
  border-radius: 4px;
}
.sidebar-close:hover { background: var(--gray-100); }

.filter-section {
  margin-bottom: 20px;
}
.filter-section h3 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--gray-400);
  margin-bottom: 8px;
}
.filter-section label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  cursor: pointer;
  font-size: 13px;
  color: var(--gray-700);
  border-radius: var(--radius-sm);
  transition: color var(--transition);
}
.filter-section label:hover { color: var(--blue); }
.filter-section input[type="checkbox"] {
  accent-color: var(--blue);
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.text-input, .select-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--gray-700);
  outline: none;
  transition: border-color var(--transition);
}
.text-input:focus, .select-input:focus { border-color: var(--blue); }

.slider {
  width: 100%;
  accent-color: var(--blue);
  margin: 4px 0;
}
.slider-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--gray-400);
  margin-top: 2px;
}

.btn-reset {
  width: 100%;
  padding: 8px;
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  color: var(--gray-500);
  transition: all var(--transition);
  margin-top: 4px;
}
.btn-reset:hover { background: var(--gray-200); color: var(--gray-700); }

/* ===== Main ===== */
.main-content {
  flex: 1;
  min-width: 0;
  padding: 16px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.btn-filter-toggle {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
}
.btn-filter-toggle:hover { background: var(--blue-dark); }

.result-count {
  font-size: 13px;
  color: var(--gray-500);
}
.result-count strong { color: var(--blue-dark); font-size: 15px; }

/* ===== Card Grid ===== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
.loading {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px;
  color: var(--gray-400);
}
.no-result {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px;
  color: var(--gray-400);
  font-size: 15px;
}

/* ===== Property Card ===== */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform var(--transition), box-shadow var(--transition);
  border: 1px solid var(--gray-100);
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
}

.card-img {
  background: linear-gradient(135deg, var(--blue-light) 0%, #e0e7ff 100%);
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--blue);
  font-size: 13px;
  font-weight: 600;
  position: relative;
  overflow: hidden;
}
.card-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.card-rank {
  position: absolute;
  top: 10px;
  left: 10px;
  background: var(--blue);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}
.card-type-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255,255,255,.85);
  color: var(--gray-700);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}

.card-body {
  padding: 14px 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-address {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 2px;
}

.card-price-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.card-price {
  font-size: 20px;
  font-weight: 800;
  color: var(--gray-900);
}
.card-price-unit { font-size: 13px; color: var(--gray-500); }
.card-price-land-note {
  font-size: 11px;
  color: var(--amber);
  background: var(--amber-light);
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1.4;
  margin-top: 4px;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
  color: var(--gray-600);
}
.meta-chip {
  background: var(--gray-100);
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.card-station {
  font-size: 13px;
  color: var(--gray-700);
}
.card-station .station-name { font-weight: 600; }
.card-station .station-walk { color: var(--gray-500); }
.card-station .tokyo-time {
  font-size: 11px;
  color: var(--gray-400);
  margin-left: 6px;
}

/* Score */
.card-score-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.score-circle {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: help;
}
.score-circle.high { background: var(--blue-dark); }
.score-circle.mid { background: var(--blue); }
.score-circle.low { background: var(--gray-300); color: var(--gray-700); }
.score-num { font-size: 17px; font-weight: 800; line-height: 1; }
.score-label { font-size: 9px; opacity: .8; }

.residual-block { flex: 1; }
.residual-label { font-size: 11px; color: var(--gray-400); }
.residual-value { font-size: 15px; font-weight: 700; }
.profit { color: var(--green); }
.loss { color: var(--red); }
.profit-chip {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
}
.profit-chip.profit { background: var(--green-light); color: var(--green); }
.profit-chip.loss { background: var(--red-light); color: var(--red); }

/* Negative flags */
.negative-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.neg-badge {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--red-light);
  color: var(--red);
  font-weight: 600;
}

/* Actions */
.card-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-top: 1px solid var(--gray-100);
  background: var(--gray-50);
}
.action-btn {
  flex: 1;
  min-width: 70px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.action-btn.primary {
  background: var(--blue);
  color: #fff;
}
.action-btn.primary:hover { background: var(--blue-dark); }
.action-btn.secondary {
  background: #fff;
  color: var(--gray-700);
  border: 1px solid var(--gray-200);
}
.action-btn.secondary:hover { background: var(--gray-100); }

/* Tooltip for score breakdown */
[data-tooltip] { position: relative; }

/* Desktop hover tooltip (non-touch) */
@media (hover: hover) {
  [data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--gray-900);
    color: #fff;
    font-size: 11px;
    padding: 6px 10px;
    border-radius: 6px;
    white-space: pre;
    z-index: 100;
    pointer-events: none;
    min-width: 160px;
    line-height: 1.5;
  }
  [data-tooltip]:hover::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 1px);
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--gray-900);
    z-index: 100;
  }
}

/* JS-driven floating tooltip (mobile tap) */
#score-tooltip {
  display: none;
  position: fixed;
  background: var(--gray-900);
  color: #fff;
  font-size: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  white-space: pre;
  z-index: 9999;
  pointer-events: none;
  line-height: 1.6;
  max-width: calc(100vw - 24px);
  box-shadow: 0 4px 16px rgba(0,0,0,.3);
}
#score-tooltip.visible { display: block; }

/* ===== Overlay (mobile) ===== */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 40;
}
.overlay.active { display: block; }

/* ===== Footer ===== */
.site-footer {
  background: var(--gray-100);
  border-top: 1px solid var(--gray-200);
  margin-top: 40px;
  padding: 20px 16px;
  font-size: 12px;
  color: var(--gray-500);
  text-align: center;
}
.footer-inner { max-width: 1280px; margin: 0 auto; }
.footer-inner p { margin: 4px 0; }
.disclaimer { color: var(--amber); font-weight: 600; margin-top: 8px !important; }

/* ===== 3シナリオ表示 ===== */
.scenario-row {
  display: flex;
  align-items: center;
  gap: 0.4em;
}
.scenario-neutral {
  font-size: 1em;
  font-weight: bold;
}
.scenario-sub {
  margin-top: 0.4em;
  display: flex;
  flex-direction: column;
  gap: 0.15em;
  font-size: 0.83em;
  color: #6b7280;
}
.scenario-tag {
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.72em;
  font-weight: 600;
  white-space: nowrap;
  background: var(--blue-light);
  color: var(--blue-dark);
}
.scenario-tag.opt { background: #d1fae5; color: #065f46; }
.scenario-tag.pes { background: #fee2e2; color: #991b1b; }

/* 解説内シナリオテーブル */
.exp-area-label {
  font-size: 0.88em;
  margin-bottom: 4px;
  margin-top: 6px;
}
.exp-scenario-table {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.85em;
  padding-left: 4px;
}
.exp-scenario-row {
  display: flex;
  align-items: center;
  gap: 0.4em;
  color: #6b7280;
}
.exp-scenario-neutral {
  font-weight: 600;
  color: #1f2937;
}
.exp-scenario-summary {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed #d1d5db;
  font-size: 0.88em;
  line-height: 1.6;
}

/* ===== Residual Explanation (10年後予測の根拠) ===== */
.residual-explanation {
  margin-top: 0.8em;
  padding: 0;
  background: #f8f9fa;
  border-left: 3px solid #4a90e2;
  border-radius: 4px;
  font-size: 0.85em;
  line-height: 1.6;
  color: #555;
}
.residual-explanation summary {
  cursor: pointer;
  font-weight: 500;
  color: #4a90e2;
  padding: 0.5em 0.8em;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 4px;
}
.residual-explanation summary::-webkit-details-marker { display: none; }
.residual-explanation summary::before {
  content: '▶';
  font-size: 9px;
  transition: transform 0.2s ease;
}
.residual-explanation[open] summary::before { transform: rotate(90deg); }
.residual-explanation summary:hover {
  color: #2563eb;
}
.residual-explanation strong {
  color: #1f2937;
}
.residual-explanation .explanation-body {
  padding: 0.2em 0.8em 0.7em;
  border-top: 1px solid #e2e8f0;
}
.trend-up { color: #16a34a; font-weight: bold; }
.trend-down { color: #dc2626; font-weight: bold; }
.residual-explanation .exp-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 4px 0;
}
.residual-explanation .exp-row span {
  font-size: 0.92em;
}
.residual-explanation .exp-summary {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed #d1d5db;
  font-size: 0.92em;
}

/* ===== Tab Bar ===== */
.tab-bar {
  display: flex;
  gap: 4px;
  padding: 12px 16px 0;
  background: #fff;
  border-bottom: 2px solid var(--gray-200);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-bottom: 3px solid transparent;
  background: none;
  color: var(--gray-500);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
  white-space: nowrap;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.tab-btn:hover {
  color: var(--blue);
  background: var(--blue-light);
}

.tab-btn.active {
  color: var(--blue-dark);
  border-bottom-color: var(--blue);
  background: var(--blue-light);
  font-weight: 700;
}

.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 18px;
  padding: 0 5px;
  background: var(--gray-200);
  color: var(--gray-700);
  border-radius: 9px;
  font-size: 11px;
  font-weight: 600;
}

.tab-btn.active .tab-count {
  background: var(--blue);
  color: #fff;
}

/* ===== タブ区切り ===== */
.tab-divider {
  display: inline-block;
  width: 1px;
  height: 24px;
  background: var(--gray-300);
  margin: 0 8px;
  align-self: center;
  flex-shrink: 0;
}

/* ===== カテゴリ横断タブ ===== */
.tab-cross {
  background: #fef3f2;
  color: var(--gray-500);
}

.tab-cross:hover {
  background: #fee2e2;
  color: #c2410c;
}

.tab-cross.active {
  color: #c2410c;
  border-bottom-color: #ef4444;
  background: #fee2e2;
  font-weight: 700;
}

.tab-cross.active .tab-count {
  background: #ef4444;
  color: #fff;
}

.tab-cross .tab-count {
  background: #fecaca;
  color: #c2410c;
}

/* ===== カードタイプバッジ色分け ===== */
.card-type-badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 4px; }
.badge-kodate  { background: #d1fae5; color: #065f46; }
.badge-mansion { background: #dbeafe; color: #1d4ed8; }
.badge-land    { background: #fef3c7; color: #92400e; }

/* 旧耐震バッジ（カード右上） */
.seismic-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  z-index: 2;
}

/* ===== マンション固有バッジ ===== */
.mansion-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 4px 0 6px;
}

.mansion-badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid transparent;
}

.mansion-badge.seismic-new    { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.mansion-badge.seismic-old    { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }
.mansion-badge.brand-mansion  { background: #fdf4ff; color: #7e22ce; border-color: #d8b4fe; }
.mansion-badge.new2000        { background: #eff6ff; color: #1d4ed8; border-color: #93c5fd; }
.mansion-badge.reserve-ok     { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.mansion-badge.reserve-warn   { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.mansion-badge.reserve-ng     { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }
.mansion-badge.reserve-unknown { background: var(--gray-100); color: var(--gray-500); border-color: var(--gray-300); }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .header-title-row {
    flex-direction: column;
    gap: 8px;
  }
  .sidebar {
    position: fixed;
    left: -100%;
    top: 0;
    height: 100%;
    width: min(var(--sidebar-w), 85vw);
    z-index: 50;
    transition: left var(--transition);
    border-right: none;
    box-shadow: 4px 0 20px rgba(0,0,0,.15);
  }
  .sidebar.open {
    left: 0;
  }
  .sidebar-close { display: block; }
  .btn-filter-toggle { display: flex; }
  .main-content { padding: 12px; }
  .card-grid { grid-template-columns: 1fr; }
  .guide-table { font-size: 11px; }
  .tab-bar { padding: 8px 8px 0; gap: 2px; }
  .tab-btn { padding: 6px 10px; font-size: 13px; }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
}

/* ===== ヘッダー: タイトル行 ===== */
.header-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

/* ===== 駐車場バッジ ===== */
.parking-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  margin-top: 4px;
}
.parking-ok {
  background: var(--green-light);
  color: var(--green);
}
.parking-ng {
  background: var(--red-light);
  color: var(--red);
}
.parking-unknown {
  background: var(--gray-100);
  color: var(--gray-500);
}

/* ===== 設定ボタン (ヘッダー) ===== */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-top: 4px;
}

.settings-btn {
  background: var(--gray-100);
  border: 1.5px solid var(--gray-200);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), border-color var(--transition);
  flex-shrink: 0;
  padding: 0;
}
.settings-btn:hover {
  background: var(--blue-light);
  border-color: var(--blue);
}

/* ===== ヘッダー評価サマリー ===== */
.header-rating-summary {
  font-size: 12px;
  color: var(--gray-500);
  padding: 4px 0 8px;
}

/* ===== 星評価エリア (カード下部) ===== */
.card-star-area {
  padding: 8px 12px 10px;
  border-top: 1px solid var(--gray-100);
  background: var(--gray-50);
  border-radius: 0 0 var(--radius) var(--radius);
}

.star-rating-block {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.star-my-label {
  font-size: 11px;
  color: var(--gray-500);
  font-weight: 600;
  margin-right: 2px;
}

.star-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 20px;
  padding: 2px;
  line-height: 1;
  transition: transform 0.1s ease;
}
.star-btn:hover {
  transform: scale(1.25);
}
.star-empty {
  color: var(--gray-300);
}
.star-filled {
  color: #f59e0b;
}

.star-summary {
  font-size: 11px;
  color: var(--gray-500);
  background: var(--gray-100);
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
  margin-left: 4px;
}

/* ===== 名前モーダル / 設定モーダル 共通 ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal-box {
  background: #fff;
  border-radius: var(--radius);
  padding: 28px 24px 24px;
  max-width: 360px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 10px;
}

.modal-desc {
  font-size: 13px;
  color: var(--gray-500);
  margin-bottom: 16px;
  line-height: 1.5;
}

.modal-preset-btns {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.preset-btn {
  flex: 1;
  padding: 10px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  background: var(--gray-50);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.preset-btn:hover {
  border-color: var(--blue);
  background: var(--blue-light);
  color: var(--blue-dark);
}

.modal-or {
  font-size: 12px;
  color: var(--gray-400);
  margin-bottom: 6px;
}

.modal-name-input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 15px;
  outline: none;
  transition: border-color var(--transition);
  margin-bottom: 14px;
}
.modal-name-input:focus {
  border-color: var(--blue);
}

.modal-submit-btn {
  width: 100%;
  padding: 12px;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transition);
}
.modal-submit-btn:hover {
  background: var(--blue-dark);
}

.modal-close-btn {
  width: 100%;
  padding: 10px;
  background: var(--gray-100);
  color: var(--gray-700);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 12px;
  transition: background var(--transition);
}
.modal-close-btn:hover {
  background: var(--gray-200);
}

/* ===== 設定モーダル固有 ===== */
.settings-section {
  margin-bottom: 4px;
}

.settings-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--gray-700);
  margin-bottom: 10px;
  display: block;
}

.btn-danger {
  width: 100%;
  padding: 10px;
  background: var(--red-light);
  color: var(--red);
  border: 1.5px solid #fca5a5;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
}
.btn-danger:hover {
  background: var(--red);
  color: #fff;
}

/* ===== Pagination ===== */
.pagination-container {
  width: 100%;
  margin: 12px 0;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 0;
}

.pg-btn {
  padding: 6px 14px;
  background: #fff;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  color: var(--blue-dark);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  min-width: 60px;
}

.pg-btn:hover:not(:disabled) {
  background: var(--blue-light);
  border-color: var(--blue);
}

.pg-btn:disabled {
  color: var(--gray-400);
  border-color: var(--gray-200);
  cursor: not-allowed;
  background: var(--gray-50);
}

.pg-info {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  white-space: nowrap;
  padding: 0 4px;
}

.pg-jump {
  padding: 5px 8px;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--gray-700);
  background: #fff;
  cursor: pointer;
}

.pg-jump:focus {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
}

.page-range {
  font-size: 12px;
  color: var(--gray-500);
}

@media (max-width: 480px) {
  .pagination {
    gap: 6px;
  }
  .pg-btn {
    padding: 5px 10px;
    font-size: 13px;
    min-width: 50px;
  }
  .pg-jump {
    font-size: 12px;
  }
}

/* ========================================================== */
/* ===== Defensive UI: 守りの投資指向 リデザイン (2026-05-10) ===== */
/* ========================================================== */

/* カード本体: 余白を増やし、すっきり */
.card-body {
  padding: 16px 16px 14px;
  gap: 12px;
}

/* タイトル+価格セクション */
.card-head {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card-price-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 2px;
}

/* 円形スコアバッジ (画像右下) */
.card-score-circle {
  position: absolute;
  bottom: 10px;
  right: 10px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4A90E2, #2962FF);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  font-weight: 700;
  font-size: 20px;
  line-height: 1;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  border: 2px solid rgba(255,255,255,0.85);
  z-index: 2;
  letter-spacing: 0;
}
.card-score-circle small {
  font-size: 9px;
  font-weight: 500;
  opacity: 0.9;
  margin-top: 2px;
}
/* スコアグレード別カラー */
.card-score-circle.score-grade-s { background: linear-gradient(135deg, #00C853, #00897B); }
.card-score-circle.score-grade-a { background: linear-gradient(135deg, #4A90E2, #2962FF); }
.card-score-circle.score-grade-b { background: linear-gradient(135deg, #FFB74D, #F57C00); }
.card-score-circle.score-grade-c { background: linear-gradient(135deg, #FF7043, #D84315); }
.card-score-circle.score-grade-d { background: linear-gradient(135deg, #9E9E9E, #616161); }

.meta-chip.meta-new {
  background: #dbeafe;
  color: #1d4ed8;
  font-weight: 700;
}

/* リスクバッジ行 */
.risk-badges-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 4px 0 0;
}
.risk-badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid transparent;
  letter-spacing: 0.01em;
}
.risk-badge.risk-strong {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fca5a5;
}
.risk-badge.risk-mild {
  background: #fef3c7;
  color: #92400e;
  border-color: #fcd34d;
}

.badge-line { display: flex; flex-wrap: wrap; gap: 4px; }

.decision-box {
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 8px 10px;
  background: #f8fafc;
  display: grid;
  gap: 6px;
}
.decision-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.decision-label,
.pm-decision-badge {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 4px;
}
.decision-buy_now .decision-label,
.pm-decision-badge.decision-buy_now { background: #dcfce7; color: #166534; }
.decision-watch .decision-label,
.pm-decision-badge.decision-watch { background: #dbeafe; color: #1e40af; }
.decision-wait_for_discount .decision-label,
.pm-decision-badge.decision-wait_for_discount { background: #fef3c7; color: #92400e; }
.decision-avoid .decision-label,
.pm-decision-badge.decision-avoid { background: #fee2e2; color: #991b1b; }
.decision-reason {
  min-width: 0;
  color: var(--gray-700);
  font-size: 12px;
  line-height: 1.35;
}
.decision-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
}
.decision-metrics span {
  background: #ffffff;
  border: 1px solid var(--gray-200);
  border-radius: 4px;
  color: var(--gray-700);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 4px;
  text-align: center;
}
.decision-target {
  color: var(--gray-600);
  font-size: 11px;
  font-weight: 700;
}

/* ヒーロー指標ブロック (悲観時純コスト + 残価率バー) */
.hero-block {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: stretch;
  padding: 12px;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  margin-top: 4px;
}

.hero-net {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}
.hero-net-label {
  font-size: 11px;
  color: var(--gray-700);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.hero-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  font-size: 10px;
  color: var(--gray-500);
  background: var(--gray-100);
  border-radius: 50%;
  cursor: help;
  font-weight: 600;
  border: 1px solid var(--gray-200);
}
.hero-help:hover {
  color: var(--blue-dark, #1e40af);
  background: var(--gray-200);
}
.hero-net-value {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.hero-net-value.net-good { color: var(--green); }
.hero-net-value.net-bad  { color: var(--red); }
.hero-net-value.net-na   { color: var(--gray-400); }
.hero-net-sub-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-500);
  margin-top: 4px;
  line-height: 1.3;
}
.hero-sub-pes { color: #b91c1c; }
.hero-sub-opt { color: #047857; }
.hero-sub-sep { color: var(--gray-300); }
.hero-net-sub {
  font-size: 10px;
  font-weight: 600;
  color: var(--gray-500);
  margin-top: 2px;
}

/* 残価率バー */
.residual-bar-wrap {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
}
.residual-bar-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 10px;
  font-weight: 600;
}
.residual-bar-label {
  color: var(--gray-500);
}
.residual-bar-pct {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.bar-high-text { color: var(--green); }
.bar-mid-text  { color: var(--amber); }
.bar-low-text  { color: var(--red); }

.bar-bg {
  position: relative;
  width: 100%;
  height: 10px;
  background: var(--gray-200);
  border-radius: 5px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.4s ease;
}
.bar-fill.bar-high { background: linear-gradient(90deg, #22c55e 0%, #16a34a 100%); }
.bar-fill.bar-mid  { background: linear-gradient(90deg, #f59e0b 0%, #d97706 100%); }
.bar-fill.bar-low  { background: linear-gradient(90deg, #ef4444 0%, #dc2626 100%); }
.bar-tick {
  position: absolute;
  top: 0;
  width: 1px;
  height: 100%;
  background: rgba(255,255,255,0.6);
}

/* 3シナリオ行 (悲観/中立/楽観) */
.scenarios-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  padding: 8px 12px;
  background: var(--gray-50);
  border-radius: 8px;
  border: 1px solid var(--gray-100);
}
.scen-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  text-align: center;
}
.scen-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  align-self: center;
  letter-spacing: 0.03em;
}
.scen-tag-pes {
  background: #fee2e2;
  color: #991b1b;
}
.scen-tag-neu {
  background: var(--gray-800, #1f2937);
  color: #fff;
}
.scen-tag-opt {
  background: #ecfdf5;
  color: #047857;
}
.scen-val {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
/* 中立メイン: 大きめ・黒太字 */
.scen-neu .scen-val {
  font-size: 15px;
  font-weight: 800;
  color: var(--gray-900);
}
/* 楽観: 中サイズ・緑系 */
.scen-opt .scen-val {
  font-size: 13px;
  font-weight: 700;
  color: #047857;
}
/* 悲観: 中サイズ・赤系 */
.scen-pes .scen-val {
  font-size: 13px;
  font-weight: 700;
  color: #b91c1c;
}

/* good/bad（資産形成型/消費型）色は中立で支配的に表示 */
.scen-neu .scen-val.net-good { color: var(--green); }
.scen-neu .scen-val.net-bad  { color: var(--red); }

/* 詳細トグル */
.card-details {
  border-top: 1px dashed var(--gray-200);
  margin-top: 4px;
  padding-top: 8px;
}
.card-details-summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-700);
  user-select: none;
  transition: background var(--transition);
}
.card-details-summary::-webkit-details-marker { display: none; }
.card-details-summary:hover {
  background: var(--gray-100);
}
.card-details-summary-icon {
  font-size: 10px;
  transition: transform var(--transition);
}
.card-details[open] .card-details-summary-icon {
  transform: rotate(180deg);
}
.card-details[open] .card-details-summary {
  background: var(--blue-light);
  border-color: var(--blue);
  color: var(--blue-dark);
}

.card-details-body {
  margin-top: 8px;
  padding: 10px;
  background: #fafbfc;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
}

/* 詳細タブ */
.detail-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--gray-200);
}
.detail-tab-btn {
  background: none;
  border: none;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition);
  white-space: nowrap;
}
.detail-tab-btn:hover {
  color: var(--blue);
}
.detail-tab-btn.active {
  color: var(--blue-dark);
  border-bottom-color: var(--blue);
}

.detail-tab-pane {
  display: none;
}
.detail-tab-pane.active {
  display: block;
}

/* T1: 守備力分析 */
.defense-block {
  font-size: 12px;
  line-height: 1.6;
  color: var(--gray-700);
}
.defense-headline {
  font-size: 12px;
  color: var(--gray-700);
  margin-bottom: 6px;
}
.defense-numbers {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 8px;
}
.defense-num-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  font-size: 12px;
}
.defense-num-row + .defense-num-row {
  border-top: 1px dashed var(--gray-100);
}
.defense-num-label {
  color: var(--gray-500);
}
.defense-num-val {
  font-weight: 700;
  color: var(--gray-900);
}
.defense-num-val.profit { color: var(--green); }
.defense-num-val.loss { color: var(--red); }

.defense-note {
  font-size: 12px;
  font-style: italic;
  color: var(--gray-700);
  padding: 6px 10px;
  background: #fffbeb;
  border-left: 3px solid var(--amber);
  border-radius: 4px;
  margin-bottom: 8px;
}

.defense-supports {
  list-style: none;
  margin: 0;
  padding: 0;
}
.defense-supports li {
  padding: 3px 0;
  font-size: 12px;
  color: var(--green);
  font-weight: 600;
}
.defense-empty-note {
  font-size: 12px;
  color: var(--gray-500);
  font-style: italic;
}

.defense-params {
  margin-top: 10px;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
}
.defense-param-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-500);
  margin-bottom: 4px;
}
.defense-param-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
}
.defense-param-table th,
.defense-param-table td {
  padding: 3px 6px;
  text-align: left;
  border-bottom: 1px dashed var(--gray-100);
}
.defense-param-table th {
  color: var(--gray-500);
  font-weight: 500;
  width: 45%;
}
.defense-param-table td {
  color: var(--gray-900);
  font-weight: 600;
}

/* T2: 3シナリオ詳細 */
.scenarios-detail .scen-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
  background: #fff;
  border-radius: 6px;
  overflow: hidden;
}
.scen-table th,
.scen-table td {
  padding: 5px 6px;
  border-bottom: 1px solid var(--gray-100);
  text-align: right;
}
.scen-table thead th {
  background: var(--gray-100);
  font-weight: 700;
  font-size: 11px;
  text-align: center;
}
.scen-table thead .scen-th-pes {
  background: #fee2e2;
  color: #991b1b;
}
.scen-table thead .scen-th-neu {
  background: var(--gray-200);
  color: var(--gray-700);
}
.scen-table thead .scen-th-opt {
  background: #ecfdf5;
  color: #047857;
  opacity: 0.85;
}
.scen-table tbody th {
  text-align: left;
  color: var(--gray-500);
  font-weight: 500;
  background: var(--gray-50);
}
.scen-table .profit { color: var(--green); font-weight: 700; }
.scen-table .loss { color: var(--red); font-weight: 700; }
.scen-formula {
  margin-top: 8px;
  padding: 6px 10px;
  background: #fff;
  border: 1px dashed var(--gray-200);
  border-radius: 4px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--gray-700);
}
.scen-formula-note {
  color: var(--gray-500);
  font-size: 10.5px;
}

/* T3: スコア内訳 */
.score-detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.score-detail-table th,
.score-detail-table td {
  padding: 4px 6px;
  border-bottom: 1px dashed var(--gray-100);
  text-align: left;
}
.score-detail-table th {
  color: var(--gray-500);
  font-weight: 500;
  width: 50%;
}
.score-detail-table .score-val {
  color: var(--gray-900);
  font-weight: 700;
  text-align: right;
  width: 30%;
}
.score-detail-table .score-max {
  color: var(--gray-400);
  text-align: right;
  width: 20%;
}
.score-detail-total {
  margin-top: 8px;
  padding: 6px 10px;
  background: var(--blue-light);
  border-radius: 4px;
  font-size: 13px;
  text-align: center;
  color: var(--blue-dark);
  font-weight: 600;
}
.score-detail-total strong {
  font-size: 17px;
  color: var(--blue-dark);
}

/* モバイル調整 */
@media (max-width: 480px) {
  .hero-block {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .hero-net-value {
    font-size: 26px;
  }
  .scenarios-row {
    padding: 6px 8px;
  }
  .scen-val { font-size: 12px; }
  .scen-neu .scen-val { font-size: 14px; }
  .detail-tab-btn {
    padding: 5px 7px;
    font-size: 11px;
  }
}

/* =====================================================================
   コスパ★ (カード上)
   ===================================================================== */
.cospa-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
  padding: 6px 10px;
  background: #fff8e1;
  border: 1px solid #fde68a;
  border-radius: 6px;
  font-size: 13px;
}
.cospa-label {
  font-size: 11px;
  color: var(--gray-500);
  font-weight: 600;
}
.cospa-stars {
  font-size: 16px;
  letter-spacing: 1px;
  color: #f59e0b;
  font-weight: bold;
}
.cospa-stars-empty {
  color: var(--gray-300);
}
.cospa-stars.cospa-good { color: #22c55e; }
.cospa-stars.cospa-mid  { color: #f59e0b; }
.cospa-stars.cospa-bad  { color: #ef4444; }
.cospa-stars.cospa-na   { color: var(--gray-300); }
.cospa-meta {
  font-size: 12px;
  margin-left: auto;
  color: var(--gray-700);
  font-weight: 600;
}
.cospa-meta.cospa-good { color: #16a34a; }
.cospa-meta.cospa-mid  { color: #ca8a04; }
.cospa-meta.cospa-bad  { color: #dc2626; }

/* =====================================================================
   詳細モーダル open ボタン
   ===================================================================== */
.card-detail-open-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 8px;
  padding: 10px 14px;
  background: var(--blue-light, #eff6ff);
  border: 1.5px solid var(--blue, #3b82f6);
  border-radius: 8px;
  color: var(--blue-dark, #1e40af);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}
.card-detail-open-btn:hover {
  background: var(--blue, #3b82f6);
  color: #fff;
}
.card-detail-open-btn:active {
  transform: translateY(1px);
}
.card-detail-icon {
  font-size: 15px;
}

/* =====================================================================
   物件詳細モーダル
   ===================================================================== */
.property-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
}
.property-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
}
.property-modal-box {
  position: relative;
  background: #fff;
  border-radius: 12px;
  max-width: 720px;
  width: calc(100% - 32px);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  z-index: 1;
}
.property-modal-close {
  position: sticky;
  top: 8px;
  /* float を使うと sticky と組み合わせた際にブラウザ間で配置が不安定になり、
     ヘッダー要素と重なってクリックできなくなる。通常フローの右寄せブロックに変更。 */
  display: flex;
  margin: 8px 8px 0 auto;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  z-index: 5;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.property-modal-close:hover {
  background: rgba(0, 0, 0, 0.8);
}
.property-modal-content {
  padding: 16px 20px 24px;
}

body.pm-open {
  overflow: hidden;
}

/* モーダル ヘッダー */
.pm-header {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--gray-200);
}
.pm-header-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.pm-thumb {
  width: 100px;
  height: 75px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
}
.pm-header-text {
  flex: 1;
  min-width: 0;
}
.pm-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-900);
  margin: 0 0 6px 0;
  line-height: 1.3;
}
.pm-rank-score {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 12px;
  margin-bottom: 4px;
}
.pm-rank {
  background: var(--gray-100);
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  color: var(--gray-700);
}
.pm-score strong {
  font-size: 15px;
  color: var(--blue-dark);
}
.pm-address {
  font-size: 12px;
  color: var(--gray-600);
}
.pm-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.pm-action {
  flex: 1;
  padding: 8px 12px;
  background: var(--blue);
  color: #fff;
  text-decoration: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}
.pm-action:hover { background: var(--blue-dark); }
.pm-action-secondary {
  background: var(--gray-200);
  color: var(--gray-700);
}
.pm-action-secondary:hover { background: var(--gray-300); color: var(--gray-900); }

/* モーダル セクション */
.pm-section {
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px dashed var(--gray-200);
}
.pm-section:last-child {
  border-bottom: none;
  padding-bottom: 0;
}
.pm-h3 {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--gray-900);
  margin: 0 0 8px 0;
  padding: 6px 10px;
  background: var(--gray-50);
  border-left: 3px solid var(--blue);
  border-radius: 0 4px 4px 0;
}
.pm-h3-neg {
  border-left-color: var(--red, #ef4444);
  background: #fef2f2;
}
.pm-h4 {
  font-size: 12px;
  font-weight: 700;
  color: var(--gray-700);
  margin: 10px 0 4px;
}

.pm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.pm-table th,
.pm-table td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--gray-100);
  text-align: left;
  vertical-align: top;
}
.pm-table th {
  font-weight: 500;
  color: var(--gray-600);
  width: 45%;
}
.pm-table td {
  color: var(--gray-900);
  font-weight: 600;
}
.pm-table td.profit { color: var(--green, #16a34a); }
.pm-table td.loss { color: var(--red, #dc2626); }

.pm-pl-table th { width: 30%; }
.pm-pl-table td { text-align: right; font-size: 14px; font-weight: 700; }

.pm-note {
  font-size: 11.5px;
  color: var(--gray-500);
  line-height: 1.5;
  margin: 6px 0 0;
}
.pm-note-inline {
  font-size: 11px;
  color: var(--gray-500);
  font-weight: 400;
  margin-left: 6px;
}
.pm-area-label {
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--gray-700);
}

/* 判定バッジ */
.pm-verdict-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.pm-verdict-good { background: #dcfce7; color: #166534; }
.pm-verdict-mid  { background: var(--gray-200); color: var(--gray-700); }
.pm-verdict-bad  { background: #fee2e2; color: #991b1b; }

/* 新5段階バッジ (§4 予測価格 vs 販売価格 用 / 分布ベース) */
.pm-verdict-high     { background: #fee2e2; color: #991b1b; }   /* 割高 (上位10%) */
.pm-verdict-mid-high { background: #ffedd5; color: #9a3412; }   /* やや割高 (上位10-25%) */
.pm-verdict-mid-low  { background: #dcfce7; color: #166534; }   /* やや割安 (下位10-25%) */
.pm-verdict-low      { background: #bbf7d0; color: #14532d; }   /* 割安 (下位10%) */
.pm-verdict-sub {
  font-size: 11px;
  color: var(--gray-600);
  margin-left: 6px;
}

/* §4 予測価格 vs 販売価格 - 予測価格行を強調 */
.pm-pred-table .pm-pred-total {
  border-top: 1px solid var(--gray-300);
  background: rgba(0, 0, 0, 0.02);
}
.pm-pred-table .pm-pred-total th,
.pm-pred-table .pm-pred-total td {
  font-size: 13px;
}

/* 土地基本価値 採用ソースバッジ (市場価格/公示価格×1.10/路線価×1.30/データなし) */
.pm-source-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.pm-source-market   { background: #dcfce7; color: #166534; }  /* 緑: 市場価格 (最も信頼性高い) */
.pm-source-official { background: #dbeafe; color: #1e3a8a; }  /* 青: 公示価格×1.10 (標準) */
.pm-source-route    { background: var(--gray-200); color: var(--gray-700); }  /* グレー: 路線価×1.30 (推定値) */
.pm-source-none     { background: #fee2e2; color: #991b1b; }  /* 赤: データなし (要注意) */

/* 計算式の補足注釈 (採用ソース × 単価 × 面積 = 価値) */
.pm-formula-note {
  font-size: 11px;
  color: var(--gray-600);
  margin-top: 3px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

/* 3シナリオ表 */
.pm-scen-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.pm-scen-table th,
.pm-scen-table td {
  padding: 6px 8px;
  text-align: right;
  border-bottom: 1px solid var(--gray-100);
}
.pm-scen-table thead th {
  text-align: center;
  font-weight: 700;
  font-size: 11.5px;
}
.pm-scen-table thead th.pes { background: #fee2e2; color: #991b1b; }
.pm-scen-table thead th.neu { background: var(--gray-200); color: var(--gray-700); }
.pm-scen-table thead th.opt { background: #dcfce7; color: #166534; }
.pm-scen-table tbody th {
  text-align: left;
  color: var(--gray-500);
  font-weight: 500;
  width: 35%;
  background: var(--gray-50);
}

/* 含み損益 実質コスト */
.pm-net-living {
  margin-top: 12px;
  padding: 10px 12px;
  background: #fafbfc;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
}
.pm-net-living-title {
  font-size: 11.5px;
  color: var(--gray-600);
  margin-bottom: 8px;
  font-weight: 600;
}

/* 価値を支える/下げる要素 */
.pm-section-factors .pm-h3 + .pm-factor-table,
.pm-section-factors .pm-h3 + .pm-empty {
  margin-bottom: 14px;
}
.pm-factor-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.pm-factor-table td {
  padding: 6px 8px;
  border-bottom: 1px dashed var(--gray-100);
  vertical-align: top;
}
.pm-factor-label {
  width: 45%;
  color: var(--gray-900);
  font-weight: 600;
}
.pm-factor-mult {
  width: 18%;
  text-align: right;
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.pm-factor-mult.pos { color: #16a34a; }
.pm-factor-mult.neg { color: #dc2626; }
.pm-factor-note {
  color: var(--gray-500);
  font-size: 11.5px;
  line-height: 1.4;
}
.pm-factor-strong {
  background: #fef2f2;
}
.pm-factor-mild {
  background: #fffbeb;
}
.pm-empty {
  font-size: 12px;
  color: var(--gray-500);
  font-style: italic;
  padding: 6px 0;
}

/* 折りたたみ */
.pm-details {
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  background: #fafbfc;
}
.pm-summary {
  cursor: pointer;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--gray-700);
  list-style: none;
  user-select: none;
}
.pm-summary::-webkit-details-marker { display: none; }
.pm-summary::before {
  content: '▶ ';
  font-size: 10px;
  margin-right: 4px;
  transition: transform 0.15s;
  display: inline-block;
}
.pm-details[open] .pm-summary::before {
  transform: rotate(90deg);
}
.pm-details-body {
  padding: 10px 14px 14px;
  border-top: 1px dashed var(--gray-200);
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--gray-700);
}
.pm-formula {
  background: #1f2937;
  color: #e5e7eb;
  padding: 8px 10px;
  border-radius: 4px;
  font-size: 11.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
  margin: 6px 0;
}
.pm-logic-table th { width: 60%; font-size: 12px; }
.pm-ref-list {
  margin: 4px 0 8px;
  padding-left: 20px;
  font-size: 12px;
  color: var(--gray-700);
}
.pm-ref-list code {
  background: var(--gray-100);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11.5px;
}

/* 物件特性フラグ */
.pm-flag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.pm-flag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
}
.pm-flag-icon { font-size: 13px; }
.pm-flag-strong { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.pm-flag-mild   { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.pm-flag-good   { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.pm-flag-unknown{ background: var(--gray-100); color: var(--gray-600); border-color: var(--gray-200); }
/* ハウスメーカー/ブランド検知バッジ (表示専用、価格・スコアに影響しない) */
.pm-flag-brand-premium { background: #7c3aed; color: #ffffff; border-color: #6d28d9; }
.pm-flag-brand-major   { background: #2563eb; color: #ffffff; border-color: #1d4ed8; }
.pm-flag-brand-middle  { background: #6b7280; color: #ffffff; border-color: #4b5563; }

/* モーダル モバイル */
@media (max-width: 480px) {
  .property-modal-box {
    width: calc(100% - 16px);
    max-height: calc(100vh - 16px);
  }
  .property-modal-content {
    padding: 12px 14px 18px;
  }
  .pm-h3 {
    font-size: 13px;
  }
  .pm-table th,
  .pm-table td {
    font-size: 11.5px;
    padding: 4px 6px;
  }
  .pm-thumb {
    width: 80px;
    height: 60px;
  }
  .pm-factor-table td {
    font-size: 11.5px;
    padding: 5px 4px;
  }
  .pm-factor-note {
    font-size: 10.5px;
  }
}

/* ===== カード用4種バッジ (一覧コンパクト版) =====
   詳細モーダル§10/§2/§4 と同じ色体系で小さく表示 */
.card-badge-row,
.card-flag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 6px 0 2px;
}
.card-flag-row {
  margin-top: 4px;
}
.card-flag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  border: 1px solid transparent;
  line-height: 1.4;
  white-space: nowrap;
}
.card-flag-icon {
  font-size: 11px;
  line-height: 1;
}
/* 物件特性 (§10 と同じトーン) */
.card-flag-flag-strong { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.card-flag-flag-mild   { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.card-flag-flag-good   { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.card-flag-flag-unknown{ background: var(--gray-100); color: var(--gray-600); border-color: var(--gray-200); }
/* ハウスメーカー/ブランド (§10 と同じ) */
.card-flag-brand-premium { background: #7c3aed; color: #fff; border-color: #6d28d9; }
.card-flag-brand-major   { background: #2563eb; color: #fff; border-color: #1d4ed8; }
.card-flag-brand-middle  { background: #6b7280; color: #fff; border-color: #4b5563; }
/* 採用ソースバッジ (§2 と同じトーンで小さく) */
.card-source-badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  line-height: 1.4;
  white-space: nowrap;
}
.card-source-badge.pm-source-market   { background: #dcfce7; color: #166534; }
.card-source-badge.pm-source-official { background: #dbeafe; color: #1e3a8a; }
.card-source-badge.pm-source-route    { background: var(--gray-200); color: var(--gray-700); }
.card-source-badge.pm-source-none     { background: #fee2e2; color: #991b1b; }
/* 予測判定バッジ (§4 と同じトーン) */
.card-verdict-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  line-height: 1.4;
  white-space: nowrap;
}
.card-verdict-badge.pm-verdict-high     { background: #fee2e2; color: #991b1b; }
.card-verdict-badge.pm-verdict-mid-high { background: #ffedd5; color: #9a3412; }
.card-verdict-badge.pm-verdict-mid      { background: var(--gray-200); color: var(--gray-700); }
.card-verdict-badge.pm-verdict-mid-low  { background: #dcfce7; color: #166534; }
.card-verdict-badge.pm-verdict-low      { background: #bbf7d0; color: #14532d; }
.card-verdict-sub {
  font-size: 10px;
  font-weight: 500;
  opacity: 0.85;
}
