/* Livability Score page */
.livability-page { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.livability-page h1 { margin-bottom: 0.5rem; }
.livability-page .lead { color: #555; margin-bottom: 2rem; }

.weights-panel {
  background: #f7f9fb;
  border: 1px solid #e1e6eb;
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 2rem;
}
.weights-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1rem;
}
.weights-header h2 { margin: 0; font-size: 1.15rem; }
.weights-actions { display: flex; align-items: center; gap: 1rem; }
.weights-total { font-size: 0.95rem; color: #333; }
.weights-total strong { color: #1a3d5c; }
.weights-total strong.warn { color: #c0392b; }

.weight-controls { display: grid; gap: 0.6rem; }
.weight-row {
  display: grid;
  grid-template-columns: 130px 1fr 65px;
  align-items: center;
  gap: 0.75rem;
}
.weight-value { 
  text-align: right; 
  font-variant-numeric: tabular-nums; 
  color: #1a3d5c; 
  font-weight: 600; 
  font-size: 0.85rem; 
}
.weight-row label { font-weight: 600; font-size: 0.9rem; color: #333; }
.weight-row input[type=range] { width: 100%; accent-color: #1a3d5c; }
.weight-value { text-align: right; font-variant-numeric: tabular-nums; color: #1a3d5c; font-weight: 600; font-size: 0.85rem; }

.weights-hint { font-size: 0.82rem; color: #777; margin: 0.9rem 0 0; }

.results-panel { margin-bottom: 2rem; }
.results-header {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1rem;
}
.results-header h2 { margin: 0; font-size: 1.2rem; }
.results-header select {
  padding: 0.35rem 0.5rem; border: 1px solid #ccc; border-radius: 4px;
  font-size: 0.9rem; background: #fff;
}
.results-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.results-controls label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
}

.results-table-wrap { overflow-x: auto; }

.livability-table {
  width: 100%; border-collapse: collapse; font-size: 0.9rem;
}
.livability-table thead th {
  text-align: left; padding: 0.65rem 0.5rem;
  border-bottom: 2px solid #1a3d5c; background: #f2f5f8;
  font-weight: 700; color: #1a3d5c; white-space: nowrap;
}
.livability-table .axis-head { font-size: 0.78rem; color: #555; font-weight: 600; }
.livability-table tbody tr:nth-child(even) { background: #fafbfc; }
.livability-table tbody td {
  padding: 0.55rem 0.5rem; border-bottom: 1px solid #e8ecf0; vertical-align: middle;
}
.livability-table .rank { color: #888; width: 36px; }
.livability-table .state { color: #888; font-size: 0.82rem; }
.livability-table .composite {
  font-weight: 700; color: #1a3d5c; font-variant-numeric: tabular-nums;
  width: 70px; text-align: right;
}
.livability-table .axis-bars {
  display: flex; flex-direction: column; gap: 2px;
  min-width: 200px;
}
.bar-wrap {
  width: 100%; height: 6px; background: #eef1f4; border-radius: 3px; overflow: hidden;
}
.bar { height: 100%; border-radius: 3px; transition: width 0.25s ease; }
.bar-affordability { background: #2e86ab; }
.bar-stability    { background: #5a9e7c; }
.bar-momentum     { background: #d4a72c; }
.bar-safety       { background: #b8452c; }
.bar-health       { background: #8e5aa8; }
.bar-amenities    { background: #4a90d9; }

.loading, .error { color: #888; padding: 1rem; text-align: center; }
.error { color: #c0392b; }

.btn-secondary {
  padding: 0.35rem 0.8rem; border: 1px solid #ccc; background: #fff;
  border-radius: 4px; font-size: 0.85rem; cursor: pointer;
}
.btn-secondary:hover { background: #f0f4f8; border-color: #1a3d5c; }

.methodology-note {
  background: #f7f9fb; border-left: 4px solid #1a3d5c;
  padding: 1.25rem 1.5rem; border-radius: 6px;
}
.methodology-note h2 { font-size: 1.05rem; margin-top: 0; }
.methodology-note p { font-size: 0.9rem; color: #444; }
.methodology-note .attribution {
  font-size: 0.78rem; color: #777; margin: 0.75rem 0 0;
}

@media (max-width: 640px) {
  .weight-row { grid-template-columns: 100px 1fr 36px; gap: 0.5rem; }
  .livability-table .axis-bars { display: none; }
  .livability-table .axis-head { display: none; }
}
.axis-legend {
  display: flex; flex-wrap: wrap; gap: 1rem;
  margin-bottom: 1rem; font-size: 0.8rem; color: #555;
}
.axis-legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.axis-legend i { width: 12px; height: 12px; border-radius: 2px; display: inline-block; }
/* Top 10 카드 그리드 */
.livability-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.liv-card {
  position: relative;
  background: #fff;
  border: 1px solid #e1e6eb;
  border-left: 4px solid #2ecc71;   /* tier 색상으로 동적 변경 */
  border-radius: 8px;
  padding: 1rem 1.1rem;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.liv-card:hover {
  box-shadow: 0 4px 14px rgba(26, 61, 92, 0.12);
  transform: translateY(-2px);
}

.liv-card-rank {
  position: absolute;
  top: 0.7rem; right: 0.9rem;
  font-size: 0.85rem;
  color: #999;
  font-weight: 700;
}

.liv-card-name {
  font-size: 1rem;
  font-weight: 700;
  color: #1a3d5c;
  margin: 0 0 0.1rem;
  padding-right: 2.5rem; /* rank 자리 */
  line-height: 1.25;
}

.liv-card-state {
  font-size: 0.8rem;
  color: #888;
  margin-bottom: 0.6rem;
}

.liv-card-score-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.liv-card-score {
  font-size: 1.8rem;
  font-weight: 800;
  color: #1a3d5c;
  line-height: 1;
}

.liv-card-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-excellent  { background: #d4f5e0; color: #1e8449; }
.badge-strong     { background: #d6ecfa; color: #1f618d; }
.badge-balanced   { background: #fcf3d4; color: #9a7d0a; }
.badge-challenging{ background: #fde2d0; color: #a04000; }
.badge-stressed   { background: #f5d0d0; color: #922b21; }

/* 축별 미니 바 (카드 안) */
.liv-card-bars {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 0.4rem;
}
.liv-card-bar-row {
  display: grid;
  grid-template-columns: 78px 1fr 30px;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  color: #666;
}
.liv-card-bar-row .lbl { text-transform: capitalize; }
.liv-card-bar-row .val { text-align: right; font-variant-numeric: tabular-nums; }
.liv-card-bar-track {
  height: 5px; background: #eef1f4; border-radius: 3px; overflow: hidden;
}
.liv-card-bar-fill { height: 100%; border-radius: 3px; }

.is-hidden { display: none; }

.live-badge {
  display: inline-block;
  font-size: 0.62rem;
  background: #e74c3c;
  color: #fff;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  vertical-align: middle;
  margin-left: 0.35rem;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}
.data-note {
  font-size: 0.82rem;
  color: #666;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px dashed #ddd;
}
.preset.active { 
  background: #1a3d5c; 
  color: white; 
  border-color: #1a3d5c; 
}
/* 카드 클릭 링크 */
.liv-card-link {
  display: block;
  text-decoration: none;
  color: inherit;
  outline: none;
}
.liv-card-link:hover,
.liv-card-link:focus {
  text-decoration: none;
  color: inherit;
}
.liv-card-link .liv-card {
  cursor: pointer;
}
.liv-card-link:focus-visible .liv-card {
  outline: 2px solid #1a3d5c;
  outline-offset: 2px;
}

/* 테이블 행 클릭 */
.clickable-row {
  cursor: pointer;
}
.clickable-row:hover {
  background: #eef4f9 !important;
}
.clickable-row:hover td .composite {
  color: #0d2b45;
}