:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #111827;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

h1, h2, h3 { margin: 0; }
h1 { font-size: 20px; }
h2 { font-size: 15px; margin-bottom: 8px; }
h3 { font-size: 14px; margin-bottom: 8px; }

.top { padding: 16px 20px 8px; }
.sub { margin: 4px 0 0; color: var(--muted); }

.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
  padding: 8px 20px 16px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.hint { color: var(--muted); font-size: 12px; margin: 0 0 10px; }

.weight-row { margin-bottom: 12px; }
.weight-row .label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}
.weight-row .label .count { margin-left: auto; font-weight: 400; color: var(--muted); font-size: 12px; }
.weight-row .ctrl { display: flex; align-items: center; gap: 8px; }
.weight-row input[type=range] { flex: 1; }
.weight-row input[type=number] { width: 56px; padding: 2px 4px; border: 1px solid var(--line); border-radius: 6px; }

.swatch {
  width: 12px; height: 12px;
  border-radius: 50%;
  display: inline-block;
  flex: none;
}

.weight-total { font-size: 12px; color: var(--muted); margin-bottom: 10px; }

.presets { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 12px; font-size: 12px; color: var(--muted); }

button {
  font: inherit;
  font-size: 12px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
}
button:hover { background: #f3f4f6; }
button.primary {
  width: 100%;
  padding: 9px;
  font-size: 14px;
  font-weight: 700;
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
button.primary:hover { background: #374151; }

.dirty { color: #b45309; font-size: 12px; margin: 8px 0 0; }

.legend { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.legend label, .check { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.legend .n { color: var(--muted); font-size: 12px; margin-left: auto; }
.legend .sel-mark {
  width: 14px; height: 14px; border-radius: 50%;
  border: 3px solid #111; background: #fff; display: inline-block;
}

.map-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 560px;
}
#map { width: 100%; height: calc(100% - 26px); min-height: 560px; }
.map-tip { margin: 0; padding: 4px 10px; font-size: 11px; color: var(--muted); background: var(--card); border-top: 1px solid var(--line); }

.leaflet-popup-content { font-size: 13px; line-height: 1.5; }
.popup-title { font-weight: 700; margin-bottom: 2px; }
.popup-tag { display: inline-block; padding: 0 6px; border-radius: 8px; color: #fff; font-size: 11px; margin-bottom: 4px; }
.popup-grid { display: grid; grid-template-columns: auto auto; gap: 0 12px; }

.summary { padding: 0 20px 20px; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}
.card .k { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.card .v { font-size: 20px; font-weight: 700; }
.card .s { color: var(--muted); font-size: 12px; }

.grid2 {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 2fr;
  gap: 16px;
}
.box {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  min-width: 0;
}

.bars { display: flex; flex-direction: column; gap: 5px; }
.bar-row { display: grid; grid-template-columns: 64px 1fr 28px; align-items: center; gap: 8px; font-size: 12px; cursor: pointer; }
.bar-row:hover .bar-name { text-decoration: underline; }
.bar-track { display: flex; height: 14px; background: #f3f4f6; border-radius: 4px; overflow: hidden; }
.bar-seg { height: 100%; }
.bar-num { text-align: right; font-variant-numeric: tabular-nums; }
.bar-row.active .bar-name { font-weight: 700; }

.table-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }
.table-head h3 { margin: 0; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 12px; }
.filters select { font: inherit; padding: 3px 6px; border: 1px solid var(--line); border-radius: 6px; margin-left: 4px; }

.table-scroll { max-height: 460px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; text-align: left; }
th { position: sticky; top: 0; background: #f9fafb; cursor: pointer; user-select: none; }
th.sorted-asc::after { content: " ▲"; font-size: 9px; }
th.sorted-desc::after { content: " ▼"; font-size: 9px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #f9fafb; }
td.name { white-space: normal; min-width: 160px; }

.foot { padding: 12px 20px 24px; color: var(--muted); font-size: 12px; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding: 8px 16px 16px; }
  .map-wrap, #map { min-height: 420px; }
  .grid2 { grid-template-columns: 1fr; }
  .summary, .top, .foot { padding-left: 16px; padding-right: 16px; }
}
